diff options
author | skjnldsv <skjnldsv@protonmail.com> | 2024-12-06 09:59:40 +0100 |
---|---|---|
committer | skjnldsv <skjnldsv@protonmail.com> | 2024-12-11 08:54:27 +0100 |
commit | 4470dd623cbb475d8b8a60771a0426b40a27d177 (patch) | |
tree | b25d61712d4a95a3dc98d28602f97da82abed22a /apps/files/src/components/FileEntry/FileEntryActions.vue | |
parent | 3baa91d8421286952cf1973a7d5d49066484b08a (diff) | |
download | nextcloud-server-4470dd623cbb475d8b8a60771a0426b40a27d177.tar.gz nextcloud-server-4470dd623cbb475d8b8a60771a0426b40a27d177.zip |
fix(files): failsafe when executing actions methods
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files/src/components/FileEntry/FileEntryActions.vue')
-rw-r--r-- | apps/files/src/components/FileEntry/FileEntryActions.vue | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/apps/files/src/components/FileEntry/FileEntryActions.vue b/apps/files/src/components/FileEntry/FileEntryActions.vue index f8fde7842a8..d8d46c8f713 100644 --- a/apps/files/src/components/FileEntry/FileEntryActions.vue +++ b/apps/files/src/components/FileEntry/FileEntryActions.vue @@ -163,7 +163,14 @@ export default defineComponent({ if (this.filesListWidth < 768 || this.gridMode) { return [] } - return this.enabledFileActions.filter(action => action?.inline?.(this.source, this.currentView)) + return this.enabledFileActions.filter(action => { + try { + return action?.inline?.(this.source, this.currentView) + } catch (error) { + logger.error('Error while checking if action is inline', { action, error }) + return false + } + }) }, // Enabled action that are displayed inline with a custom render function @@ -236,13 +243,19 @@ export default defineComponent({ methods: { actionDisplayName(action: FileAction) { - if ((this.gridMode || (this.filesListWidth < 768 && action.inline)) && typeof action.title === 'function') { - // if an inline action is rendered in the menu for - // lack of space we use the title first if defined - const title = action.title([this.source], this.currentView) - if (title) return title + try { + if ((this.gridMode || (this.filesListWidth < 768 && action.inline)) && typeof action.title === 'function') { + // if an inline action is rendered in the menu for + // lack of space we use the title first if defined + const title = action.title([this.source], this.currentView) + if (title) return title + } + return action.displayName([this.source], this.currentView) + } catch (error) { + logger.error('Error while getting action display name', { action, error }) + // Not ideal, but better than nothing + return action.id } - return action.displayName([this.source], this.currentView) }, async onActionClick(action, isSubmenu = false) { @@ -257,7 +270,13 @@ export default defineComponent({ return } - const displayName = action.displayName([this.source], this.currentView) + let displayName = action.id + try { + displayName = action.displayName([this.source], this.currentView) + } catch (error) { + logger.error('Error while getting action display name', { action, error }) + } + try { // Set the loading marker this.$emit('update:loading', action.id) @@ -275,8 +294,8 @@ export default defineComponent({ return } showError(t('files', '"{displayName}" action failed', { displayName })) - } catch (e) { - logger.error('Error while executing action', { action, e }) + } catch (error) { + logger.error('Error while executing action', { action, error }) showError(t('files', '"{displayName}" action failed', { displayName })) } finally { // Reset the loading marker |