Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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 <[email protected]>
  • Loading branch information
susnux authored and backportbot[bot] committed Jun 8, 2024
commit 5b1969b0f5ef9edc9a78cea51326863497343fa9
10 changes: 5 additions & 5 deletions apps/files/src/components/FileEntry/FileEntryActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,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: {
Expand All @@ -256,7 +256,7 @@ export default defineComponent({
},

mountType() {
return this.source._attributes['mount-type']
return this.source.attributes['mount-type']
},
},

Expand Down
6 changes: 4 additions & 2 deletions apps/files/src/components/FileEntryMixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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)

Expand Down Expand Up @@ -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) {
Expand Down