mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 08:16:43 -04:00
fix(systemtags): Correctly set the display name for the Nextcloud node
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
This commit is contained in:
parent
51aa19989c
commit
0535a95efb
4 changed files with 21 additions and 40 deletions
|
|
@ -19,33 +19,36 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
import type { ContentsWithRoot } from '@nextcloud/files'
|
||||
import type { FileStat, ResponseDataDetailed } from 'webdav'
|
||||
import type { TagWithId } from '../types'
|
||||
|
||||
import { Folder, type ContentsWithRoot, Permission, getDavNameSpaces, getDavProperties } 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'
|
||||
import { getClient } from '../../../files/src/services/WebdavClient'
|
||||
import { resultToNode } from '../../../files/src/services/Files'
|
||||
|
||||
const rootPath = '/systemtags'
|
||||
|
||||
const client = davGetClient()
|
||||
const resultToNode = (node: FileStat) => davResultToNode(node)
|
||||
|
||||
const formatReportPayload = (tagId: number) => `<?xml version="1.0"?>
|
||||
<oc:filter-files ${getDavNameSpaces()}>
|
||||
<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,
|
||||
|
|
@ -62,16 +65,16 @@ 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) {
|
||||
|
|
@ -79,7 +82,7 @@ export const getContents = async (path = '/'): Promise<ContentsWithRoot> => {
|
|||
}
|
||||
|
||||
const folder = tagToNode(tag)
|
||||
const contentsResponse = await getClient().getDirectoryContents('/', {
|
||||
const contentsResponse = await client.getDirectoryContents(davRootPath, {
|
||||
details: true,
|
||||
// Only filter favorites if we're at the root
|
||||
data: formatReportPayload(tagId),
|
||||
|
|
|
|||
4
dist/systemtags-init.js
vendored
4
dist/systemtags-init.js
vendored
File diff suppressed because one or more lines are too long
22
dist/systemtags-init.js.LICENSE.txt
vendored
22
dist/systemtags-init.js.LICENSE.txt
vendored
|
|
@ -19,25 +19,3 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
|
||||
*
|
||||
* @author John Molakvoæ <skjnldsv@protonmail.com>
|
||||
*
|
||||
* @license AGPL-3.0-or-later
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
|
|
|||
2
dist/systemtags-init.js.map
vendored
2
dist/systemtags-init.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue