moved etag blocked message to upload progress bar
This commit is contained in:
parent
0e025986c1
commit
be27d72ee1
|
@ -13,8 +13,6 @@ import { SetFiles, SetLoading } from 'pages/gallery';
|
|||
import { AppContext } from 'pages/_app';
|
||||
import { logError } from 'utils/sentry';
|
||||
import { FileRejection } from 'react-dropzone';
|
||||
import { CustomError } from 'utils/common/errorUtil';
|
||||
import { DESKTOP_APP_DOWNLOAD_URL, downloadApp } from 'utils/common';
|
||||
|
||||
interface Props {
|
||||
syncWithRemote: (force?: boolean, silent?: boolean) => Promise<void>;
|
||||
|
@ -219,19 +217,7 @@ export default function Upload(props: Props) {
|
|||
props.setFiles,
|
||||
);
|
||||
} catch (err) {
|
||||
if (err?.message===CustomError.ETAG_MISSING) {
|
||||
props.setDialogMessage({ title: constants.UPLOAD_FAILED,
|
||||
staticBackdrop: true,
|
||||
close: { variant: 'danger', text: constants.CLOSE },
|
||||
content: constants.ETAGS_BLOCKED(DESKTOP_APP_DOWNLOAD_URL),
|
||||
proceed: {
|
||||
text: constants.DOWNLOAD,
|
||||
action: downloadApp,
|
||||
variant: 'success',
|
||||
} });
|
||||
} else {
|
||||
props.setBannerMessage(err.message);
|
||||
}
|
||||
props.setBannerMessage(err.message);
|
||||
setProgressView(false);
|
||||
throw err;
|
||||
} finally {
|
||||
|
|
|
@ -7,7 +7,9 @@ import {
|
|||
import { FileRejection } from 'react-dropzone';
|
||||
import { FileUploadResults, UPLOAD_STAGES } from 'services/uploadService';
|
||||
import styled from 'styled-components';
|
||||
import { DESKTOP_APP_DOWNLOAD_URL } from 'utils/common';
|
||||
import constants from 'utils/strings/constants';
|
||||
import englishConstants from 'utils/strings/englishConstants';
|
||||
|
||||
interface Props {
|
||||
fileCounter;
|
||||
|
@ -46,14 +48,16 @@ export default function UploadProgress(props: Props) {
|
|||
const [failedFilesView, setFailedView]=useState(false);
|
||||
const [skippedFilesView, setSkippedFilesView]=useState(false);
|
||||
const [unsupportedFilesView, setUnsupportedFilesView]=useState(false);
|
||||
const [uploadedFileView, setUploadedFileView]=useState(false);
|
||||
const [uploadedFilesView, setUploadedFilesView]=useState(false);
|
||||
const [blockedFilesView, setBlockedFilesView]=useState(false);
|
||||
|
||||
useEffect(()=>{
|
||||
if (props.show) {
|
||||
setFailedView(false);
|
||||
setSkippedFilesView(false);
|
||||
setUnsupportedFilesView(false);
|
||||
setUploadedFileView(false);
|
||||
setUploadedFilesView(false);
|
||||
setBlockedFilesView(false);
|
||||
}
|
||||
}, [props.show]);
|
||||
|
||||
|
@ -77,6 +81,7 @@ export default function UploadProgress(props: Props) {
|
|||
const fileList= fileUploadResults.get(progress);
|
||||
fileUploadResults.set(progress, [...fileList, fileName]);
|
||||
}
|
||||
// fileUploadResults.set(FileUploadResults.BLOCKED, ['random']);
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -140,6 +145,18 @@ export default function UploadProgress(props: Props) {
|
|||
))}
|
||||
</FileList>
|
||||
}
|
||||
{fileUploadResults?.get(FileUploadResults.BLOCKED)?.length>0 &&(<>
|
||||
<SectionHeader onClick={()=>setBlockedFilesView(!blockedFilesView)} > blocked files {blockedFilesView?<ExpandLess/>:<ExpandMore/>}</SectionHeader>
|
||||
<FileList collapsed={!blockedFilesView}>
|
||||
{englishConstants.ETAGS_BLOCKED(DESKTOP_APP_DOWNLOAD_URL)}
|
||||
{fileUploadResults.get(FileUploadResults.BLOCKED).map((fileName) => (
|
||||
|
||||
<li key={fileName} style={{ marginTop: '12px' }}>
|
||||
{fileName}
|
||||
</li>
|
||||
))}
|
||||
</FileList>
|
||||
</>)}
|
||||
{fileUploadResults?.get(FileUploadResults.FAILED)?.length>0 &&(<>
|
||||
<SectionHeader onClick={()=>setFailedView(!failedFilesView)}>{constants.FAILED_FILES} {failedFilesView?<ExpandLess/>:<ExpandMore/>}</SectionHeader>
|
||||
<FileList collapsed={!failedFilesView}>
|
||||
|
@ -180,9 +197,9 @@ export default function UploadProgress(props: Props) {
|
|||
</>)}
|
||||
|
||||
{fileUploadResults?.get(FileUploadResults.UPLOADED)?.length>0 &&(<>
|
||||
<SectionHeader onClick={()=>setUploadedFileView(!uploadedFileView)} > {constants.UPLOADED_FILES} {uploadedFileView?<ExpandLess/>:<ExpandMore/>}</SectionHeader>
|
||||
<SectionHeader onClick={()=>setUploadedFilesView(!uploadedFilesView)} > {constants.UPLOADED_FILES} {uploadedFilesView?<ExpandLess/>:<ExpandMore/>}</SectionHeader>
|
||||
<p>{constants.UPLOADED_INFO}</p>
|
||||
<FileList collapsed={!uploadedFileView}>
|
||||
<FileList collapsed={!uploadedFilesView}>
|
||||
{fileUploadResults.get(FileUploadResults.UPLOADED).map((fileName) => (
|
||||
|
||||
<li key={fileName} style={{ marginTop: '12px' }}>
|
||||
|
|
|
@ -50,6 +50,7 @@ export enum FileUploadResults {
|
|||
FAILED = -1,
|
||||
SKIPPED = -2,
|
||||
UNSUPPORTED = -3,
|
||||
BLOCKED=-4,
|
||||
UPLOADED = 100,
|
||||
}
|
||||
|
||||
|
@ -293,10 +294,13 @@ class UploadService {
|
|||
}
|
||||
} catch (e) {
|
||||
logError(e, 'file upload failed');
|
||||
this.failedFiles.push(fileWithCollection);
|
||||
// set progress to -1 indicating that file upload failed but keep it to show in the file-upload list progress
|
||||
this.fileProgress.set(rawFile.name, FileUploadResults.FAILED);
|
||||
handleError(e);
|
||||
this.failedFiles.push(fileWithCollection);
|
||||
if (e.message ===CustomError.ETAG_MISSING) {
|
||||
this.fileProgress.set(rawFile.name, FileUploadResults.BLOCKED);
|
||||
} else {
|
||||
this.fileProgress.set(rawFile.name, FileUploadResults.FAILED);
|
||||
}
|
||||
} finally {
|
||||
file=null;
|
||||
encryptedFile=null;
|
||||
|
|
|
@ -32,12 +32,6 @@ export function parseError(error) {
|
|||
parsedMessage = constants.SESSION_EXPIRED_MESSAGE;
|
||||
break;
|
||||
}
|
||||
} else if (error?.message) {
|
||||
const errorMessage = error.message.toString();
|
||||
switch (errorMessage) {
|
||||
case CustomError.ETAG_MISSING:
|
||||
parsedMessage=CustomError.ETAG_MISSING;
|
||||
}
|
||||
}
|
||||
if (parsedMessage) {
|
||||
return { parsedError: new Error(parsedMessage), parsed: true };
|
||||
|
|
|
@ -457,7 +457,7 @@ const englishConstants = {
|
|||
<p> please disable any addons that might be preventing ente from using <code>eTags</code> to upload large files, or use our
|
||||
{' '}
|
||||
<a
|
||||
href={url} style={{ color: '#2dc262' }}
|
||||
href={url} style={{ color: '#2dc262', textDecoration: 'underline' }}
|
||||
target="_blank" rel="noreferrer">
|
||||
desktop app
|
||||
</a>
|
||||
|
|
Loading…
Reference in a new issue