Skip to content

Commit 0b0dbb9

Browse files
committed
fix(files): use displayName in breadcrumbs if available
Signed-off-by: John Molakvoæ <[email protected]>
1 parent 45f39d6 commit 0b0dbb9

File tree

5 files changed

+39
-7
lines changed

5 files changed

+39
-7
lines changed

apps/files/src/components/BreadCrumbs.vue

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import NcBreadcrumb from '@nextcloud/vue/dist/Components/NcBreadcrumb.js'
2121
import NcBreadcrumbs from '@nextcloud/vue/dist/Components/NcBreadcrumbs.js'
2222
import Vue from 'vue'
2323
24+
import { useFilesStore } from '../store/files.ts'
25+
import { usePathsStore } from '../store/paths.ts'
26+
2427
export default Vue.extend({
2528
name: 'BreadCrumbs',
2629
@@ -37,7 +40,20 @@ export default Vue.extend({
3740
},
3841
},
3942
43+
setup() {
44+
const filesStore = useFilesStore()
45+
const pathsStore = usePathsStore()
46+
return {
47+
filesStore,
48+
pathsStore,
49+
}
50+
},
51+
4052
computed: {
53+
currentView() {
54+
return this.$navigation.active
55+
},
56+
4157
dirs() {
4258
const cumulativePath = (acc) => (value) => (acc += `${value}/`)
4359
// Generate a cumulative path for each path segment: ['/', '/foo', '/foo/bar', ...] etc
@@ -52,14 +68,30 @@ export default Vue.extend({
5268
return {
5369
dir,
5470
exact: true,
55-
name: basename(dir),
71+
name: this.getDirDisplayName(dir),
5672
to,
5773
}
5874
})
5975
},
6076
},
6177
6278
methods: {
79+
getNodeFromId(id) {
80+
return this.filesStore.getNode(id)
81+
},
82+
getFileIdFromPath(path) {
83+
return this.pathsStore.getPath(this.currentView?.id, path)
84+
},
85+
getDirDisplayName(path) {
86+
if (path === '/') {
87+
return t('files', 'Home')
88+
}
89+
90+
const fileId = this.getFileIdFromPath(path)
91+
const node = this.getNodeFromId(fileId)
92+
return node?.attributes?.displayName || basename(path)
93+
},
94+
6395
onClick(to) {
6496
if (to?.query?.dir === this.$route.query.dir) {
6597
this.$emit('reload')

dist/core-common.js

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

dist/core-common.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.

dist/files-main.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/files-main.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)