From 496e2de0d208ea67fb54dd9137c8412fa6939c25 Mon Sep 17 00:00:00 2001 From: gopienkonikita Date: Tue, 30 Jan 2024 14:13:30 +0300 Subject: [PATCH] Fix Bug 65381 - Rooms. Public. Fixed opening files of unsupported formats. --- packages/client/public/locales/en/Files.json | 3 ++- packages/client/src/HOCs/withFileActions.js | 3 ++- packages/client/src/HOCs/withHotkeys.js | 2 +- packages/client/src/store/FilesActionsStore.js | 7 ++++++- packages/client/src/store/HotkeyStore.js | 4 ++-- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/client/public/locales/en/Files.json b/packages/client/public/locales/en/Files.json index 790346a419..553e8f9604 100644 --- a/packages/client/public/locales/en/Files.json +++ b/packages/client/public/locales/en/Files.json @@ -191,5 +191,6 @@ "WantToRestoreTheRooms": "All shared links in restored rooms will become active, and their contents will be available to everyone with the room links. Do you want to restore the rooms?", "WithSubfolders": "With subfolders", "YouLeftTheRoom": "You have left the room", - "LinkSettings": "Link settings" + "LinkSettings": "Link settings", + "FileDownloadingIsRestricted": "File downloading is restricted in this room." } diff --git a/packages/client/src/HOCs/withFileActions.js b/packages/client/src/HOCs/withFileActions.js index 9601f022fa..a819f87256 100644 --- a/packages/client/src/HOCs/withFileActions.js +++ b/packages/client/src/HOCs/withFileActions.js @@ -178,6 +178,7 @@ export default function withFileActions(WrappedFileItem) { onFilesClick = (e) => { const { + t, item, openFileAction, setParentId, @@ -207,7 +208,7 @@ export default function withFileActions(WrappedFileItem) { // setRoomType(item.roomType); } - openFileAction(item); + openFileAction(item, t); }; onSelectTag = (tag) => { diff --git a/packages/client/src/HOCs/withHotkeys.js b/packages/client/src/HOCs/withHotkeys.js index bce4cde95b..0cc62a9705 100644 --- a/packages/client/src/HOCs/withHotkeys.js +++ b/packages/client/src/HOCs/withHotkeys.js @@ -218,7 +218,7 @@ const withHotkeys = (Component) => { useHotkeys("ctrl+RIGHT, command+RIGHT", moveCaretRight, hotkeysFilter); //Open item - useHotkeys("Enter", openItem, hotkeysFilter); + useHotkeys("Enter", () => openItem(t), hotkeysFilter); //Back to parent folder useHotkeys("Backspace", backToParentFolder, hotkeysFilter); diff --git a/packages/client/src/store/FilesActionsStore.js b/packages/client/src/store/FilesActionsStore.js index 8d7ab6ffb5..50bce206c3 100644 --- a/packages/client/src/store/FilesActionsStore.js +++ b/packages/client/src/store/FilesActionsStore.js @@ -2091,7 +2091,7 @@ class FilesActionStore { onMarkAsRead = (item) => this.markAsRead([], [`${item.id}`], item); - openFileAction = (item) => { + openFileAction = (item, t) => { const { openDocEditor, isPrivacyFolder, setSelection } = this.filesStore; const { currentDeviceType } = this.authStore.settingsStore; const { fileItemsList } = this.pluginStore; @@ -2226,6 +2226,11 @@ class FilesActionStore { } } + if (!item.security.Download) { + toastr.error(t("Files:FileDownloadingIsRestricted")); + return; + } + return window.open(viewUrl, "_self"); } }; diff --git a/packages/client/src/store/HotkeyStore.js b/packages/client/src/store/HotkeyStore.js index 74c0ae9cea..77a62ffb4c 100644 --- a/packages/client/src/store/HotkeyStore.js +++ b/packages/client/src/store/HotkeyStore.js @@ -494,14 +494,14 @@ class HotkeyStore { if (this.nextFile) this.setCaret(this.nextFile); }; - openItem = () => { + openItem = (t) => { const { selection } = this.filesStore; const someDialogIsOpen = checkDialogsOpen(); selection.length === 1 && !someDialogIsOpen && - this.filesActionsStore.openFileAction(selection[0]); + this.filesActionsStore.openFileAction(selection[0], t); }; selectAll = () => {