From d9f9a7280e94064ded03bbfc7cb9331380c9b185 Mon Sep 17 00:00:00 2001
From: John Molakvoæ <skjnldsv@protonmail.com>
Date: Wed, 24 May 2023 17:20:35 +0200
Subject: fix(files): make open folder a default action
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
---
 apps/files/src/components/FileEntry.vue | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

(limited to 'apps/files/src/components/FileEntry.vue')

diff --git a/apps/files/src/components/FileEntry.vue b/apps/files/src/components/FileEntry.vue
index 8dc067a407d..fd61f5e3623 100644
--- a/apps/files/src/components/FileEntry.vue
+++ b/apps/files/src/components/FileEntry.vue
@@ -33,7 +33,7 @@
 
 		<!-- Link to file -->
 		<td class="files-list__row-name">
-			<a ref="name" v-bind="linkTo" @click="execDefaultAction">
+			<a ref="name" v-bind="linkAttrs" @click="execDefaultAction">
 				<!-- Icon or preview -->
 				<span class="files-list__row-icon">
 					<FolderIcon v-if="source.type === 'folder'" />
@@ -261,7 +261,22 @@ export default Vue.extend({
 			return minOpacity + (1 - minOpacity) * Math.pow((this.source.size / maxOpacitySize), 2)
 		},
 
-		linkTo() {
+		linkAttrs() {
+			if (this.enabledDefaultActions.length > 0) {
+				const action = this.enabledDefaultActions[0]
+				const displayName = action.displayName([this.source], this.currentView)
+				return {
+					class: ['files-list__row-default-action', 'files-list__row-action-' + action.id],
+					role: 'button',
+					title: displayName,
+				}
+			}
+
+			/**
+			 * A folder would never reach this point
+			 * as it has open-folder as default action.
+			 * Just to be safe, let's handle it.
+			 */
 			if (this.source.type === 'folder') {
 				const to = { ...this.$route, query: { dir: join(this.dir, this.source.basename) } }
 				return {
@@ -271,15 +286,6 @@ export default Vue.extend({
 				}
 			}
 
-			if (this.enabledDefaultActions.length > 0) {
-				const action = this.enabledDefaultActions[0]
-				const displayName = action.displayName([this.source], this.currentView)
-				return {
-					title: displayName,
-					role: 'button',
-				}
-			}
-
 			return {
 				href: this.source.source,
 				// TODO: Use first action title ?
@@ -526,11 +532,6 @@ export default Vue.extend({
 			}
 		},
 		execDefaultAction(event) {
-			// Do not execute the default action on the folder, navigate instead
-			if (this.source.type === 'folder') {
-				return
-			}
-
 			if (this.enabledDefaultActions.length > 0) {
 				event.preventDefault()
 				event.stopPropagation()
-- 
cgit v1.2.3

