Skip to content

Commit 9def7a8

Browse files
authored
Merge pull request #58108 from nextcloud/chore/update-files
chore(deps): update `@nextcloud/files` to v4.0.0-rc.1
2 parents 209c5c3 + e3068bf commit 9def7a8

File tree

196 files changed

+915
-1086
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+915
-1086
lines changed

apps/comments/src/actions/inlineUnreadCommentsAction.spec.ts

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
/**
1+
/*!
22
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import type { Folder, View } from '@nextcloud/files'
6+
import type { IFolder, IView } from '@nextcloud/files'
77

8-
import { File, FileAction, Permission } from '@nextcloud/files'
8+
import { File, Permission } from '@nextcloud/files'
99
import { describe, expect, test, vi } from 'vitest'
1010
import logger from '../logger.js'
1111
import { action } from './inlineUnreadCommentsAction.ts'
1212

1313
const view = {
1414
id: 'files',
1515
name: 'Files',
16-
} as View
16+
} as IView
1717

1818
describe('Inline unread comments action display name tests', () => {
1919
test('Default values', () => {
@@ -29,36 +29,35 @@ describe('Inline unread comments action display name tests', () => {
2929
root: '/files/admin',
3030
})
3131

32-
expect(action).toBeInstanceOf(FileAction)
3332
expect(action.id).toBe('comments-unread')
3433
expect(action.displayName({
3534
nodes: [file],
3635
view,
37-
folder: {} as Folder,
36+
folder: {} as IFolder,
3837
contents: [],
3938
})).toBe('')
4039
expect(action.title!({
4140
nodes: [file],
4241
view,
43-
folder: {} as Folder,
42+
folder: {} as IFolder,
4443
contents: [],
4544
})).toBe('1 new comment')
4645
expect(action.iconSvgInline({
4746
nodes: [file],
4847
view,
49-
folder: {} as Folder,
48+
folder: {} as IFolder,
5049
contents: [],
5150
})).toMatch(/<svg.+<\/svg>/)
5251
expect(action.enabled!({
5352
nodes: [file],
5453
view,
55-
folder: {} as Folder,
54+
folder: {} as IFolder,
5655
contents: [],
5756
})).toBe(true)
5857
expect(action.inline!({
5958
nodes: [file],
6059
view,
61-
folder: {} as Folder,
60+
folder: {} as IFolder,
6261
contents: [],
6362
})).toBe(true)
6463
expect(action.default).toBeUndefined()
@@ -81,13 +80,13 @@ describe('Inline unread comments action display name tests', () => {
8180
expect(action.displayName({
8281
nodes: [file],
8382
view,
84-
folder: {} as Folder,
83+
folder: {} as IFolder,
8584
contents: [],
8685
})).toBe('')
8786
expect(action.title!({
8887
nodes: [file],
8988
view,
90-
folder: {} as Folder,
89+
folder: {} as IFolder,
9190
contents: [],
9291
})).toBe('2 new comments')
9392
})
@@ -108,7 +107,7 @@ describe('Inline unread comments action enabled tests', () => {
108107
expect(action.enabled!({
109108
nodes: [file],
110109
view,
111-
folder: {} as Folder,
110+
folder: {} as IFolder,
112111
contents: [],
113112
})).toBe(false)
114113
})
@@ -129,7 +128,7 @@ describe('Inline unread comments action enabled tests', () => {
129128
expect(action.enabled!({
130129
nodes: [file],
131130
view,
132-
folder: {} as Folder,
131+
folder: {} as IFolder,
133132
contents: [],
134133
})).toBe(false)
135134
})
@@ -150,7 +149,7 @@ describe('Inline unread comments action enabled tests', () => {
150149
expect(action.enabled!({
151150
nodes: [file],
152151
view,
153-
folder: {} as Folder,
152+
folder: {} as IFolder,
154153
contents: [],
155154
})).toBe(true)
156155
})
@@ -171,7 +170,7 @@ describe('Inline unread comments action enabled tests', () => {
171170
expect(action.enabled!({
172171
nodes: [file],
173172
view,
174-
folder: {} as Folder,
173+
folder: {} as IFolder,
175174
contents: [],
176175
})).toBe(true)
177176
})
@@ -204,7 +203,7 @@ describe('Inline unread comments action execute tests', () => {
204203
const result = await action.exec!({
205204
nodes: [file],
206205
view,
207-
folder: {} as Folder,
206+
folder: {} as IFolder,
208207
contents: [],
209208
})
210209

@@ -241,7 +240,7 @@ describe('Inline unread comments action execute tests', () => {
241240
const result = await action.exec!({
242241
nodes: [file],
243242
view,
244-
folder: {} as Folder,
243+
folder: {} as IFolder,
245244
contents: [],
246245
})
247246

apps/comments/src/actions/inlineUnreadCommentsAction.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6+
import type { IFileAction } from '@nextcloud/files'
7+
68
import CommentProcessingSvg from '@mdi/svg/svg/comment-processing.svg?raw'
7-
import { FileAction, getSidebar } from '@nextcloud/files'
9+
import { getSidebar } from '@nextcloud/files'
810
import { n, t } from '@nextcloud/l10n'
911
import logger from '../logger.js'
1012

11-
export const action = new FileAction({
13+
export const action: IFileAction = {
1214
id: 'comments-unread',
1315

1416
title({ nodes }) {
@@ -47,4 +49,4 @@ export const action = new FileAction({
4749
inline: () => true,
4850

4951
order: -140,
50-
})
52+
}

apps/files/src/actions/convertAction.ts

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
/**
1+
/*!
22
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
5+
6+
import type { IFileAction } from '@nextcloud/files'
7+
58
import AutoRenewSvg from '@mdi/svg/svg/autorenew.svg?raw'
69
import { getCapabilities } from '@nextcloud/capabilities'
7-
import { FileAction, registerFileAction } from '@nextcloud/files'
10+
import { registerFileAction } from '@nextcloud/files'
811
import { t } from '@nextcloud/l10n'
912
import { generateUrl } from '@nextcloud/router'
1013
import { convertFile, convertFiles } from './convertUtils.ts'
@@ -18,47 +21,45 @@ type ConversionsProvider = {
1821
export const ACTION_CONVERT = 'convert'
1922

2023
/**
21-
*
24+
* Registers the convert actions based on the capabilities provided by the server.
2225
*/
2326
export function registerConvertActions() {
2427
// Generate sub actions
2528
const convertProviders = getCapabilities()?.files?.file_conversions as ConversionsProvider[] ?? []
26-
const actions = convertProviders.map(({ to, from, displayName }) => {
27-
return new FileAction({
28-
id: `convert-${from}-${to}`,
29-
displayName: () => t('files', 'Save as {displayName}', { displayName }),
30-
iconSvgInline: () => generateIconSvg(to),
31-
enabled: ({ nodes }) => {
32-
// Check that all nodes have the same mime type
33-
return nodes.every((node) => from === node.mime)
34-
},
29+
const actions = convertProviders.map(({ to, from, displayName }) => ({
30+
id: `convert-${from}-${to}`,
31+
displayName: () => t('files', 'Save as {displayName}', { displayName }),
32+
iconSvgInline: () => generateIconSvg(to),
33+
enabled: ({ nodes }) => {
34+
// Check that all nodes have the same mime type
35+
return nodes.every((node) => from === node.mime)
36+
},
3537

36-
async exec({ nodes }) {
37-
if (!nodes[0]) {
38-
return false
39-
}
38+
async exec({ nodes }) {
39+
if (!nodes[0]) {
40+
return false
41+
}
4042

41-
// If we're here, we know that the node has a fileid
42-
convertFile(nodes[0].fileid as number, to)
43+
// If we're here, we know that the node has a fileid
44+
convertFile(nodes[0].fileid as number, to)
4345

44-
// Silently terminate, we'll handle the UI in the background
45-
return null
46-
},
46+
// Silently terminate, we'll handle the UI in the background
47+
return null
48+
},
4749

48-
async execBatch({ nodes }) {
49-
const fileIds = nodes.map((node) => node.fileid).filter(Boolean) as number[]
50-
convertFiles(fileIds, to)
50+
async execBatch({ nodes }) {
51+
const fileIds = nodes.map((node) => node.fileid).filter(Boolean) as number[]
52+
convertFiles(fileIds, to)
5153

52-
// Silently terminate, we'll handle the UI in the background
53-
return Array(nodes.length).fill(null)
54-
},
54+
// Silently terminate, we'll handle the UI in the background
55+
return Array(nodes.length).fill(null)
56+
},
5557

56-
parent: ACTION_CONVERT,
57-
})
58-
})
58+
parent: ACTION_CONVERT,
59+
} satisfies IFileAction))
5960

6061
// Register main action
61-
registerFileAction(new FileAction({
62+
registerFileAction({
6263
id: ACTION_CONVERT,
6364
displayName: () => t('files', 'Save as …'),
6465
iconSvgInline: () => AutoRenewSvg,
@@ -69,15 +70,16 @@ export function registerConvertActions() {
6970
return null
7071
},
7172
order: 25,
72-
}))
73+
} satisfies IFileAction)
7374

7475
// Register sub actions
7576
actions.forEach(registerFileAction)
7677
}
7778

