]> source.dussan.org Git - nextcloud-server.git/commitdiff
refactor(files): Fix TypeScript issues in FileEntryActions
authorFerdinand Thiessen <opensource@fthiessen.de>
Fri, 31 May 2024 12:19:12 +0000 (14:19 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Sat, 8 Jun 2024 15:10:16 +0000 (15:10 +0000)
* 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>
apps/files/src/components/FileEntry/FileEntryActions.vue
apps/files/src/components/FileEntryMixin.ts

index 6e5d78518f73b9cf804b87e579a61807e63b7664..6e713e729882d88a378c21276c8223ab7a446518 100644 (file)
@@ -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<string, FileAction>)
+                               }, {} as Record<string, FileAction[]>)
                },
 
                openedMenu: {
@@ -255,7 +255,7 @@ export default defineComponent({
                },
 
                mountType() {
-                       return this.source._attributes['mount-type']
+                       return this.source.attributes['mount-type']
                },
        },
 
index 2e9958c98f071bb1468774b0e3f94716dad971ca..2e34f757f9eab0c663132890cea0620a732da3df 100644 (file)
@@ -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<typeof FileEntryActions>
+                       actions.execDefaultAction(event)
                },
 
                openDetailsIfAvailable(event) {