Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions apps/systemtags/src/files_actions/inlineSystemTagsAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,10 @@
import type { Node } from '@nextcloud/files'
import { FileAction } from '@nextcloud/files'
import { translate as t } from '@nextcloud/l10n'
import { getNodeSystemTags } from '../utils.ts'

import '../css/fileEntryInlineSystemTags.scss'

const getNodeSystemTags = function(node: Node): string[] {
const tags = node.attributes?.['system-tags']?.['system-tag'] as string|string[]|undefined

if (tags === undefined) {
return []
}

return [tags].flat()
}

const renderTag = function(tag: string, isMore = false): HTMLElement {
const tagElement = document.createElement('li')
tagElement.classList.add('files-list__system-tag')
Expand Down
93 changes: 91 additions & 2 deletions apps/systemtags/src/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
import type { DAVResultResponseProps } from 'webdav'
import type { ServerTag, Tag } from './types.js'

import { describe, it, expect } from '@jest/globals'
import { formatTag, parseIdFromLocation, parseTags } from './utils'
import { describe, expect, it } from '@jest/globals'
import { Folder } from '@nextcloud/files'
import { formatTag, getNodeSystemTags, parseIdFromLocation, parseTags } from './utils'

describe('systemtags - utils', () => {
describe('parseTags', () => {
Expand Down Expand Up @@ -85,4 +86,92 @@ describe('systemtags - utils', () => {
})
})
})

describe('getNodeSystemTags', () => {
it('parses a plain tag', () => {
const node = new Folder({
owner: 'test',
source: 'https://example.com/remote.php/dav/files/test/folder',
attributes: {
'system-tags': {
'system-tag': 'tag',
},
},
})
expect(getNodeSystemTags(node)).toStrictEqual(['tag'])
})

it('parses plain tags', () => {
const node = new Folder({
owner: 'test',
source: 'https://example.com/remote.php/dav/files/test/folder',
attributes: {
'system-tags': {
'system-tag': [
'tag',
'my-tag',
],
},
},
})
expect(getNodeSystemTags(node)).toStrictEqual(['tag', 'my-tag'])
})

it('parses tag with attributes', () => {
const node = new Folder({
owner: 'test',
source: 'https://example.com/remote.php/dav/files/test/folder',
attributes: {
'system-tags': {
'system-tag': {
text: 'tag',
'@can-assign': true,
},
},
},
})
expect(getNodeSystemTags(node)).toStrictEqual(['tag'])
})

it('parses tags with attributes', () => {
const node = new Folder({
owner: 'test',
source: 'https://example.com/remote.php/dav/files/test/folder',
attributes: {
'system-tags': {
'system-tag': [
{
text: 'tag',
'@can-assign': true,
},
{
text: 'my-tag',
'@can-assign': false,
},
],
},
},
})
expect(getNodeSystemTags(node)).toStrictEqual(['tag', 'my-tag'])
})

it('parses tags mixed with and without attributes', () => {
const node = new Folder({
owner: 'test',
source: 'https://example.com/remote.php/dav/files/test/folder',
attributes: {
'system-tags': {
'system-tag': [
'tag',
{
text: 'my-tag',
'@can-assign': false,
},
],
},
},
})
expect(getNodeSystemTags(node)).toStrictEqual(['tag', 'my-tag'])
})
})
})
21 changes: 20 additions & 1 deletion apps/systemtags/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import camelCase from 'camelcase'

import type { Node } from '@nextcloud/files'
import type { DAVResultResponseProps } from 'webdav'

import type { BaseTag, ServerTag, Tag, TagWithId } from './types.js'

