mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
fix(files): use displayName in breadcrumbs if available
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
This commit is contained in:
parent
45f39d65fe
commit
0b0dbb99d3
5 changed files with 39 additions and 7 deletions
|
|
@ -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')
|
||||
|
|
|
|||
4
dist/core-common.js
vendored
4
dist/core-common.js
vendored
File diff suppressed because one or more lines are too long
2
dist/core-common.js.map
vendored
2
dist/core-common.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/files-main.js
vendored
4
dist/files-main.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files-main.js.map
vendored
2
dist/files-main.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue