Skip to content

Commit

Permalink
Merge pull request #46921 from nextcloud/fix/system-tags-displayname
Browse files Browse the repository at this point in the history
fix(systemtags): Correctly set the display name for the Nextcloud node
  • Loading branch information
skjnldsv committed Jul 31, 2024
2 parents a5770a5 + 835d357 commit bfde053
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
27 changes: 14 additions & 13 deletions apps/systemtags/src/services/systemtags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import type { ContentsWithRoot } from '@nextcloud/files'
import type { FileStat, ResponseDataDetailed } from 'webdav'
import type { TagWithId } from '../types'

import { Folder, Permission, getDavNameSpaces, getDavProperties, davGetClient, davResultToNode } from '@nextcloud/files'
import { generateRemoteUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'

import { Folder, Permission, getDavNameSpaces, getDavProperties, davGetClient, davResultToNode, davRemoteURL, davRootPath } from '@nextcloud/files'
import { fetchTags } from './api'

const rootPath = '/systemtags'

const client = davGetClient()
const resultToNode = (node: FileStat) => davResultToNode(node)

Expand All @@ -20,17 +20,18 @@ const formatReportPayload = (tagId: number) => `<?xml version="1.0"?>
<d:prop>
${getDavProperties()}
</d:prop>
<oc:filter-rules>
<oc:systemtag>${tagId}</oc:systemtag>
</oc:filter-rules>
<oc:filter-rules>
<oc:systemtag>${tagId}</oc:systemtag>
</oc:filter-rules>
</oc:filter-files>`

const tagToNode = function(tag: TagWithId): Folder {
return new Folder({
id: tag.id,
source: generateRemoteUrl('dav/systemtags/' + tag.id),
owner: getCurrentUser()?.uid as string,
root: '/systemtags',
source: `${davRemoteURL}${rootPath}/${tag.id}`,
owner: String(getCurrentUser()?.uid ?? 'anonymous'),
root: rootPath,
displayname: tag.displayName,
permissions: Permission.READ,
attributes: {
...tag,
Expand All @@ -47,24 +48,24 @@ export const getContents = async (path = '/'): Promise<ContentsWithRoot> => {
return {
folder: new Folder({
id: 0,
source: generateRemoteUrl('dav/systemtags'),
source: `${davRemoteURL}${rootPath}`,
owner: getCurrentUser()?.uid as string,
root: '/systemtags',
root: rootPath,
permissions: Permission.NONE,
}),
contents: tagsCache.map(tagToNode),
}
}

const tagId = parseInt(path.replace('/', ''), 10)
const tagId = parseInt(path.split('/', 2)[0])
const tag = tagsCache.find(tag => tag.id === tagId)

if (!tag) {
throw new Error('Tag not found')
}

const folder = tagToNode(tag)
const contentsResponse = await client.getDirectoryContents('/', {
const contentsResponse = await client.getDirectoryContents(davRootPath, {
details: true,
// Only filter favorites if we're at the root
data: formatReportPayload(tagId),
Expand Down
4 changes: 2 additions & 2 deletions dist/systemtags-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/systemtags-init.js.map

Large diffs are not rendered by default.

0 comments on commit bfde053

Please sign in to comment.