Skip to content

Commit d1439a2

Browse files
committed
fixup! fixup! fixup! chore: update @nextcloud/files to 4.0.0
1 parent 24ca149 commit d1439a2

File tree

10 files changed

+339
-69
lines changed

10 files changed

+339
-69
lines changed

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

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

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

88
import { File, FileAction, Permission } from '@nextcloud/files'
99
import { describe, expect, test, vi } from 'vitest'
@@ -30,11 +30,36 @@ describe('Inline unread comments action display name tests', () => {
3030

3131
expect(action).toBeInstanceOf(FileAction)
3232
expect(action.id).toBe('comments-unread')
33-
expect(action.displayName([file], view)).toBe('')
34-
expect(action.title!([file], view)).toBe('1 new comment')
35-
expect(action.iconSvgInline([], view)).toMatch(/<svg.+<\/svg>/)
36-
expect(action.enabled!([file], view)).toBe(true)
37-
expect(action.inline!(file, view)).toBe(true)
33+
expect(action.displayName({
34+
nodes: [file],
35+
view,
36+
folder: {} as Folder,
37+
contents: [],
38+
})).toBe('')
39+
expect(action.title!({
40+
nodes: [file],
41+
view,
42+
folder: {} as Folder,
43+
contents: [],
44+
})).toBe('1 new comment')
45+
expect(action.iconSvgInline({
46+
nodes: [file],
47+
view,
48+
folder: {} as Folder,
49+
contents: [],
50+
})).toMatch(/<svg.+<\/svg>/)
51+
expect(action.enabled!({
52+
nodes: [file],
53+
view,
54+
folder: {} as Folder,
55+
contents: [],
56+
})).toBe(true)
57+
expect(action.inline!({
58+
nodes: [file],
59+
view,
60+
folder: {} as Folder,
61+
contents: [],
62+
})).toBe(true)
3863
expect(action.default).toBeUndefined()
3964
expect(action.order).toBe(-140)
4065
})
@@ -51,8 +76,18 @@ describe('Inline unread comments action display name tests', () => {
5176
},
5277
})
5378

54-
expect(action.displayName([file], view)).toBe('')
55-
expect(action.title!([file], view)).toBe('2 new comments')
79+
expect(action.displayName({
80+
nodes: [file],
81+
view,
82+
folder: {} as Folder,
83+
contents: [],
84+
})).toBe('')
85+
expect(action.title!({
86+
nodes: [file],
87+
view,
88+
folder: {} as Folder,
89+
contents: [],
90+
})).toBe('2 new comments')
5691
})
5792
})
5893

@@ -67,7 +102,12 @@ describe('Inline unread comments action enabled tests', () => {
67102
attributes: { },
68103
})
69104

70-
expect(action.enabled!([file], view)).toBe(false)
105+
expect(action.enabled!({
106+
nodes: [file],
107+
view,
108+
folder: {} as Folder,
109+
contents: [],
110+
})).toBe(false)
71111
})
72112

73113
test('Action is disabled when file does not have unread comments', () => {
@@ -82,7 +122,12 @@ describe('Inline unread comments action enabled tests', () => {
82122
},
83123
})
84124

85-
expect(action.enabled!([file], view)).toBe(false)
125+
expect(action.enabled!({
126+
nodes: [file],
127+
view,
128+
folder: {} as Folder,
129+
contents: [],
130+
})).toBe(false)
86131
})
87132

88133
test('Action is enabled when file has a single unread comment', () => {
@@ -97,7 +142,12 @@ describe('Inline unread comments action enabled tests', () => {
97142
},
98143
})
99144

100-
expect(action.enabled!([file], view)).toBe(true)
145+
expect(action.enabled!({
146+
nodes: [file],
147+
view,
148+
folder: {} as Folder,
149+
contents: [],
150+
})).toBe(true)
101151
})
102152

103153
test('Action is enabled when file has a two unread comments', () => {
@@ -112,7 +162,12 @@ describe('Inline unread comments action enabled tests', () => {
112162
},
113163
})
114164

115-
expect(action.enabled!([file], view)).toBe(true)
165+
expect(action.enabled!({
166+
nodes: [file],
167+
view,
168+
folder: {} as Folder,
169+
contents: [],
170+
})).toBe(true)
116171
})
117172
})
118173

