Skip to content

Commit 4fa769e

Browse files
committed
fixup! chore: update @nextcloud/files to 4.0.0
Signed-off-by: skjnldsv <[email protected]>
1 parent ac3a4b2 commit 4fa769e

File tree

3 files changed

+30
-49
lines changed

3 files changed

+30
-49
lines changed

apps/files/src/components/FileEntry/FileEntryActions.vue

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
v-for="action in enabledRenderActions"
1212
:key="action.id"
1313
:class="'files-list__row-action-' + action.id"
14-
:active-folder="activeFolder"
15-
:active-view="activeView"
14+
:active-folder="activeStore.activeFolder"
15+
:active-view="activeStore.activeView"
1616
:render="action.renderInline"
1717
:source="source"
1818
class="files-list__row-action--inline" />
@@ -121,7 +121,7 @@
121121
</template>
122122

123123
<script lang="ts">
124-
import type { FileAction, Node } from '@nextcloud/files'
124+
import type { ActionContextSingle, FileAction, Node } from '@nextcloud/files'
125125
import type { PropType } from 'vue'
126126
127127
import { DefaultType, NodeStatus } from '@nextcloud/files'
@@ -175,13 +175,11 @@ export default defineComponent({
175175
176176
setup() {
177177
// The file list is guaranteed to be shown with active view - thus we can set the `loaded` flag
178-
const { activeNode, activeFolder, activeView } = useActiveStore()
178+
const activeStore = useActiveStore()
179179
const filesListWidth = useFileListWidth()
180180
const enabledFileActions = inject<FileAction[]>('enabledFileActions', [])
181181
return {
182-
activeFolder,
183-
activeNode,
184-
activeView,
182+
activeStore,
185183
enabledFileActions,
186184
filesListWidth,
187185
t,
@@ -190,18 +188,18 @@ export default defineComponent({
190188
191189
computed: {
192190
isActive() {
193-
return this.activeNode?.source === this.source.source
191+
return this.activeStore.activeNode?.source === this.source.source
194192
},
195193
196194
isLoading() {
197195
return this.source.status === NodeStatus.LOADING
198196
},
199197
200-
actionContext() {
198+
actionContext(): ActionContextSingle {
201199
return {
202200
nodes: [this.source],
203-
view: this.activeView,
204-
folder: this.activeFolder!,
201+
view: this.activeStore.activeView!,
202+
folder: this.activeStore.activeFolder!,
205203
contents: [],
206204
}
207205
},
@@ -307,22 +305,12 @@ export default defineComponent({
307305
if ((this.gridMode || (this.filesListWidth < 768 && action.inline)) && typeof action.title === 'function') {
308306
// if an inline action is rendered in the menu for
309307
// lack of space we use the title first if defined
310-
const title = action.title({
311-
nodes: [this.source],
312-
view: this.activeView,
313-
folder: this.activeFolder!,
314-
contents: [],
315-
})
308+
const title = action.title(this.actionContext)
316309
if (title) {
317310
return title
318311
}
319312
}
320-
return action.displayName({
321-
nodes: [this.source],
322-
view: this.activeView,
323-
folder: this.activeFolder!,
324-
contents: [],
325-
})
313+
return action.displayName(this.actionContext)
326314
} catch (error) {
327315
logger.error('Error while getting action display name', { action, error })
328316
// Not ideal, but better than nothing
@@ -334,7 +322,7 @@ export default defineComponent({
334322
if (!this.isActive) {
335323
return false
336324
}
337-
return this.activeStore?.activeAction?.id === action.id
325+
return this.activeStore.activeAction?.id === action.id
338326
},
339327
340328
async onActionClick(action) {

apps/files/src/components/FilesListVirtual.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ export default defineComponent({
456456
},
457457
458458
onKeyDown(event: KeyboardEvent) {
459+
console.debug('FilesListVirtual: onKeyDown', { key: event.key })
459460
// Up and down arrow keys
460461
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
461462
const columnCount = this.$refs.table?.columnCount ?? 1
@@ -469,6 +470,7 @@ export default defineComponent({
469470
470471
if (nextNode && nextNode?.fileid) {
471472
this.setActiveNode(nextNode)
473+
return
472474
}
473475
}
474476
@@ -484,6 +486,7 @@ export default defineComponent({
484486
485487
if (nextNode && nextNode?.fileid) {
486488
this.setActiveNode(nextNode)
489+
return
487490
}
488491
}
489492
},

apps/files/src/utils/actionUtils.ts

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,28 @@
22
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
5-
import type { FileAction } from '@nextcloud/files'
5+
import type { ActionContextSingle, FileAction } from '@nextcloud/files'
66

77
import { showError, showSuccess } from '@nextcloud/dialogs'
88
import { NodeStatus } from '@nextcloud/files'
99
import { t } from '@nextcloud/l10n'
1010
import Vue from 'vue'
1111
import logger from '../logger.ts'
1212
import { useActiveStore } from '../store/active.ts'
13-
import { getPinia } from '../store/index.ts'
1413

1514
/**
1615
* Execute an action on the current active node
1716
*
1817
* @param action The action to execute
1918
*/
2019
export async function executeAction(action: FileAction) {
21-
const activeStore = useActiveStore(getPinia())
22-
const currentFolder = activeStore.activeFolder!
23-
const currentNode = activeStore.activeNode!
24-
const currentView = activeStore.activeView!
20+
const activeStore = useActiveStore()
21+
const currentFolder = activeStore.activeFolder
22+
const currentNode = activeStore.activeNode
23+
const currentView = activeStore.activeView
2524

26-
// @ts-expect-error _children is private
27-
const contents = currentFolder?._children || []
28-
29-
if (!currentNode || !currentView) {
30-
logger.error('No active node or view', { node: currentNode, view: currentView })
25+
if (!currentFolder || !currentNode || !currentView) {
26+
logger.error('No active folder, node or view', { folder: currentFolder, node: currentNode, view: currentView })
3127
return
3228
}
3329

@@ -36,24 +32,23 @@ export async function executeAction(action: FileAction) {
3632
return
3733
}
3834

39-
if (!action.enabled!({
35+
// @ts-expect-error _children is private
36+
const contents = currentFolder?._children || []
37+
const context = {
4038
nodes: [currentNode],
4139
view: currentView,
4240
folder: currentFolder,
4341
contents,
44-
})) {
42+
} as ActionContextSingle
43+
44+
if (!action.enabled!(context)) {
4545
logger.debug('Action is not not available for the current context', { action, node: currentNode, view: currentView })
4646
return
4747
}
4848

4949
let displayName = action.id
5050
try {
51-
displayName = action.displayName({
52-
nodes: [currentNode],
53-
view: currentView,
54-
folder: currentFolder,
55-
contents,
56-
})
51+
displayName = action.displayName(context)
5752
} catch (error) {
5853
logger.error('Error while getting action display name', { action, error })
5954
}
@@ -63,12 +58,7 @@ export async function executeAction(action: FileAction) {
6358
Vue.set(currentNode, 'status', NodeStatus.LOADING)
6459
activeStore.activeAction = action
6560

66-
const success = await action.exec({
67-
nodes: [currentNode],
68-
view: currentView,
69-
folder: currentFolder!,
70-
contents,
71-
})
61+
const success = await action.exec(context)
7262

7363
// If the action returns null, we stay silent
7464
if (success === null || success === undefined) {

0 commit comments

Comments
 (0)