Web: Files: Fix password protected files operations

This commit is contained in:
Alexey Safronov 2022-06-21 12:29:26 +03:00
parent 18f944b2c6
commit 610f738ca6
3 changed files with 60 additions and 57 deletions

View File

@ -277,32 +277,32 @@ export default function withContent(WrappedContent) {
})
.then(() => this.completeAction(itemId))
.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);
setFormCreationInfo({
newTitle: `${title}.${item.fileExst}`,
fromExst: ".docx",
toExst: item.fileExst,
open,
actionId: itemId,
fileInfo: {
id: fileActionTemplateId,
folderId: item.parentId,
fileExst: item.fileExst,
},
});
setConvertPasswordDialogVisible(true);
open && openDocEditor(null, null, tab);
if (err.indexOf("password") == -1) {
toastr.error(err, t("Common:Warning"));
return;
}
toastr.error(
t("Translations:FileProtected"),
t("Common:Warning")
);
setIsUpdatingRowItem(false);
setFormCreationInfo({
newTitle: `${title}.${item.fileExst}`,
fromExst: ".docx",
toExst: item.fileExst,
open,
actionId: itemId,
fileInfo: {
id: fileActionTemplateId,
folderId: item.parentId,
fileExst: item.fileExst,
},
});
setConvertPasswordDialogVisible(true);
open && openDocEditor(null, null, tab);
})
.finally(() => {
const fileIds = [+itemId];

View File

@ -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,19 @@ 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);
});
}

View File

@ -68,19 +68,19 @@ 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);
});
};