Skip to content

Commit bfde053

Browse files
authored
Merge pull request #46921 from nextcloud/fix/system-tags-displayname
fix(systemtags): Correctly set the display name for the Nextcloud node
2 parents a5770a5 + 835d357 commit bfde053

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

apps/systemtags/src/services/systemtags.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import type { ContentsWithRoot } from '@nextcloud/files'
66
import type { FileStat, ResponseDataDetailed } from 'webdav'
77
import type { TagWithId } from '../types'
88

9-
import { Folder, Permission, getDavNameSpaces, getDavProperties, davGetClient, davResultToNode } from '@nextcloud/files'
10-
import { generateRemoteUrl } from '@nextcloud/router'
119
import { getCurrentUser } from '@nextcloud/auth'
12-
10+
import { Folder, Permission, getDavNameSpaces, getDavProperties, davGetClient, davResultToNode, davRemoteURL, davRootPath } from '@nextcloud/files'
1311
import { fetchTags } from './api'
1412

13+
const rootPath = '/systemtags'
14+
1515
const client = davGetClient()
1616
const resultToNode = (node: FileStat) => davResultToNode(node)
1717

@@ -20,17 +20,18 @@ const formatReportPayload = (tagId: number) => `<?xml version="1.0"?>
2020
<d:prop>
2121
${getDavProperties()}
2222
</d:prop>
23-
<oc:filter-rules>
24-
<oc:systemtag>${tagId}</oc:systemtag>
25-
</oc:filter-rules>
23+
<oc:filter-rules>
24+
<oc:systemtag>${tagId}</oc:systemtag>
25+
</oc:filter-rules>
2626
</oc:filter-files>`
2727

2828
const tagToNode = function(tag: TagWithId): Folder {
2929
return new Folder({
3030
id: tag.id,
31-
source: generateRemoteUrl('dav/systemtags/' + tag.id),
32-
owner: getCurrentUser()?.uid as string,
33-
root: '/systemtags',
31+
source: `${davRemoteURL}${rootPath}/${tag.id}`,
32+
owner: String(getCurrentUser()?.uid ?? 'anonymous'),
33+
root: rootPath,
34+
displayname: tag.displayName,
3435
permissions: Permission.READ,
3536
attributes: {
3637
...tag,
@@ -47,24 +48,24 @@ export const getContents = async (path = '/'): Promise<ContentsWithRoot> => {
4748
return {
4849
folder: new Folder({
4950
id: 0,
50-
source: generateRemoteUrl('dav/systemtags'),
51+
source: `${davRemoteURL}${rootPath}`,
5152
owner: getCurrentUser()?.uid as string,
52-
root: '/systemtags',
53+
root: rootPath,
5354
permissions: Permission.NONE,
5455
}),
5556
contents: tagsCache.map(tagToNode),
5657
}
5758
}
5859

59-
const tagId = parseInt(path.replace('/', ''), 10)
60+
const tagId = parseInt(path.split('/', 2)[0])
6061
const tag = tagsCache.find(tag => tag.id === tagId)
6162

6263
if (!tag) {
6364
throw new Error('Tag not found')
6465
}
6566

6667
const folder = tagToNode(tag)
67-
const contentsResponse = await client.getDirectoryContents('/', {
68+
const contentsResponse = await client.getDirectoryContents(davRootPath, {
6869
details: true,
6970
// Only filter favorites if we're at the root
7071
data: formatReportPayload(tagId),

dist/systemtags-init.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.

dist/systemtags-init.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)