apps/comments/src/actions/inlineUnreadCommentsAction.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import logger from '../logger.js'
1313
export const action = new FileAction({
1414
id: 'comments-unread',
1515

16-
title(nodes: Node[]) {
17-
const unread = nodes[0].attributes['comments-unread'] as number
18-
if (unread >= 0) {
16+
title({ nodes }) {
17+
const unread = nodes[0]?.attributes['comments-unread'] as number | undefined
18+
if (typeof unread === 'number' && unread >= 0) {
1919
return n('comments', '1 new comment', '{unread} new comments', unread, { unread })
2020
}
2121
return t('comments', 'Comment')
@@ -27,14 +27,18 @@ export const action = new FileAction({
2727
iconSvgInline: () => CommentProcessingSvg,
2828

2929
enabled({ nodes }) {
30-
const unread = nodes[0].attributes['comments-unread'] as number | undefined
30+
const unread = nodes[0]?.attributes?.['comments-unread'] as number | undefined
3131
return typeof unread === 'number' && unread > 0
3232
},
3333

3434
async exec({ nodes }) {
35+
if (nodes.length !== 1 || !nodes[0]) {
36+
return false
37+
}
38+
3539
try {
3640
window.OCA.Files.Sidebar.setActiveTab('comments')
37-
await window.OCA.Files.Sidebar.open(node.path)
41+
await window.OCA.Files.Sidebar.open(nodes[0].path)
3842
return null
3943
} catch (error) {
4044
logger.error('Error while opening sidebar', { error })

apps/files_external/src/actions/enterCredentialsAction.spec.ts

Lines changed: 54 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,26 @@ describe('Enter credentials action conditions tests', () => {
3838

3939
expect(action).toBeInstanceOf(FileAction)
4040
expect(action.id).toBe('credentials-external-storage')
41-
expect(action.displayName([storage], externalStorageView)).toBe('Enter missing credentials')
42-
expect(action.iconSvgInline([storage], externalStorageView)).toMatch(/<svg.+<\/svg>/)
41+
expect(action.displayName({
42+
view: externalStorageView,
43+
nodes: [storage],
44+
folder: {} as Folder,
45+
contents: [],
46+
})).toBe('Enter missing credentials')
47+
expect(action.iconSvgInline({
48+
view: externalStorageView,
49+
nodes: [storage],
50+
folder: {} as Folder,
51+
contents: [],
52+
})).toMatch(/<svg.+<\/svg>/)
4353
expect(action.default).toBe(DefaultType.DEFAULT)
4454
expect(action.order).toBe(-1000)
45-
expect(action.inline!(storage, externalStorageView)).toBe(true)
55+
expect(action.inline!({
56+
view: externalStorageView,
57+
nodes: [storage],
58+
folder: {} as Folder,
59+
contents: [],
60+
})).toBe(true)
4661
})
4762
})
4863

@@ -119,31 +134,61 @@ describe('Enter credentials action enabled tests', () => {
119134

120135
test('Disabled with on success storage', () => {
121136
expect(action.enabled).toBeDefined()
122-
expect(action.enabled!([storage], externalStorageView)).toBe(false)
137+
expect(action.enabled!({
138+
nodes: [storage],
139+
view: externalStorageView,
140+
folder: {} as Folder,
141+
contents: [],
142+
})).toBe(false)
123143
})
124144

125145
test('Disabled for multiple nodes', () => {
126146
expect(action.enabled).toBeDefined()
127-
expect(action.enabled!([storage, storage], view)).toBe(false)
147+
expect(action.enabled!({
148+
nodes: [storage, storage],
149+
view,
150+
folder: {} as Folder,
151+
contents: [],
152+
})).toBe(false)
128153
})
129154

130155
test('Enabled for missing user auth storage', () => {
131156
expect(action.enabled).toBeDefined()
132-
expect(action.enabled!([userProvidedStorage], view)).toBe(true)
157+
expect(action.enabled!({
158+
nodes: [userProvidedStorage],
159+
view: externalStorageView,
160+
folder: {} as Folder,
161+
contents: [],
162+
})).toBe(true)
133163
})
134164

135165
test('Enabled for missing global user auth storage', () => {
136166
expect(action.enabled).toBeDefined()
137-
expect(action.enabled!([globalAuthUserStorage], view)).toBe(true)
167+
expect(action.enabled!({
168+
nodes: [globalAuthUserStorage],
169+
view,
170+
folder: {} as Folder,
171+
contents: [],
172+
})).toBe(true)
138173
})
139174

140175
test('Disabled for missing config', () => {
141176
expect(action.enabled).toBeDefined()
142-
expect(action.enabled!([missingConfig], view)).toBe(false)
177+
expect(action.enabled!({
178+
nodes: [missingConfig],
179+
view,
180+
folder: {} as Folder,
181+
contents: [],
182+
})).toBe(false)
143183
})
144184

145185
test('Disabled for normal nodes', () => {
146186
expect(action.enabled).toBeDefined()
147-
expect(action.enabled!([notAStorage], view)).toBe(false)
187+
expect(action.enabled!({
188+
nodes: [notAStorage],
189+
view,
190+
folder: {} as Folder,
191+
contents: [],
192+
})).toBe(false)
148193
})
149194
})

apps/files_external/src/actions/enterCredentialsAction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const action = new FileAction({
6868

6969
enabled: ({ nodes }) => {
7070
// Only works on single node
71-
if (nodes.length !== 1) {
71+
if (nodes.length !== 1 || !nodes[0]) {
7272
return false
7373
}
7474

@@ -96,7 +96,7 @@ export const action = new FileAction({
9696

9797
if (login && password) {
9898
try {
99-
await setCredentials(node, login, password)
99+
await setCredentials(nodes[0], login, password)
100100
showSuccess(t('files_external', 'Credentials successfully set'))
101101
} catch (error) {
102102
showError(t('files_external', 'Error while setting credentials: {error}', {

apps/files_sharing/src/files_actions/restoreShareAction.spec.ts

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,27 @@ describe('Restore share action conditions tests', () => {
4343

4444
expect(action).toBeInstanceOf(FileAction)
4545
expect(action.id).toBe('restore-share')
46-
expect(action.displayName([file], deletedShareView)).toBe('Restore share')
47-
expect(action.iconSvgInline([file], deletedShareView)).toMatch(/<svg.+<\/svg>/)
46+
expect(action.displayName({
47+
view: deletedShareView,
48+
nodes: [file],
49+
folder: {} as Folder,
50+
contents: [],
51+
})).toBe('Restore share')
52+
expect(action.iconSvgInline({
53+
view: deletedShareView,
54+
nodes: [file],
55+
folder: {} as Folder,
56+
contents: [],
57+
})).toMatch(/<svg.+<\/svg>/)
4858
expect(action.default).toBeUndefined()
4959
expect(action.order).toBe(1)
5060
expect(action.inline).toBeDefined()
51-
expect(action.inline!(file, deletedShareView)).toBe(true)
61+
expect(action.inline!({
62+
view: deletedShareView,
63+
nodes: [file],
64+
folder: {} as Folder,
65+
contents: [],
66+
})).toBe(true)
5267
})
5368

5469
test('Default values for multiple files', () => {
@@ -67,7 +82,12 @@ describe('Restore share action conditions tests', () => {
6782
permissions: Permission.ALL,
6883
})
6984

70-
expect(action.displayName([file1, file2], deletedShareView)).toBe('Restore shares')
85+
expect(action.displayName({
86+
view: deletedShareView,
87+
nodes: [file1, file2],
88+
folder: {} as Folder,
89+
contents: [],
90+
})).toBe('Restore shares')
7191
})
7292
})
7393

@@ -82,17 +102,32 @@ describe('Restore share action enabled tests', () => {
82102
})
83103

84104
expect(action.enabled).toBeDefined()
85-
expect(action.enabled!([file], deletedShareView)).toBe(true)
105+
expect(action.enabled!({
106+
nodes: [file],
107+
view: deletedShareView,
108+
folder: {} as Folder,
109+
contents: [],
110+
})).toBe(true)
86111
})
87112

88113
test('Disabled on wrong view', () => {
89114
expect(action.enabled).toBeDefined()
90-
expect(action.enabled!([], view)).toBe(false)
115+
expect(action.enabled!({
116+
nodes: [],
117+
view,
118+
folder: {} as Folder,
119+
contents: [],
120+
})).toBe(false)
91121
})
92122

93123
test('Disabled without nodes', () => {
94124
expect(action.enabled).toBeDefined()
95-
expect(action.enabled!([], deletedShareView)).toBe(false)
125+
expect(action.enabled!({
126+
nodes: [],
127+
view: deletedShareView,
128+
folder: {} as Folder,
129+
contents: [],
130+
})).toBe(false)
96131
})
97132
})
98133

apps/files_sharing/src/files_actions/restoreShareAction.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
5-
import type { Node, View } from '@nextcloud/files'
6-
75
import ArrowULeftTopSvg from '@mdi/svg/svg/arrow-u-left-top.svg?raw'
86
import axios from '@nextcloud/axios'
97
import { emit } from '@nextcloud/event-bus'
@@ -37,7 +35,7 @@ export const action = new FileAction({
3735
}
3836
},
3937
async execBatch({ nodes, view, folder, contents }) {
40-
return Promise.all(nodes.map((node) => this.exec({nodes: [node], view, folder, contents })))
38+
return Promise.all(nodes.map((node) => this.exec({ nodes: [node], view, folder, contents })))
4139
},
4240

4341
order: 1,

0 commit comments

Comments
 (0)