Skip to content

Commit c8516c2

Browse files
committed
chore: update @nextcloud/files to 4.0.0
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent 590d839 commit c8516c2

File tree

17 files changed

+661
-242
lines changed

17 files changed

+661
-242
lines changed

apps/files/src/components/FileEntry.vue

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@
5050
<FileEntryActions
5151
v-show="!isRenamingSmallScreen"
5252
ref="actions"
53+
v-model:opened="openedMenu"
5354
:class="`files-list__row-actions-${uniqueId}`"
54-
:opened.sync="openedMenu"
5555
:source="source" />
5656

5757
<!-- Mime -->
@@ -92,12 +92,12 @@
9292
<td
9393
v-for="column in columns"
9494
:key="column.id"
95-
:class="`files-list__row-${currentView.id}-${column.id}`"
95+
:class="`files-list__row-${activeView.id}-${column.id}`"
9696
class="files-list__row-column-custom"
9797
:data-cy-files-list-row-column-custom="column.id"
9898
@click="openDetailsIfAvailable">
9999
<CustomElementRender
100-
:current-view="currentView"
100+
:current-view="activeView"
101101
:render="column.render"
102102
:source="source" />
103103
</td>
@@ -116,9 +116,8 @@ import FileEntryCheckbox from './FileEntry/FileEntryCheckbox.vue'
116116
import FileEntryName from './FileEntry/FileEntryName.vue'
117117
import FileEntryPreview from './FileEntry/FileEntryPreview.vue'
118118
import { useFileListWidth } from '../composables/useFileListWidth.ts'
119-
import { useNavigation } from '../composables/useNavigation.ts'
120-
import { useRouteParameters } from '../composables/useRouteParameters.ts'
121119
import { useActionsMenuStore } from '../store/actionsmenu.ts'
120+
import { useActiveStore } from '../store/active.ts'
122121
import { useDragAndDropStore } from '../store/dragging.ts'
123122
import { useFilesStore } from '../store/files.ts'
124123
import { useRenamingStore } from '../store/renaming.ts'
@@ -160,24 +159,23 @@ export default defineComponent({
160159
const renamingStore = useRenamingStore()
161160
const selectionStore = useSelectionStore()
162161
const filesListWidth = useFileListWidth()
163-
// The file list is guaranteed to be only shown with active view - thus we can set the `loaded` flag
164-
const { currentView } = useNavigation(true)
162+
165163
const {
166-
directory: currentDir,
167-
fileId: currentFileId,
168-
} = useRouteParameters()
164+
activeFolder,
165+
activeNode,
166+
activeView,
167+
} = useActiveStore()
169168
170169
return {
171170
actionsMenuStore,
171+
activeFolder,
172+
activeNode,
173+
activeView,
172174
draggingStore,
175+
filesListWidth,
173176
filesStore,
174177
renamingStore,
175178
selectionStore,
176-
177-
currentDir,
178-
currentFileId,
179-
currentView,
180-
filesListWidth,
181179
}
182180
},
183181
@@ -208,7 +206,7 @@ export default defineComponent({
208206
if (this.filesListWidth < 512 || this.compact) {
209207
return []
210208
}
211-
return this.currentView.columns || []
209+
return this.activeView.columns || []
212210
},
213211
214212
mime() {
@@ -281,7 +279,12 @@ export default defineComponent({
281279
return
282280
}
283281
284-
this.defaultFileAction?.exec(this.source, this.currentView, this.currentDir)
282+
this.defaultFileAction?.exec({
283+
nodes: [this.source],
284+
folder: this.activeFolder!,
285+
contents: this.nodes,
286+
view: this.activeView!,
287+
})
285288
},
286289
},
287290
})

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ export default defineComponent({
208208
}
209209
return this.enabledFileActions.filter((action) => {
210210
try {
211-
return action?.inline?.(this.source, this.currentView)
211+
return action?.inline?.({ nodes: [this.source], view: this.currentView }) === true
212212
} catch (error) {
213213
logger.error('Error while checking if action is inline', { action, error })
214214
return false

apps/files/src/components/FileEntryGrid.vue

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@
6565
<!-- Actions -->
6666
<FileEntryActions
6767
ref="actions"
68+
v-model:opened="openedMenu"
6869
:class="`files-list__row-actions-${uniqueId}`"
6970
:grid-mode="true"
70-
:opened.sync="openedMenu"
7171
:source="source" />
7272
</tr>
7373
</template>
@@ -79,9 +79,9 @@ import FileEntryActions from './FileEntry/FileEntryActions.vue'
7979
import FileEntryCheckbox from './FileEntry/FileEntryCheckbox.vue'
8080
import FileEntryName from './FileEntry/FileEntryName.vue'
8181
import FileEntryPreview from './FileEntry/FileEntryPreview.vue'
82-
import { useNavigation } from '../composables/useNavigation.ts'
83-
import { useRouteParameters } from '../composables/useRouteParameters.ts'
82+
import { useFileListWidth } from '../composables/useFileListWidth.ts'
8483
import { useActionsMenuStore } from '../store/actionsmenu.ts'
84+
import { useActiveStore } from '../store/active.ts'
8585
import { useDragAndDropStore } from '../store/dragging.ts'
8686
import { useFilesStore } from '../store/files.ts'
8787
import { useRenamingStore } from '../store/renaming.ts'
@@ -111,23 +111,24 @@ export default defineComponent({
111111
const filesStore = useFilesStore()
112112
const renamingStore = useRenamingStore()
113113
const selectionStore = useSelectionStore()
114-
// The file list is guaranteed to be only shown with active view - thus we can set the `loaded` flag
115-
const { currentView } = useNavigation(true)
114+
const filesListWidth = useFileListWidth()
115+
116116
const {
117-
directory: currentDir,
118-
fileId: currentFileId,
119-
} = useRouteParameters()
117+
activeFolder,
118+
activeNode,
119+
activeView,
120+
} = useActiveStore()
120121
121122
return {
122123
actionsMenuStore,
124+
activeFolder,
125+
activeNode,
126+
activeView,
123127
draggingStore,
128+
filesListWidth,
124129
filesStore,
125130
renamingStore,
126131
selectionStore,
127-
128-
currentDir,
129-
currentFileId,
130-
currentView,
131132
}
132133
},
133134

apps/files/src/components/FileEntryMixin.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export default defineComponent({
122122
},
123123

124124
isActive() {
125-
return String(this.fileid) === String(this.currentFileId)
125+
return String(this.fileid) === String(this.activeNode.fileid)
126126
},
127127

128128
/**
@@ -378,14 +378,29 @@ export default defineComponent({
378378
event.preventDefault()
379379
event.stopPropagation()
380380
// Execute the first default action if any
381-
this.defaultFileAction.exec(this.source, this.currentView, this.currentDir)
381+
this.defaultFileAction.exec({
382+
nodes: [this.source],
383+
folder: this.activeFolder!,
384+
contents: this.nodes,
385+
view: this.activeView!,
386+
})
382387
},
383388

384389
openDetailsIfAvailable(event) {
385390
event.preventDefault()
386391
event.stopPropagation()
387-
if (sidebarAction?.enabled?.([this.source], this.currentView)) {
388-
sidebarAction.exec(this.source, this.currentView, this.currentDir)
392+
if (sidebarAction?.enabled?.({
393+
nodes: [this.source],
394+
folder: this.activeFolder!,
395+
contents: this.nodes,
396+
view: this.activeView!,
397+
})) {
398+
sidebarAction.exec({
399+
nodes: [this.source],
400+
folder: this.activeFolder!,
401+
contents: this.nodes,
402+
view: this.activeView!,
403+
})
389404
}
390405
},
391406

apps/files/src/components/FilesListVirtual.vue

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,19 @@ export default defineComponent({
311311
// Open the sidebar for the given URL fileid
312312
// iif we just loaded the app.
313313
const node = this.nodes.find((n) => n.fileid === fileId) as NcNode
314-
if (node && sidebarAction?.enabled?.([node], this.currentView)) {
314+
if (node && sidebarAction?.enabled?.({
315+
nodes: [node],
316+
folder: this.currentFolder,
317+
view: this.currentView,
318+
contents: this.nodes,
319+
})) {
315320
logger.debug('Opening sidebar on file ' + node.path, { node })
316-
sidebarAction.exec(node, this.currentView, this.currentFolder.path)
321+
sidebarAction.exec({
322+
nodes: [node],
323+
folder: this.currentFolder,
324+
view: this.currentView,
325+
contents: this.nodes,
326+
})
317327
return
318328
}
319329
logger.warn(`Failed to open sidebar on file ${fileId}, file isn't cached yet !`, { fileId, node })
@@ -393,7 +403,12 @@ export default defineComponent({
393403
// So if there is an enabled default action, so execute it
394404
if (defaultAction) {
395405
logger.debug('Opening file ' + node.path, { node })
396-
return await defaultAction.exec(node, this.currentView, this.currentFolder.path)
406+
return await defaultAction.exec({
407+
nodes: [node],
408+
view: this.currentView,
409+
folder: this.currentFolder,
410+
contents: this.nodes,
411+
})
397412
}
398413
}
399414
// The file is either a folder or has no default action other than downloading
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*!
2+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import { getPinia } from "../store"
7+
import { useFilesStore } from "../store/files"
8+
import { useNavigation } from "./useNavigation"
9+
import { useRouteParameters } from "./useRouteParameters"
10+
11+
export function useContext() {
12+
const filesStore = useFilesStore(getPinia())
13+
const { currentView } = useNavigation(true)
14+
const { directory } = useRouteParameters()
15+
16+
return filesStore.getDirectoryByPath(currentView.value.id, directory)

apps/files/src/utils/actionUtils.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@ import { getPinia } from '../store/index.ts'
1919
*/
2020
export async function executeAction(action: FileAction) {
2121
const activeStore = useActiveStore(getPinia())
22-
const currentDir = (window?.OCP?.Files?.Router?.query?.dir || '/') as string
23-
const currentNode = activeStore.activeNode
24-
const currentView = activeStore.activeView
22+
const currentFolder = activeStore.activeFolder!
23+
const currentNode = activeStore.activeNode!
24+
const currentView = activeStore.activeView!
25+
26+
// @ts-expect-error _children is private
27+
const contents = currentFolder?._children || []
2528

2629
if (!currentNode || !currentView) {
2730
logger.error('No active node or view', { node: currentNode, view: currentView })
@@ -33,14 +36,24 @@ export async function executeAction(action: FileAction) {
3336
return
3437
}
3538

36-
if (!action.enabled!([currentNode], currentView)) {
39+
if (!action.enabled!({
40+
nodes: [currentNode],
41+
view: currentView,
42+
folder: currentFolder,
43+
contents,
44+
})) {
3745
logger.debug('Action is not not available for the current context', { action, node: currentNode, view: currentView })
3846
return
3947
}
4048

4149
let displayName = action.id
4250
try {
43-
displayName = action.displayName([currentNode], currentView)
51+
displayName = action.displayName({
52+
nodes: [currentNode],
53+
view: currentView,
54+
folder: currentFolder,
55+
contents,
56+
})
4457
} catch (error) {
4558
logger.error('Error while getting action display name', { action, error })
4659
}
@@ -50,7 +63,12 @@ export async function executeAction(action: FileAction) {
5063
Vue.set(currentNode, 'status', NodeStatus.LOADING)
5164
activeStore.activeAction = action
5265

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

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

apps/files/src/views/FilesList.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,12 @@ export default defineComponent({
793793
if (window?.OCA?.Files?.Sidebar?.setActiveTab) {
794794
window.OCA.Files.Sidebar.setActiveTab('sharing')
795795
}
796-
sidebarAction.exec(this.currentFolder, this.currentView!, this.currentFolder.path)
796+
sidebarAction.exec({
797+
nodes: [this.source],
798+
view: this.currentView,
799+
folder: this.currentFolder,
800+
contents: this.dirContents,
801+
})
797802
},
798803
799804
toggleGridView() {
@@ -823,7 +828,12 @@ export default defineComponent({
823828
824829
const displayName = this.actionDisplayName(action)
825830
try {
826-
const success = await action.exec(this.source, this.dirContents, this.currentDir)
831+
const success = await action.exec({
832+
nodes: [this.source],
833+
view: this.currentView,
834+
folder: this.currentFolder,
835+
contents: this.dirContents,
836+
})
827837
// If the action returns null, we stay silent
828838
if (success === null || success === undefined) {
829839
return

apps/files_sharing/src/files_actions/acceptShareAction.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@ import { pendingSharesViewId } from '../files_views/shares.ts'
1414

1515
export const action = new FileAction({
1616
id: 'accept-share',
17-
displayName: (nodes: Node[]) => n('files_sharing', 'Accept share', 'Accept shares', nodes.length),
17+
displayName: ({ nodes }) => n('files_sharing', 'Accept share', 'Accept shares', nodes.length),
1818
iconSvgInline: () => CheckSvg,
1919

20-
enabled: (nodes, view) => nodes.length > 0 && view.id === pendingSharesViewId,
20+
enabled: ({ nodes, view }) => nodes.length > 0 && view.id === pendingSharesViewId,
2121

22-
async exec(node: Node) {
22+
async exec({ nodes }) {
2323
try {
24+
const node = nodes[0]
2425
const isRemote = !!node.attributes.remote
2526
const url = generateOcsUrl('apps/files_sharing/api/v1/{shareBase}/pending/{id}', {
2627
shareBase: isRemote ? 'remote_shares' : 'shares',
@@ -36,8 +37,13 @@ export const action = new FileAction({
3637
return false
3738
}
3839
},
39-
async execBatch(nodes: Node[], view: View, dir: string) {
40-
return Promise.all(nodes.map((node) => this.exec(node, view, dir)))
40+
async execBatch({ nodes, view, folder, contents }) {
41+
return Promise.all(nodes.map((node) => this.exec({
42+
nodes: [node],
43+
view,
44+
folder,
45+
contents,
46+
})))
4147
},
4248

4349
order: 1,

0 commit comments

Comments
 (0)