From 14635929e9a233146d7cf15f9f322cbbde247966 Mon Sep 17 00:00:00 2001
From: Ferdinand Thiessen <opensource@fthiessen.de>
Date: Thu, 16 May 2024 23:36:46 +0200
Subject: fix(files): Keep 'back'-button for not found directories or if user
 can not upload

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
---
 apps/files/src/views/FilesList.vue | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

(limited to 'apps/files/src/views/FilesList.vue')

diff --git a/apps/files/src/views/FilesList.vue b/apps/files/src/views/FilesList.vue
index b40af040984..0880e02ca0c 100644
--- a/apps/files/src/views/FilesList.vue
+++ b/apps/files/src/views/FilesList.vue
@@ -76,15 +76,21 @@
 			:name="currentView?.emptyTitle || t('files', 'No files in here')"
 			:description="currentView?.emptyCaption || t('files', 'Upload some content or sync with your devices!')"
 			data-cy-files-content-empty>
-			<template #action>
+			<template v-if="dir !== '/'" #action>
 				<!-- Uploader -->
-				<UploadPicker v-if="dir !== '/'"
+				<UploadPicker v-if="currentFolder && canUpload && !isQuotaExceeded"
 					:content="dirContents"
 					:destination="currentFolder"
-					:multiple="true"
 					class="files-list__header-upload-button"
+					multiple
 					@failed="onUploadFail"
 					@uploaded="onUpload" />
+				<NcButton v-else
+					:aria-label="t('files', 'Go to the previous folder')"
+					:to="toPreviousDir"
+					type="primary">
+					{{ t('files', 'Go back') }}
+				</NcButton>
 			</template>
 			<template #icon>
 				<NcIconSvgWrapper :svg="currentView.icon" />
@@ -353,6 +359,14 @@ export default defineComponent({
 				&& this.loading
 		},
 
+		/**
+		 * Route to the previous directory.
+		 */
+		toPreviousDir(): Route {
+			const dir = this.dir.split('/').slice(0, -1).join('/') || '/'
+			return { ...this.$route, query: { dir } }
+		},
+
 		shareAttributes(): number[] | undefined {
 			if (!this.currentFolder?.attributes?.['share-types']) {
 				return undefined
-- 
cgit v1.2.3

