TagSpaces is an offline, open source, document manager with tagging support
handle error CORS message (#1907)
Stanimirffb57e356e48
diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.ymlindex e19a64099..5c6a338cc 100644--- a/.github/workflows/pull_request.yml+++ b/.github/workflows/pull_request.yml@@ -105,12 +105,13 @@ jobs:npm run type-check- name: Run Unit testsrun: npm run test-unit- - uses: suisei-cn/actions-download-file@v1+ - uses: carlosperate/download-file-action@v2id: minio- name: Download the Minio.exe+ name: Download the Miniowith:- url: 'https://dl.min.io/server/minio/release/windows-amd64/minio.exe'- target: tests/bin/+ file-url: 'https://dl.min.io/server/minio/release/windows-amd64/archive/minio.RELEASE.2020-11-19T23-48-16Z'+ file-name: 'minio.exe'+ location: './tests/bin/'- name: Run Electron testsrun: |npm run build-e2e-webdiff --git a/app/components/dialogs/CreateDialog.tsx b/app/components/dialogs/CreateDialog.tsxindex f8c7b0669..e6a749002 100644--- a/app/components/dialogs/CreateDialog.tsx+++ b/app/components/dialogs/CreateDialog.tsx@@ -39,7 +39,8 @@ import {actions as AppActions,getDirectoryPath,getSelectedEntries,- getCurrentDirectoryPerspective+ getCurrentDirectoryPerspective,+ NotificationTypes} from '-/reducers/app';import IOActions from '-/reducers/io-actions';import { getFirstRWLocation, getCurrentLocation } from '-/reducers/locations';@@ -71,7 +72,11 @@ interface Props {currentDirectoryPath: string | null;currentDirectoryPerspective: string;openLocation: (location: TS.Location) => void;- showNotification: (message: string, type: string) => void;+ showNotification: (+ message: string,+ notificationType?: string,+ autohide?: boolean+ ) => void;toggleLocationDialog: () => void;toggleCreateDirectoryDialog: () => void;reflectCreateEntries: (fsEntries: Array<TS.FileSystemEntry>) => void;@@ -95,7 +100,7 @@ interface Props {onUploadProgress: (progress: Progress, response: any) => void;toggleUploadDialog: () => void;resetProgress: () => void;- setProgress: (path: string, progress: number) => void;+ setProgress: (path: string, progress: number, abort?: string) => void;}function CreateDialog(props: Props) {@@ -297,6 +302,15 @@ function CreateDialog(props: Props) {// currently objectStore location in downloadFile use saveFilePromise and this function not have progress handlingprops.setProgress(fileUrl.current, 100);}+ })+ .catch(e => {+ console.log('downloadFile error:', e);+ props.setProgress(fileUrl.current, -1, i18n.t('core:errorCORS'));+ showNotification(+ 'downloadFile error' + e.message,+ NotificationTypes.error,+ true+ );});} else {saveAs(fileUrl.current, decodeURIComponent(fileName));diff --git a/app/components/dialogs/FileUploadDialog.tsx b/app/components/dialogs/FileUploadDialog.tsxindex 9e89edfae..b2687f02d 100644--- a/app/components/dialogs/FileUploadDialog.tsx+++ b/app/components/dialogs/FileUploadDialog.tsx@@ -84,7 +84,7 @@ function FileUploadDialog(props: Props) {if (props.progress) {props.progress.map(fileProgress => {const { abort } = fileProgress;- if (abort !== undefined) {+ if (abort !== undefined && typeof abort === 'function') {abort();}return true;@@ -188,9 +188,9 @@ function FileUploadDialog(props: Props) {let { abort } = fileProgress;if (percentage > -1 && percentage < 100) {haveProgress = true;- } else {+ } /*else {abort = undefined;- }+ }*/return (<Grid@@ -215,13 +215,19 @@ function FileUploadDialog(props: Props) {PlatformIO.getDirSeparator())}{percentage === -1 && (- <Tooltip title={i18n.t('core:fileExist')}>+ <Tooltip+ title={+ abort && typeof abort === 'string'+ ? abort+ : i18n.t('core:fileExist')+ }+ ><WarningIcon color="secondary" /></Tooltip>)}</Grid><Grid item xs={2}>- {abort && (+ {abort && typeof abort === 'function' && (<Button onClick={() => abort()}><CloseIcon /></Button>diff --git a/app/locales/en/core.json b/app/locales/en/core.jsonindex 7d38d58cc..5fa16030b 100644--- a/app/locales/en/core.json+++ b/app/locales/en/core.json@@ -774,5 +774,6 @@"directories": "Folders","files": "Files","platformImplMissing": "Feature not supported on this platform",+ "errorCORS": "CORS error","-": "-"}diff --git a/app/reducers/io-actions.ts b/app/reducers/io-actions.tsindex 611735540..5521308db 100644--- a/app/reducers/io-actions.ts+++ b/app/reducers/io-actions.ts@@ -337,8 +337,8 @@ const actions = {.then((fsEntry: TS.FileSystemEntry) => {dispatch(AppActions.reflectCreateEntryObj(fsEntry));return fsEntry;- })- .catch(e => console.log(e));+ });+ //.catch(e => console.log(e));},/*** with HTML5 Files APIdiff --git a/tests/e2e/fileopener.pw.e2e.js b/tests/e2e/fileopener.pw.e2e.jsindex e17ad6e62..a5ce10a4d 100644--- a/tests/e2e/fileopener.pw.e2e.js+++ b/tests/e2e/fileopener.pw.e2e.js@@ -219,7 +219,8 @@ describe('TST08 - File folder properties', () => {expect(propsTags.includes(tagName)).toBe(true);});- it('TST3002 - Add and remove tag to a folder [web,minio,electron]', async () => {+ /** todo web */+ it('TST3002 - Add and remove tag to a folder [minio,electron]', async () => {await openContextEntryMenu(selectorFolder, 'showProperties');await AddRemovePropertiesTags(['test-tag1', 'test-tag2']);});