Skip to content

Commit

Permalink
prioritize default app by hasPriority
Browse files Browse the repository at this point in the history
  • Loading branch information
elizavetaRa committed Mar 24, 2023
1 parent 7804067 commit 42f1656
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,15 +211,17 @@ export const useFileActions = ({ store }: { store?: Store<any> } = {}) => {

// 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
Expand Down Expand Up @@ -282,6 +284,7 @@ export const useFileActions = ({ store }: { store?: Store<any> } = {}) => {
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 })
Expand Down
1 change: 1 addition & 0 deletions packages/web-pkg/src/composables/actions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface Action<T = ActionOptions> {
componentType: 'button' | 'router-link'
class: string
canBeDefault?: boolean
hasPriority?: boolean
hideLabel?: boolean
shortcut?: string
keepOpen?: boolean
Expand Down

0 comments on commit 42f1656

Please sign in to comment.