From 42f1656900137ee166155e9c1a890e33660c2c23 Mon Sep 17 00:00:00 2001 From: elizavetaRa Date: Fri, 24 Mar 2023 09:32:53 +0100 Subject: [PATCH] prioritize default app by hasPriority --- .../src/composables/actions/files/useFileActions.ts | 13 ++++++++----- packages/web-pkg/src/composables/actions/types.ts | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/web-app-files/src/composables/actions/files/useFileActions.ts b/packages/web-app-files/src/composables/actions/files/useFileActions.ts index 009fb2f3f6d..8a2b93b4c26 100644 --- a/packages/web-app-files/src/composables/actions/files/useFileActions.ts +++ b/packages/web-app-files/src/composables/actions/files/useFileActions.ts @@ -211,15 +211,17 @@ export const useFileActions = ({ store }: { store?: Store } = {}) => { // first priority: handlers from config const defaultEditorActions = unref(editorActions).filter(filterCallback) - if (defaultEditorActions.length) { - return defaultEditorActions[0] - } // second priority: `/app/open` endpoint of app provider if available // FIXME: files app should not know anything about the `external apps` app const externalAppsActions = loadExternalAppActions(options).filter(filterCallback) - if (externalAppsActions.length) { - return externalAppsActions[0] + + // prioritize apps that have hasPriority set + const appActions = [...defaultEditorActions, ...externalAppsActions].sort( + (a, b) => Number(b.hasPriority) - Number(a.hasPriority) + ) + if (appActions.length) { + return appActions[0] } // fallback: system actions @@ -282,6 +284,7 @@ export const useFileActions = ({ store }: { store?: Store } = {}) => { class: `oc-files-actions-${app.name}-trigger`, isEnabled: () => true, canBeDefault: defaultApplication === app.name, + hasPriority: defaultApplication === app.name, handler: () => openExternalApp(app.name, driveAliasAndItem, webDavPath, fileId, options.space.shareId), label: () => $gettextInterpolate(label, { appName: app.name }) diff --git a/packages/web-pkg/src/composables/actions/types.ts b/packages/web-pkg/src/composables/actions/types.ts index d6618c5efa4..46afbee6043 100644 --- a/packages/web-pkg/src/composables/actions/types.ts +++ b/packages/web-pkg/src/composables/actions/types.ts @@ -12,6 +12,7 @@ export interface Action { componentType: 'button' | 'router-link' class: string canBeDefault?: boolean + hasPriority?: boolean hideLabel?: boolean shortcut?: string keepOpen?: boolean