Skip to content

Commit e22b67d

Browse files
emoral435skjnldsv
authored andcommitted
fix(files): fixed breadcrumbs dissapearing on narrow screens
Signed-off-by: Eduardo Morales <emoral435@gmail.com>
1 parent 1a845dd commit e22b67d

3 files changed

Lines changed: 41 additions & 19 deletions

File tree

apps/files/src/components/BreadCrumbs.vue

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
<!--
2+
- @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
3+
-
4+
- @author John Molakvoæ <skjnldsv@protonmail.com>
5+
-
6+
- @license AGPL-3.0-or-later
7+
-
8+
- This program is free software: you can redistribute it and/or modify
9+
- it under the terms of the GNU Affero General Public License as
10+
- published by the Free Software Foundation, either version 3 of the
11+
- License, or (at your option) any later version.
12+
-
13+
- This program is distributed in the hope that it will be useful,
14+
- but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
- GNU Affero General Public License for more details.
17+
-
18+
- You should have received a copy of the GNU Affero General Public License
19+
- along with this program. If not, see <http://www.gnu.org/licenses/>.
20+
-
21+
-->
22+
123
<template>
224
<NcBreadcrumbs
325
data-cy-files-content-breadcrumbs
@@ -29,11 +51,10 @@
2951
</template>
3052

3153
<script lang="ts">
32-
import type { Node } from '@nextcloud/files'
54+
import { Permission, type Node } from '@nextcloud/files'
3355
3456
import { basename } from 'path'
3557
import { defineComponent } from 'vue'
36-
import { Permission } from '@nextcloud/files'
3758
import { translate as t} from '@nextcloud/l10n'
3859
import HomeSvg from '@mdi/svg/svg/home.svg?raw'
3960
import NcBreadcrumb from '@nextcloud/vue/dist/Components/NcBreadcrumb.js'
@@ -91,12 +112,12 @@ export default defineComponent({
91112
return this.$navigation.active
92113
},
93114
94-
dirs() {
95-
const cumulativePath = (acc) => (value) => (acc += `${value}/`)
115+
dirs(): string[] {
116+
const cumulativePath = (acc: string) => (value: string) => (acc += `${value}/`)
96117
// Generate a cumulative path for each path segment: ['/', '/foo', '/foo/bar', ...] etc
97-
const paths = this.path.split('/').filter(Boolean).map(cumulativePath('/'))
118+
const paths: string[] = this.path.split('/').filter(Boolean).map(cumulativePath('/'))
98119
// Strip away trailing slash
99-
return ['/', ...paths.map(path => path.replace(/^(.+)\/$/, '$1'))]
120+
return ['/', ...paths.map((path: string) => path.replace(/^(.+)\/$/, '$1'))]
100121
},
101122
102123
sections() {
@@ -114,11 +135,6 @@ export default defineComponent({
114135
})
115136
},
116137
117-
// used to show the views icon for the first breadcrumb
118-
viewIcon() {
119-
return this.currentView?.icon ?? HomeSvg
120-
},
121-
122138
isUploadInProgress(): boolean {
123139
return this.uploaderStore.queue.length !== 0
124140
},
@@ -134,6 +150,11 @@ export default defineComponent({
134150
return this.filesListWidth > 400
135151
},
136152
153+
// used to show the views icon for the first breadcrumb
154+
viewIcon(): string {
155+
return this.currentView?.icon ?? HomeSvg
156+
},
157+
137158
selectedFiles() {
138159
return this.selectionStore.selected
139160
},
@@ -144,19 +165,19 @@ export default defineComponent({
144165
},
145166
146167
methods: {
147-
getNodeFromId(id) {
168+
getNodeFromId(id: number): Node | undefined {
148169
return this.filesStore.getNode(id)
149170
},
150-
getFileIdFromPath(path) {
171+
getFileIdFromPath(path: string): number | undefined {
151172
return this.pathsStore.getPath(this.currentView?.id, path)
152173
},
153-
getDirDisplayName(path) {
174+
getDirDisplayName(path: string): string {
154175
if (path === '/') {
155176
return this.$navigation?.active?.name || t('files', 'Home')
156177
}
157178
158-
const fileId = this.getFileIdFromPath(path)
159-
const node = this.getNodeFromId(fileId)
179+
const fileId: number | undefined = this.getFileIdFromPath(path)
180+
const node: Node | undefined = (fileId) ? this.getNodeFromId(fileId) : undefined
160181
return node?.attributes?.displayName || basename(path)
161182
},
162183
@@ -263,6 +284,7 @@ export default defineComponent({
263284
// Take as much space as possible
264285
flex: 1 1 100% !important;
265286
width: 100%;
287+
margin-inline: 0px 10px 0px 10px;
266288
267289
::v-deep a {
268290
cursor: pointer !important;

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)