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>
pull/45611/head
Ferdinand Thiessen 2024-05-31 14:19:12 +07:00
parent 7004c3cb46
commit 13d9a1007b
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400
2 changed files with 9 additions and 7 deletions

@ -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']
},
},

@ -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) {