7879
/**
80+
* Generates an SVG icon for a given mime type by using the server's mime icon endpoint.
7981
*
80-
* @param mime
82+
* @param mime - The mime type to generate the icon for
8183
*/
8284
export function generateIconSvg(mime: string) {
8385
// Generate icon based on mime type

apps/files/src/actions/deleteAction.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
/**
1+
/*!
22
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
5-
import type { View } from '@nextcloud/files'
5+
6+
import type { IView } from '@nextcloud/files'
67

78
import axios from '@nextcloud/axios'
89
import * as capabilities from '@nextcloud/capabilities'
910
import * as eventBus from '@nextcloud/event-bus'
10-
import { File, FileAction, Folder, Permission } from '@nextcloud/files'
11+
import { File, Folder, Permission } from '@nextcloud/files'
1112
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'
1213
import logger from '../logger.ts'
1314
import { action } from './deleteAction.ts'
@@ -20,12 +21,12 @@ vi.mock('@nextcloud/capabilities')
2021
const view = {
2122
id: 'files',
2223
name: 'Files',
23-
} as View
24+
} as IView
2425

2526
const trashbinView = {
2627
id: 'trashbin',
2728
name: 'Trashbin',
28-
} as View
29+
} as IView
2930

3031
describe('Delete action conditions tests', () => {
3132
beforeEach(() => {
@@ -90,7 +91,6 @@ describe('Delete action conditions tests', () => {
9091
})
9192

9293
test('Default values', () => {
93-
expect(action).toBeInstanceOf(FileAction)
9494
expect(action.id).toBe('delete')
9595
expect(action.displayName({
9696
nodes: [file],

apps/files/src/actions/deleteAction.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
/**
1+
/*!
22
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
5+
6+
import type { IFileAction } from '@nextcloud/files'
7+
58
import CloseSvg from '@mdi/svg/svg/close.svg?raw'
69
import NetworkOffSvg from '@mdi/svg/svg/network-off.svg?raw'
710
import TrashCanSvg from '@mdi/svg/svg/trash-can-outline.svg?raw'
8-
import { FileAction, Permission } from '@nextcloud/files'
11+
import { Permission } from '@nextcloud/files'
912
import { loadState } from '@nextcloud/initial-state'
1013
import { t } from '@nextcloud/l10n'
1114
import PQueue from 'p-queue'
@@ -20,7 +23,7 @@ const queue = new PQueue({ concurrency: 5 })
2023

2124
export const ACTION_DELETE = 'delete'
2225

23-
export const action = new FileAction({
26+
export const action: IFileAction = {
2427
id: ACTION_DELETE,
2528
displayName,
2629
iconSvgInline: ({ nodes }) => {
@@ -117,4 +120,4 @@ export const action = new FileAction({
117120
description: t('files', 'Delete'),
118121
key: 'Delete',
119122
},
120-
})
123+
}

apps/files/src/actions/downloadAction.spec.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
/**
1+
/*!
22
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6-
import type { View } from '@nextcloud/files'
6+
import type { IView } from '@nextcloud/files'
77

88
import axios from '@nextcloud/axios'
99
import * as dialogs from '@nextcloud/dialogs'
1010
import * as eventBus from '@nextcloud/event-bus'
11-
import { DefaultType, File, FileAction, Folder, Permission } from '@nextcloud/files'
11+
import { DefaultType, File, Folder, Permission } from '@nextcloud/files'
1212
import { beforeAll, beforeEach, describe, expect, test, vi } from 'vitest'
1313
import { action } from './downloadAction.ts'
1414

@@ -19,7 +19,7 @@ vi.mock('@nextcloud/event-bus')
1919
const view = {
2020
id: 'files',
2121
name: 'Files',
22-
} as View
22+
} as IView
2323

2424
// Mock webroot variable
2525
beforeAll(() => {
@@ -28,7 +28,6 @@ beforeAll(() => {
2828

2929
describe('Download action conditions tests', () => {
3030
test('Default values', () => {
31-
expect(action).toBeInstanceOf(FileAction)
3231
expect(action.id).toBe('download')
3332
expect(action.displayName({
3433
nodes: [],

0 commit comments

Comments
 (0)