From 10cbc5748f420072394c0933e0cf568a0980bb1a Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Fri, 31 May 2024 14:19:12 +0200 Subject: [PATCH] refactor(files): Fix TypeScript issues in FileEntryActions * We filter the array in `enabledSubmenuActions` so we can be sure the action does have a parent * Node attributes must be accessed using the `attributes` getter not the private `_attributes` property * Cast action ref to correct component interface to make TypeScript happy Signed-off-by: Ferdinand Thiessen --- .../src/components/FileEntry/FileEntryActions.vue | 10 +++++----- apps/files/src/components/FileEntryMixin.ts | 6 ++++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/files/src/components/FileEntry/FileEntryActions.vue b/apps/files/src/components/FileEntry/FileEntryActions.vue index 6e5d78518f7..6e713e72988 100644 --- a/apps/files/src/components/FileEntry/FileEntryActions.vue +++ b/apps/files/src/components/FileEntry/FileEntryActions.vue @@ -228,12 +228,12 @@ export default defineComponent({ return this.enabledActions .filter(action => action.parent) .reduce((arr, action) => { - if (!arr[action.parent]) { - arr[action.parent] = [] + if (!arr[action.parent!]) { + arr[action.parent!] = [] } - arr[action.parent].push(action) + arr[action.parent!].push(action) return arr - }, {} as Record) + }, {} as Record) }, openedMenu: { @@ -255,7 +255,7 @@ export default defineComponent({ }, mountType() { - return this.source._attributes['mount-type'] + return this.source.attributes['mount-type'] }, }, diff --git a/apps/files/src/components/FileEntryMixin.ts b/apps/files/src/components/FileEntryMixin.ts index 2e9958c98f0..2e34f757f9e 100644 --- a/apps/files/src/components/FileEntryMixin.ts +++ b/apps/files/src/components/FileEntryMixin.ts @@ -20,7 +20,7 @@ * */ -import type { PropType } from 'vue' +import type { ComponentPublicInstance, PropType } from 'vue' import { showError } from '@nextcloud/dialogs' import { FileType, Permission, Folder, File as NcFile, NodeStatus, Node, View } from '@nextcloud/files' @@ -35,6 +35,7 @@ import { getDragAndDropPreview } from '../utils/dragUtils.ts' import { hashCode } from '../utils/hashUtils.ts' import { dataTransferToFileTree, onDropExternalFiles, onDropInternalFiles } from '../services/DropService.ts' import logger from '../logger.js' +import FileEntryActions from '../components/FileEntry/FileEntryActions.vue' Vue.directive('onClickOutside', vOnClickOutside) @@ -233,7 +234,8 @@ export default defineComponent({ return false } - this.$refs.actions.execDefaultAction(event) + const actions = this.$refs.actions as ComponentPublicInstance + actions.execDefaultAction(event) }, openDetailsIfAvailable(event) { -- 2.39.5