diff options
author | John Molakvoæ <skjnldsv@protonmail.com> | 2023-04-07 14:39:16 +0200 |
---|---|---|
committer | John Molakvoæ <skjnldsv@protonmail.com> | 2023-04-11 12:00:03 +0200 |
commit | 0b0dbb99d30fc8bfb0cb34e194f8b7412fbab5ca (patch) | |
tree | 4239c728272dbd2dd0fcdbf6fab84ca810e62c40 /apps/files/src | |
parent | 45f39d65fea0c00ea3b01f0593422d97e791ff16 (diff) | |
download | nextcloud-server-0b0dbb99d30fc8bfb0cb34e194f8b7412fbab5ca.tar.gz nextcloud-server-0b0dbb99d30fc8bfb0cb34e194f8b7412fbab5ca.zip |
fix(files): use displayName in breadcrumbs if available
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files/src')
-rw-r--r-- | apps/files/src/components/BreadCrumbs.vue | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/apps/files/src/components/BreadCrumbs.vue b/apps/files/src/components/BreadCrumbs.vue index d2f8610e9ca..c2938c5aca2 100644 --- a/apps/files/src/components/BreadCrumbs.vue +++ b/apps/files/src/components/BreadCrumbs.vue @@ -21,6 +21,9 @@ import NcBreadcrumb from '@nextcloud/vue/dist/Components/NcBreadcrumb.js' import NcBreadcrumbs from '@nextcloud/vue/dist/Components/NcBreadcrumbs.js' import Vue from 'vue' +import { useFilesStore } from '../store/files.ts' +import { usePathsStore } from '../store/paths.ts' + export default Vue.extend({ name: 'BreadCrumbs', @@ -37,7 +40,20 @@ export default Vue.extend({ }, }, + setup() { + const filesStore = useFilesStore() + const pathsStore = usePathsStore() + return { + filesStore, + pathsStore, + } + }, + computed: { + currentView() { + return this.$navigation.active + }, + dirs() { const cumulativePath = (acc) => (value) => (acc += `${value}/`) // Generate a cumulative path for each path segment: ['/', '/foo', '/foo/bar', ...] etc @@ -52,7 +68,7 @@ export default Vue.extend({ return { dir, exact: true, - name: basename(dir), + name: this.getDirDisplayName(dir), to, } }) @@ -60,6 +76,22 @@ export default Vue.extend({ }, methods: { + getNodeFromId(id) { + return this.filesStore.getNode(id) + }, + getFileIdFromPath(path) { + return this.pathsStore.getPath(this.currentView?.id, path) + }, + getDirDisplayName(path) { + if (path === '/') { + return t('files', 'Home') + } + + const fileId = this.getFileIdFromPath(path) + const node = this.getNodeFromId(fileId) + return node?.attributes?.displayName || basename(path) + }, + onClick(to) { if (to?.query?.dir === this.$route.query.dir) { this.$emit('reload') |