mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
Added progress spinner to the theme upload button (#18358)
no issue
- Added a progress spinner to the theme upload button in AdminX for
better UX.
---
<!-- Leave the line below if you'd like GitHub Copilot to generate a
summary from your commit -->
<!--
copilot:summary
-->
### <samp>🤖 Generated by Copilot at 68bfc1b</samp>
Improved user feedback for theme upload feature. Added a loading
indicator to the `ThemeModal` component to show the progress of the
`uploadTheme` function.
This commit is contained in:
parent
8e83836de9
commit
5161009e56
1 changed files with 8 additions and 1 deletions
|
@ -47,6 +47,8 @@ const ThemeToolbar: React.FC<ThemeToolbarProps> = ({
|
|||
|
||||
const [uploadConfig, setUploadConfig] = useState<{enabled: boolean; error?: string}>();
|
||||
|
||||
const [isUploading, setUploading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (limiter) {
|
||||
// Sending a bad string to make sure it fails (empty string isn't valid)
|
||||
|
@ -76,8 +78,11 @@ const ThemeToolbar: React.FC<ThemeToolbarProps> = ({
|
|||
let data: ThemesInstallResponseType | undefined;
|
||||
|
||||
try {
|
||||
setUploading(true);
|
||||
data = await uploadTheme({file});
|
||||
setUploading(false);
|
||||
} catch (e) {
|
||||
setUploading(false);
|
||||
handleError(e);
|
||||
}
|
||||
|
||||
|
@ -170,7 +175,9 @@ const ThemeToolbar: React.FC<ThemeToolbarProps> = ({
|
|||
okRunningLabel: 'Overwriting...',
|
||||
okColor: 'red',
|
||||
onOk: async (confirmModal) => {
|
||||
setUploading(true);
|
||||
await handleThemeUpload({file, onActivate: onClose});
|
||||
setUploading(false);
|
||||
setCurrentTab('installed');
|
||||
confirmModal?.remove();
|
||||
}
|
||||
|
@ -180,7 +187,7 @@ const ThemeToolbar: React.FC<ThemeToolbarProps> = ({
|
|||
handleThemeUpload({file, onActivate: onClose});
|
||||
}
|
||||
}}>
|
||||
<Button color='black' label='Upload theme' tag='div' />
|
||||
<Button color='black' label='Upload theme' loading={isUploading} tag='div' />
|
||||
</FileUpload> :
|
||||
<Button color='black' label='Upload theme' onClick={() => {
|
||||
NiceModal.show(LimitModal, {
|
||||
|
|
Loading…
Add table
Reference in a new issue