0
Fork 0
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:
Ronald Langeveld 2023-09-26 18:38:09 +07:00 committed by GitHub
parent 8e83836de9
commit 5161009e56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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, {