diff --git a/products/ASC.Files/Client/src/components/GlobalEvents/CreateEvent.js b/products/ASC.Files/Client/src/components/GlobalEvents/CreateEvent.js index 3486d792c0..ce9fd3a5ce 100644 --- a/products/ASC.Files/Client/src/components/GlobalEvents/CreateEvent.js +++ b/products/ASC.Files/Client/src/components/GlobalEvents/CreateEvent.js @@ -123,38 +123,32 @@ const CreateEvent = ({ }) .then(() => editCompleteAction(id, item, false, type)) .catch((err) => { - console.log("err", err); - const isPasswordError = new RegExp("password"); - - if (isPasswordError.test(err)) { - toastr.error( - t("Translations:FileProtected"), - t("Common:Warning") - ); - - setIsUpdatingRowItem(false); - - setVisible(false); - - setFormCreationInfo({ - newTitle: `${newValue}.${extension}`, - fromExst: ".docx", - toExst: extension, - open, - actionId: id, - fileInfo: { - id: templateId, - folderId: parentId, - fileExst: extension, - }, - }); - - setConvertPasswordDialogVisible(true); - - open && openDocEditor(null, null, tab); - } else { - toastr.error(e); + if (err.indexOf("password") == -1) { + toastr.error(err, t("Common:Warning")); + return; } + + toastr.error(t("Translations:FileProtected"), t("Common:Warning")); + + setIsUpdatingRowItem(false); + + setVisible(false); + + setFormCreationInfo({ + newTitle: `${newValue}.${extension}`, + fromExst: ".docx", + toExst: extension, + open, + actionId: id, + fileInfo: { + id: templateId, + folderId: parentId, + fileExst: extension, + }, + }); + setConvertPasswordDialogVisible(true); + + open && openDocEditor(null, null, tab); }) .finally(() => { const fileIds = [+id]; diff --git a/products/ASC.Files/Client/src/components/dialogs/ConvertPasswordDialog/index.js b/products/ASC.Files/Client/src/components/dialogs/ConvertPasswordDialog/index.js index c320a690bd..0e5f5fd80c 100644 --- a/products/ASC.Files/Client/src/components/dialogs/ConvertPasswordDialog/index.js +++ b/products/ASC.Files/Client/src/components/dialogs/ConvertPasswordDialog/index.js @@ -92,17 +92,18 @@ const ConvertPasswordDialogComponent = (props) => { onClose(); }) .catch((err) => { - console.log("err", err); - - const isPasswordError = new RegExp(/\(password\)*$/); - - if (isPasswordError.test(err)) { - toastr.error(t("CreationError"), t("Common:Warning")); - if (_isMounted) { - setPasswordValid(false); - focusInput(); - } + if (err.indexOf("password") == -1) { + toastr.error(err, t("Common:Warning")); + return; } + + toastr.error(t("CreationError"), t("Common:Warning")); + if (_isMounted) { + setPasswordValid(false); + focusInput(); + } + }) + .finally(() => { _isMounted && setIsLoading(false); }); } else { @@ -116,17 +117,18 @@ const ConvertPasswordDialogComponent = (props) => { editCompleteAction(actionId, fileInfo, false); }) .catch((err) => { - console.log("err", err); - const isPasswordError = new RegExp(/\(password\)*$/); - - if (isPasswordError.test(err)) { - toastr.error(t("CreationError"), t("Common:Warning")); - open && openDocEditor(null, null, tab); - if (_isMounted) { - setPasswordValid(false); - focusInput(); - } + if (err.indexOf("password") == -1) { + toastr.error(err, t("Common:Warning")); + return; } + toastr.error(t("CreationError"), t("Common:Warning")); + open && openDocEditor(null, null, tab); + if (_isMounted) { + setPasswordValid(false); + focusInput(); + } + }) + .finally(() => { _isMounted && setIsLoading(false); }); } diff --git a/products/ASC.Files/Client/src/store/ContextOptionsStore.js b/products/ASC.Files/Client/src/store/ContextOptionsStore.js index 6b85ec1243..860b6aa24a 100644 --- a/products/ASC.Files/Client/src/store/ContextOptionsStore.js +++ b/products/ASC.Files/Client/src/store/ContextOptionsStore.js @@ -69,19 +69,18 @@ class ContextOptionsStore { this.settingsStore.extsWebRestrictedEditing[0]; this.uploadDataStore.copyAsAction(id, newTitle, folderId).catch((err) => { - console.log("err", err); - const isPasswordError = new RegExp(/\(password\)*$/); - - if (isPasswordError.test(err)) { - toastr.error(t("Translations:FileProtected"), t("Common:Warning")); - setFormCreationInfo({ - newTitle, - fromExst: fileExst, - toExst: this.settingsStore.extsWebRestrictedEditing[0], - fileInfo: item, - }); - setConvertPasswordDialogVisible(true); + if (err.indexOf("password") == -1) { + toastr.error(err, t("Common:Warning")); + return; } + toastr.error(t("Translations:FileProtected"), t("Common:Warning")); + setFormCreationInfo({ + newTitle, + fromExst: fileExst, + toExst: this.settingsStore.extsWebRestrictedEditing[0], + fileInfo: item, + }); + setConvertPasswordDialogVisible(true); }); };