export const defaultBaseTag: BaseTag = {
Expand Down Expand Up @@ -55,3 +55,22 @@ export const formatTag = (initialTag: Tag | ServerTag): ServerTag => {

return tag as unknown as ServerTag
}

export const getNodeSystemTags = function(node: Node): string[] {
const attribute = node.attributes?.['system-tags']?.['system-tag']
if (attribute === undefined) {
return []
}

// if there is only one tag it is a single string or prop object
// if there are multiple then its an array - so we flatten it to be always an array of string or prop objects
return [attribute]
.flat()
.map((tag: string|{ text: string }) => (
typeof tag === 'string'
// its a plain text prop (the tag name) without prop attributes
? tag
// its a prop object with attributes, the tag name is in the 'text' attribute
: tag.text
))
}
6 changes: 3 additions & 3 deletions dist/3920-3920.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.3.0
- license: MIT
- fast-xml-parser
- version: 4.4.1
- version: 4.5.3
- license: MIT
- floating-vue
- version: 1.0.0-beta.19
Expand Down Expand Up @@ -325,7 +325,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.2.0
- license: MIT
- strnum
- version: 1.0.5
- version: 1.1.2
- license: MIT
- style-loader
- version: 3.3.4
Expand Down Expand Up @@ -376,7 +376,7 @@ This file is generated from multiple sources. Included packages:
- version: 2.7.16
- license: MIT
- webdav
- version: 5.7.1
- version: 5.8.0
- license: MIT
- which-typed-array
- version: 1.1.15
Expand Down
6 changes: 3 additions & 3 deletions dist/7462-7462.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.3.0
- license: MIT
- fast-xml-parser
- version: 4.4.1
- version: 4.5.3
- license: MIT
- floating-vue
- version: 1.0.0-beta.19
Expand Down Expand Up @@ -325,7 +325,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.2.0
- license: MIT
- strnum
- version: 1.0.5
- version: 1.1.2
- license: MIT
- style-loader
- version: 3.3.4
Expand Down Expand Up @@ -376,7 +376,7 @@ This file is generated from multiple sources. Included packages:
- version: 2.7.16
- license: MIT
- webdav
- version: 5.7.1
- version: 5.8.0
- license: MIT
- which-typed-array
- version: 1.1.15
Expand Down
6 changes: 3 additions & 3 deletions dist/8057-8057.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.3.0
- license: MIT
- fast-xml-parser
- version: 4.4.1
- version: 4.5.3
- license: MIT
- floating-vue
- version: 1.0.0-beta.19
Expand Down Expand Up @@ -325,7 +325,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.2.0
- license: MIT
- strnum
- version: 1.0.5
- version: 1.1.2
- license: MIT
- style-loader
- version: 3.3.4
Expand Down Expand Up @@ -376,7 +376,7 @@ This file is generated from multiple sources. Included packages:
- version: 2.7.16
- license: MIT
- webdav
- version: 5.7.1
- version: 5.8.0
- license: MIT
- which-typed-array
- version: 1.1.15
Expand Down
6 changes: 3 additions & 3 deletions dist/comments-comments-app.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.3.0
- license: MIT
- fast-xml-parser
- version: 4.4.1
- version: 4.5.3
- license: MIT
- floating-vue
- version: 1.0.0-beta.19
Expand Down Expand Up @@ -325,7 +325,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.2.0
- license: MIT
- strnum
- version: 1.0.5
- version: 1.1.2
- license: MIT
- style-loader
- version: 3.3.4
Expand Down Expand Up @@ -376,7 +376,7 @@ This file is generated from multiple sources. Included packages:
- version: 2.7.16
- license: MIT
- webdav
- version: 5.7.1
- version: 5.8.0
- license: MIT
- webpack
- version: 5.94.0
Expand Down
6 changes: 3 additions & 3 deletions dist/comments-comments-tab.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.3.0
- license: MIT
- fast-xml-parser
- version: 4.4.1
- version: 4.5.3
- license: MIT
- for-each
- version: 0.3.3
Expand Down Expand Up @@ -286,7 +286,7 @@ This file is generated from multiple sources. Included packages:
- version: 1.3.0
- license: MIT
- strnum
- version: 1.0.5
- version: 1.1.2
- license: MIT
- url-join
- version: 5.0.0
Expand All @@ -310,7 +310,7 @@ This file is generated from multiple sources. Included packages:
- version: 2.7.16
- license: MIT
- webdav
- version: 5.7.1
- version: 5.8.0
- license: MIT
- webpack
- version: 5.94.0
Expand Down
4 changes: 2 additions & 2 deletions dist/core-common.js

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions dist/core-common.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,6 @@ This file is generated from multiple sources. Included packages:
- call-bind
- version: 1.0.7
- license: MIT
- camelcase
- version: 8.0.0
- license: MIT
- cancelable-promise
- version: 4.3.1
- license: MIT
Expand Down Expand Up @@ -301,7 +298,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.0.2
- license: MIT
- fast-xml-parser
- version: 4.4.1
- version: 4.5.3
- license: MIT
- floating-vue
- version: 1.0.0-beta.19
Expand Down Expand Up @@ -652,7 +649,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.2.0
- license: MIT
- strnum
- version: 1.0.5
- version: 1.1.2
- license: MIT
- style-loader
- version: 3.3.4
Expand Down Expand Up @@ -748,7 +745,7 @@ This file is generated from multiple sources. Included packages:
- version: 2.0.1
- license: MIT
- webdav
- version: 5.7.1
- version: 5.8.0
- license: MIT
- which-typed-array
- version: 1.1.15
Expand Down
2 changes: 1 addition & 1 deletion dist/core-common.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/dav-settings-personal-availability.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.3.0
- license: MIT
- fast-xml-parser
- version: 4.4.1
- version: 4.5.3
- license: MIT
- floating-vue
- version: 1.0.0-beta.19
Expand Down Expand Up @@ -355,7 +355,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.2.0
- license: MIT
- strnum
- version: 1.0.5
- version: 1.1.2
- license: MIT
- style-loader
- version: 3.3.4
Expand Down Expand Up @@ -406,7 +406,7 @@ This file is generated from multiple sources. Included packages:
- version: 2.7.16
- license: MIT
- webdav
- version: 5.7.1
- version: 5.8.0
- license: MIT
- webpack
- version: 5.94.0
Expand Down
4 changes: 2 additions & 2 deletions dist/files-sidebar.js

Large diffs are not rendered by default.

9 changes: 3 additions & 6 deletions dist/files-sidebar.js.license
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ This file is generated from multiple sources. Included packages:
- call-bind
- version: 1.0.7
- license: MIT
- camelcase
- version: 8.0.0
- license: MIT
- cancelable-promise
- version: 4.3.1
- license: MIT
Expand Down Expand Up @@ -212,7 +209,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.3.0
- license: MIT
- fast-xml-parser
- version: 4.4.1
- version: 4.5.3
- license: MIT
- floating-vue
- version: 1.0.0-beta.19
Expand Down Expand Up @@ -362,7 +359,7 @@ This file is generated from multiple sources. Included packages:
- version: 3.2.0
- license: MIT
- strnum
- version: 1.0.5
- version: 1.1.2
- license: MIT
- style-loader
- version: 3.3.4
Expand Down Expand Up @@ -413,7 +410,7 @@ This file is generated from multiple sources. Included packages:
- version: 2.7.16
- license: MIT
- webdav
- version: 5.7.1
- version: 5.8.0
- license: MIT
- webpack
- version: 5.94.0
Expand Down
2 changes: 1 addition & 1 deletion dist/files-sidebar.js.map

Large diffs are not rendered by default.

Loading
Loading