Refine upload status behavior
This commit is contained in:
parent
76c04995e9
commit
1fadbda6d2
@ -20,13 +20,16 @@ export default function AdminUploadPanel({
|
|||||||
uploadState: {
|
uploadState: {
|
||||||
isUploading,
|
isUploading,
|
||||||
hideUploadPanel,
|
hideUploadPanel,
|
||||||
|
uploadError,
|
||||||
},
|
},
|
||||||
resetUploadState,
|
resetUploadState,
|
||||||
} = useAppState();
|
} = useAppState();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppGrid
|
<AppGrid
|
||||||
className={clsx((!isUploading || hideUploadPanel) && 'hidden')}
|
className={clsx(
|
||||||
|
((!isUploading || uploadError) || hideUploadPanel) && 'hidden',
|
||||||
|
)}
|
||||||
contentMain={
|
contentMain={
|
||||||
<Container
|
<Container
|
||||||
color="gray"
|
color="gray"
|
||||||
|
|||||||
@ -74,7 +74,9 @@ export default function PhotoUploadWithStatus({
|
|||||||
}, [resetUploadState]);
|
}, [resetUploadState]);
|
||||||
const isFinishing = isPending && shouldResetUploadStateAfterPending.current;
|
const isFinishing = isPending && shouldResetUploadStateAfterPending.current;
|
||||||
|
|
||||||
const uploadNumberText = `${fileUploadIndex + 1} of ${filesLength}`;
|
const uploadStatusText = filesLength > 1
|
||||||
|
? `${fileUploadIndex + 1} of ${filesLength}`
|
||||||
|
: undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={clsx(
|
<div className={clsx(
|
||||||
@ -127,6 +129,7 @@ export default function PhotoUploadWithStatus({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
console.error(error);
|
||||||
setUploadState?.({
|
setUploadState?.({
|
||||||
isUploading: false,
|
isUploading: false,
|
||||||
uploadError: `Upload Error: ${error.message}`,
|
uploadError: `Upload Error: ${error.message}`,
|
||||||
@ -155,17 +158,25 @@ export default function PhotoUploadWithStatus({
|
|||||||
Finishing ...
|
Finishing ...
|
||||||
</>
|
</>
|
||||||
: <>
|
: <>
|
||||||
{!showButton && <>
|
{!showButton && uploadStatusText
|
||||||
<ResponsiveText shortText={uploadNumberText}>
|
? <>
|
||||||
Uploading {uploadNumberText}
|
<ResponsiveText shortText={uploadStatusText}>
|
||||||
</ResponsiveText>
|
Uploading {uploadStatusText}
|
||||||
{': '}
|
</ResponsiveText>
|
||||||
</>}
|
{': '}
|
||||||
{fileUploadName}
|
{fileUploadName}
|
||||||
|
</>
|
||||||
|
: <ResponsiveText shortText={fileUploadName}>
|
||||||
|
Uploading {fileUploadName}
|
||||||
|
</ResponsiveText>}
|
||||||
</>
|
</>
|
||||||
: !showButton && <>Initializing</>}
|
: !showButton && <>Initializing</>}
|
||||||
</span>
|
</span>
|
||||||
</div>}
|
</div>}
|
||||||
|
{uploadError &&
|
||||||
|
<div className="text-error">
|
||||||
|
{uploadError}
|
||||||
|
</div>}
|
||||||
{debug && debugDownload &&
|
{debug && debugDownload &&
|
||||||
<a
|
<a
|
||||||
className="block"
|
className="block"
|
||||||
@ -174,10 +185,6 @@ export default function PhotoUploadWithStatus({
|
|||||||
>
|
>
|
||||||
Download
|
Download
|
||||||
</a>}
|
</a>}
|
||||||
{uploadError &&
|
|
||||||
<div className="text-error">
|
|
||||||
{uploadError}
|
|
||||||
</div>}
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user