1+ <!--
2+ - @copyright Copyright (c) 2023 John Molakvoæ <[email protected] > 3+ -
4+ - @author John Molakvoæ <[email protected] > 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
426 :aria-label =" t('files', 'Current directory path')" >
527 <!-- Current path sections -->
628 <NcBreadcrumb v-for =" (section, index) in sections"
29+ v-show =" shouldShowBreadcrumbs"
730 :key =" section.dir"
831 v-bind =" section"
932 dir =" auto"
2851</template >
2952
3053<script lang="ts">
31- import type { Node } from ' @nextcloud/files'
54+ import { Permission , type Node } from ' @nextcloud/files'
3255
3356import { basename } from ' path'
3457import { defineComponent } from ' vue'
35- import { Permission } from ' @nextcloud/files'
3658import { translate as t } from ' @nextcloud/l10n'
3759import HomeSvg from ' @mdi/svg/svg/home.svg?raw'
3860import NcBreadcrumb from ' @nextcloud/vue/dist/Components/NcBreadcrumb.js'
@@ -45,6 +67,7 @@ import { useDragAndDropStore } from '../store/dragging.ts'
4567import { useFilesStore } from ' ../store/files.ts'
4668import { usePathsStore } from ' ../store/paths.ts'
4769import { useSelectionStore } from ' ../store/selection.ts'
70+ import { useUploaderStore } from ' ../store/uploader.ts'
4871import filesListWidthMixin from ' ../mixins/filesListWidth.ts'
4972import logger from ' ../logger'
5073
@@ -73,11 +96,14 @@ export default defineComponent({
7396 const filesStore = useFilesStore ()
7497 const pathsStore = usePathsStore ()
7598 const selectionStore = useSelectionStore ()
99+ const uploaderStore = useUploaderStore ()
100+
76101 return {
77102 draggingStore ,
78103 filesStore ,
79104 pathsStore ,
80105 selectionStore ,
106+ uploaderStore ,
81107 }
82108 },
83109
@@ -86,12 +112,12 @@ export default defineComponent({
86112 return this .$navigation .active
87113 },
88114
89- dirs() {
90- const cumulativePath = (acc ) => (value ) => (acc += ` ${value }/ ` )
115+ dirs(): string [] {
116+ const cumulativePath = (acc : string ) => (value : string ) => (acc += ` ${value }/ ` )
91117 // Generate a cumulative path for each path segment: ['/', '/foo', '/foo/bar', ...] etc
92- const paths = this .path .split (' /' ).filter (Boolean ).map (cumulativePath (' /' ))
118+ const paths: string [] = this .path .split (' /' ).filter (Boolean ).map (cumulativePath (' /' ))
93119 // Strip away trailing slash
94- return [' /' , ... paths .map (path => path .replace (/ ^ (. + )\/ $ / , ' $1' ))]
120+ return [' /' , ... paths .map (( path : string ) => path .replace (/ ^ (. + )\/ $ / , ' $1' ))]
95121 },
96122
97123 sections() {
@@ -109,8 +135,23 @@ export default defineComponent({
109135 })
110136 },
111137
138+ isUploadInProgress(): boolean {
139+ return this .uploaderStore .queue .length !== 0
140+ },
141+
142+ // Hide breadcrumbs if an upload is ongoing
143+ shouldShowBreadcrumbs(): boolean {
144+ // If we're uploading files, only show the breadcrumbs
145+ // if the files list is greater than 768px wide
146+ if (this .isUploadInProgress ) {
147+ return this .filesListWidth > 768
148+ }
149+ // If we're not uploading, we have enough space from 400px
150+ return this .filesListWidth > 400
151+ },
152+
112153 // used to show the views icon for the first breadcrumb
113- viewIcon() {
154+ viewIcon(): string {
114155 return this .currentView ?.icon ?? HomeSvg
115156 },
116157
@@ -124,19 +165,19 @@ export default defineComponent({
124165 },
125166
126167 methods: {
127- getNodeFromId(id ) {
168+ getNodeFromId(id : number ) : Node | undefined {
128169 return this .filesStore .getNode (id )
129170 },
130- getFileIdFromPath(path ) {
171+ getFileIdFromPath(path : string ) : number | undefined {
131172 return this .pathsStore .getPath (this .currentView ?.id , path )
132173 },
133- getDirDisplayName(path ) {
174+ getDirDisplayName(path : string ) : string {
134175 if (path === ' /' ) {
135176 return this .$navigation ?.active ?.name || t (' files' , ' Home' )
136177 }
137178
138- const fileId = this .getFileIdFromPath (path )
139- const node = this .getNodeFromId (fileId )
179+ const fileId: number | undefined = this .getFileIdFromPath (path )
180+ const node: Node | undefined = ( fileId ) ? this .getNodeFromId (fileId ) : undefined
140181 return node ?.attributes ?.displayName || basename (path )
141182 },
142183
@@ -243,6 +284,7 @@ export default defineComponent({
243284 // Take as much space as possible
244285 flex : 1 1 100% !important ;
245286 width : 100% ;
287+ margin-inline : 0px 10px 0px 10px ;
246288
247289 ::v- deep a {
248290 cursor : pointer !important ;
0 commit comments