Skip to content

Commit 0717412

Browse files
Merge pull request #50970 from nextcloud/dependabot/npm_and_yarn/webdav-5.8.0
2 parents bf387e5 + d37411d commit 0717412

24 files changed

Lines changed: 181 additions & 78 deletions

apps/systemtags/src/files_actions/bulkSystemTagsAction.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ import { loadState } from '@nextcloud/initial-state'
1414

1515
import TagMultipleSvg from '@mdi/svg/svg/tag-multiple.svg?raw'
1616

17+
const restrictSystemTagsCreationToAdmin = loadState<'0'|'1'>('settings', 'restrictSystemTagsCreationToAdmin', '0') === '1'
18+
1719
/**
18-
*
19-
* @param nodes
20+
* Spawn a dialog to add or remove tags from multiple nodes.
21+
* @param nodes Nodes to modify tags for
2022
*/
2123
async function execBatch(nodes: Node[]): Promise<(null|boolean)[]> {
2224
const response = await new Promise<null|boolean>((resolve) => {
@@ -37,7 +39,7 @@ export const action = new FileAction({
3739
// If the app is disabled, the action is not available anyway
3840
enabled(nodes) {
3941
// By default, everyone can create system tags
40-
if (loadState('settings', 'restrictSystemTagsCreationToAdmin', '0') === '1' && getCurrentUser()?.isAdmin !== true) {
42+
if (restrictSystemTagsCreationToAdmin && getCurrentUser()?.isAdmin !== true) {
4143
return false
4244
}
4345

@@ -50,7 +52,7 @@ export const action = new FileAction({
5052
}
5153

5254
// Disabled for non dav resources
53-
if (nodes.some((node) => !node.isDavRessource)) {
55+
if (nodes.some((node) => !node.isDavResource)) {
5456
return false
5557
}
5658

apps/systemtags/src/utils.spec.ts

Lines changed: 91 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55

66
import type { DAVResultResponseProps } from 'webdav'
77
import type { ServerTag, Tag } from './types.js'
8-
import { describe, expect, it } from 'vitest'
98

10-
import { formatTag, parseIdFromLocation, parseTags } from './utils'
9+
import { describe, expect, it } from 'vitest'
10+
import { formatTag, getNodeSystemTags, parseIdFromLocation, parseTags } from './utils'
11+
import { Folder } from '@nextcloud/files'
1112

1213
describe('systemtags - utils', () => {
1314
describe('parseTags', () => {
@@ -85,4 +86,92 @@ describe('systemtags - utils', () => {
8586
})
8687
})
8788
})
89+
90+
describe('getNodeSystemTags', () => {
91+
it('parses a plain tag', () => {
92+
const node = new Folder({
93+
owner: 'test',
94+
source: 'https://example.com/remote.php/dav/files/test/folder',
95+
attributes: {
96+
'system-tags': {
97+
'system-tag': 'tag',
98+
},
99+
},
100+
})
101+
expect(getNodeSystemTags(node)).toStrictEqual(['tag'])
102+
})
103+
104+
it('parses plain tags', () => {
105+
const node = new Folder({
106+
owner: 'test',
107+
source: 'https://example.com/remote.php/dav/files/test/folder',
108+
attributes: {
109+
'system-tags': {
110+
'system-tag': [
111+
'tag',
112+
'my-tag',
113+
],
114+
},
115+
},
116+
})
117+
expect(getNodeSystemTags(node)).toStrictEqual(['tag', 'my-tag'])
118+
})
119+
120+
it('parses tag with attributes', () => {
121+
const node = new Folder({
122+
owner: 'test',
123+
source: 'https://example.com/remote.php/dav/files/test/folder',
124+
attributes: {
125+
'system-tags': {
126+
'system-tag': {
127+
text: 'tag',
128+
'@can-assign': true,
129+
},
130+
},
131+
},
132+
})
133+
expect(getNodeSystemTags(node)).toStrictEqual(['tag'])
134+
})
135+
136+
it('parses tags with attributes', () => {
137+
const node = new Folder({
138+
owner: 'test',
139+
source: 'https://example.com/remote.php/dav/files/test/folder',
140+
attributes: {
141+
'system-tags': {
142+
'system-tag': [
143+
{
144+
text: 'tag',
145+
'@can-assign': true,
146+
},
147+
{
148+
text: 'my-tag',
149+
'@can-assign': false,
150+
},
151+
],
152+
},
153+
},
154+
})
155+
expect(getNodeSystemTags(node)).toStrictEqual(['tag', 'my-tag'])
156+
})
157+
158+
it('parses tags mixed with and without attributes', () => {
159+
const node = new Folder({
160+
owner: 'test',
161+
source: 'https://example.com/remote.php/dav/files/test/folder',
162+
attributes: {
163+
'system-tags': {
164+
'system-tag': [
165+
'tag',
166+
{
167+
text: 'my-tag',
168+
'@can-assign': false,
169+
},
170+
],
171+
},
172+
},
173+
})
174+
expect(getNodeSystemTags(node)).toStrictEqual(['tag', 'my-tag'])
175+
})
176+
})
88177
})

apps/systemtags/src/utils.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,22 @@ export const formatTag = (initialTag: Tag | ServerTag): ServerTag => {
5959
}
6060

6161
export const getNodeSystemTags = function(node: Node): string[] {
62-
const tags = node.attributes?.['system-tags']?.['system-tag'] as string|string[]|undefined
63-
64-
if (tags === undefined) {
62+
const attribute = node.attributes?.['system-tags']?.['system-tag']
63+
if (attribute === undefined) {
6564
return []
6665
}
6766

68-
return [tags].flat()
67+
// if there is only one tag it is a single string or prop object
68+
// if there are multiple then its an array - so we flatten it to be always an array of string or prop objects
69+
return [attribute]
70+
.flat()
71+
.map((tag: string|{ text: string }) => (
72+
typeof tag === 'string'
73+
// its a plain text prop (the tag name) without prop attributes
74+
? tag
75+
// its a prop object with attributes, the tag name is in the 'text' attribute
76+
: tag.text
77+
))
6978
}
7079

7180
export const setNodeSystemTags = function(node: Node, tags: string[]): void {

dist/3655-3655.js.license

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ This file is generated from multiple sources. Included packages:
161161
- version: 3.3.0
162162
- license: MIT
163163
- fast-xml-parser
164-
- version: 4.4.1
164+
- version: 4.5.3
165165
- license: MIT
166166
- floating-vue
167167
- version: 1.0.0-beta.19
@@ -296,7 +296,7 @@ This file is generated from multiple sources. Included packages:
296296
- version: 1.3.0
297297
- license: MIT
298298
- strnum
299-
- version: 1.0.5
299+
- version: 1.1.2
300300
- license: MIT
301301
- style-loader
302302
- version: 4.0.0
@@ -335,7 +335,7 @@ This file is generated from multiple sources. Included packages:
335335
- version: 2.7.16
336336
- license: MIT
337337
- webdav
338-
- version: 5.7.1
338+
- version: 5.8.0
339339
- license: MIT
340340
- which-typed-array
341341
- version: 1.1.15

dist/3920-3920.js.license

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ This file is generated from multiple sources. Included packages:
165165
- version: 3.3.0
166166
- license: MIT
167167
- fast-xml-parser
168-
- version: 4.4.1
168+
- version: 4.5.3
169169
- license: MIT
170170
- floating-vue
171171
- version: 1.0.0-beta.19
@@ -306,7 +306,7 @@ This file is generated from multiple sources. Included packages:
306306
- version: 3.2.0
307307
- license: MIT
308308
- strnum
309-
- version: 1.0.5
309+
- version: 1.1.2
310310
- license: MIT
311311
- style-loader
312312
- version: 4.0.0
@@ -354,7 +354,7 @@ This file is generated from multiple sources. Included packages:
354354
- version: 2.7.16
355355
- license: MIT
356356
- webdav
357-
- version: 5.7.1
357+
- version: 5.8.0
358358
- license: MIT
359359
- which-typed-array
360360
- version: 1.1.15

dist/7462-7462.js.license

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ This file is generated from multiple sources. Included packages:
165165
- version: 3.3.0
166166
- license: MIT
167167
- fast-xml-parser
168-
- version: 4.4.1
168+
- version: 4.5.3
169169
- license: MIT
170170
- floating-vue
171171
- version: 1.0.0-beta.19
@@ -306,7 +306,7 @@ This file is generated from multiple sources. Included packages:
306306
- version: 3.2.0
307307
- license: MIT
308308
- strnum
309-
- version: 1.0.5
309+
- version: 1.1.2
310310
- license: MIT
311311
- style-loader
312312
- version: 4.0.0
@@ -354,7 +354,7 @@ This file is generated from multiple sources. Included packages:
354354
- version: 2.7.16
355355
- license: MIT
356356
- webdav
357-
- version: 5.7.1
357+
- version: 5.8.0
358358
- license: MIT
359359
- which-typed-array
360360
- version: 1.1.15

dist/8057-8057.js.license

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ This file is generated from multiple sources. Included packages:
165165
- version: 3.3.0
166166
- license: MIT
167167
- fast-xml-parser
168-
- version: 4.4.1
168+
- version: 4.5.3
169169
- license: MIT
170170
- floating-vue
171171
- version: 1.0.0-beta.19
@@ -306,7 +306,7 @@ This file is generated from multiple sources. Included packages:
306306
- version: 3.2.0
307307
- license: MIT
308308
- strnum
309-
- version: 1.0.5
309+
- version: 1.1.2
310310
- license: MIT
311311
- style-loader
312312
- version: 4.0.0
@@ -354,7 +354,7 @@ This file is generated from multiple sources. Included packages:
354354
- version: 2.7.16
355355
- license: MIT
356356
- webdav
357-
- version: 5.7.1
357+
- version: 5.8.0
358358
- license: MIT
359359
- which-typed-array
360360
- version: 1.1.15

dist/comments-comments-app.js.license

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ This file is generated from multiple sources. Included packages:
165165
- version: 3.3.0
166166
- license: MIT
167167
- fast-xml-parser
168-
- version: 4.4.1
168+
- version: 4.5.3
169169
- license: MIT
170170
- floating-vue
171171
- version: 1.0.0-beta.19
@@ -306,7 +306,7 @@ This file is generated from multiple sources. Included packages:
306306
- version: 3.2.0
307307
- license: MIT
308308
- strnum
309-
- version: 1.0.5
309+
- version: 1.1.2
310310
- license: MIT
311311
- style-loader
312312
- version: 4.0.0
@@ -354,7 +354,7 @@ This file is generated from multiple sources. Included packages:
354354
- version: 2.7.16
355355
- license: MIT
356356
- webdav
357-
- version: 5.7.1
357+
- version: 5.8.0
358358
- license: MIT
359359
- webpack
360360
- version: 5.94.0

dist/comments-comments-tab.js.license

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ This file is generated from multiple sources. Included packages:
135135
- version: 3.3.0
136136
- license: MIT
137137
- fast-xml-parser
138-
- version: 4.4.1
138+
- version: 4.5.3
139139
- license: MIT
140140
- for-each
141141
- version: 0.3.3
@@ -267,7 +267,7 @@ This file is generated from multiple sources. Included packages:
267267
- version: 1.3.0
268268
- license: MIT
269269
- strnum
270-
- version: 1.0.5
270+
- version: 1.1.2
271271
- license: MIT
272272
- url-join
273273
- version: 5.0.0
@@ -288,7 +288,7 @@ This file is generated from multiple sources. Included packages:
288288
- version: 2.7.16
289289
- license: MIT
290290
- webdav
291-
- version: 5.7.1
291+
- version: 5.8.0
292292
- license: MIT
293293
- webpack
294294
- version: 5.94.0

dist/core-common.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)