diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-05-31 14:19:12 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-06-08 15:58:45 +0200 |
commit | 13d9a1007b40310b4e6cd3abec892dbf266c602d (patch) | |
tree | 842f195c914887fc17cd14a6020d40e82a1df0ee /apps/files | |
parent | 7004c3cb46e58d0545adafcfe7386ac7f79ec16b (diff) | |
download | nextcloud-server-13d9a1007b40310b4e6cd3abec892dbf266c602d.tar.gz nextcloud-server-13d9a1007b40310b4e6cd3abec892dbf266c602d.zip |
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 <opensource@fthiessen.de>
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/src/components/FileEntry/FileEntryActions.vue | 10 | ||||
-rw-r--r-- | 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 cc9413cf413..21d5cd9e796 100644 --- a/apps/files/src/components/FileEntry/FileEntryActions.vue +++ b/apps/files/src/components/FileEntry/FileEntryActions.vue @@ -211,12 +211,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<string, FileAction>) + }, {} as Record<string, FileAction[]>) }, openedMenu: { @@ -238,7 +238,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 f91bd4e540f..b1f564cdd4b 100644 --- a/apps/files/src/components/FileEntryMixin.ts +++ b/apps/files/src/components/FileEntryMixin.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -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' @@ -18,6 +18,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) @@ -212,7 +213,8 @@ export default defineComponent({ return false } - this.$refs.actions.execDefaultAction(event) + const actions = this.$refs.actions as ComponentPublicInstance<typeof FileEntryActions> + actions.execDefaultAction(event) }, openDetailsIfAvailable(event) { |