Skip to content

Commit 34113c3

Browse files
committed
fix progress bar when uploading
1 parent 9b21607 commit 34113c3

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

interface/src/components/upload/SingleUpload.tsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ const getBorderColor = (theme: Theme, props: DropzoneState) => {
2626
export interface SingleUploadProps {
2727
onDrop: (acceptedFiles: File[]) => void;
2828
onCancel: () => void;
29+
isUploading: boolean;
2930
progress: Progress;
3031
}
3132

32-
const SingleUpload: FC<SingleUploadProps> = ({ onDrop, onCancel, progress }) => {
33-
const isUploading = progress.total > 0;
33+
const SingleUpload: FC<SingleUploadProps> = ({ onDrop, onCancel, isUploading, progress }) => {
34+
const uploading = isUploading && progress.total > 0;
3435

3536
const dropzoneState = useDropzone({
3637
onDrop,
@@ -48,7 +49,7 @@ const SingleUpload: FC<SingleUploadProps> = ({ onDrop, onCancel, progress }) =>
4849
const { LL } = useI18nContext();
4950

5051
const progressText = () => {
51-
if (isUploading) {
52+
if (uploading) {
5253
if (progress.total) {
5354
return LL.UPLOADING() + ': ' + Math.round((progress.loaded * 100) / progress.total) + '%';
5455
}
@@ -68,7 +69,7 @@ const SingleUpload: FC<SingleUploadProps> = ({ onDrop, onCancel, progress }) =>
6869
color: theme.palette.grey[400],
6970
transition: 'border .24s ease-in-out',
7071
width: '100%',
71-
cursor: isUploading ? 'default' : 'pointer',
72+
cursor: uploading ? 'default' : 'pointer',
7273
borderColor: getBorderColor(theme, dropzoneState)
7374
}
7475
})}
@@ -77,7 +78,7 @@ const SingleUpload: FC<SingleUploadProps> = ({ onDrop, onCancel, progress }) =>
7778
<Box flexDirection="column" display="flex" alignItems="center">
7879
<CloudUploadIcon fontSize="large" />
7980
<Typography variant="h6">{progressText()}</Typography>
80-
{isUploading && (
81+
{uploading && (
8182
<Fragment>
8283
<Box width="100%" p={2}>
8384
<LinearProgress

interface/src/framework/system/UploadFileForm.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ const UploadFileForm: FC = () => {
4545
setMd5(data.md5);
4646
toast.success(LL.UPLOAD() + ' MD5 ' + LL.SUCCESSFUL());
4747
} else {
48-
toast.success(LL.UPLOAD() + ' ' + LL.SUCCESSFUL());
4948
setRestarting(true);
5049
}
5150
});
@@ -123,7 +122,7 @@ const UploadFileForm: FC = () => {
123122
<Typography variant="body2">{'MD5: ' + md5}</Typography>
124123
</Box>
125124
)}
126-
<SingleUpload onDrop={startUpload} onCancel={cancelUpload} progress={progress} />
125+
<SingleUpload onDrop={startUpload} onCancel={cancelUpload} isUploading={isUploading} progress={progress} />
127126
{!isUploading && (
128127
<>
129128
<Typography sx={{ pt: 2, pb: 2 }} variant="h6" color="primary">

0 commit comments

Comments
 (0)