@@ -143,10 +143,32 @@ export default {
143143 // returns the _first_ action from actions array which we now construct from
144144 // available mime-types coming from the app-provider and existing actions
145145 $_fileActions_triggerDefaultAction ( resource ) {
146- const actions = this . $_fileActions_getAllAvailableActions ( resource ) . filter (
147- ( action ) => action . canBeDefault
148- )
149- actions [ 0 ] . handler ( resource , actions [ 0 ] . handlerData )
146+ const action = this . $_fileActions_getDefaultAction ( resource )
147+ action . handler ( resource , action . handlerData )
148+ } ,
149+
150+ $_fileActions_getDefaultAction ( resource ) {
151+ const filterCallback = ( action ) =>
152+ action . canBeDefault && action . isEnabled ( { resource, parent : this . currentFolder } )
153+
154+ // first priority: handlers from config
155+ const defaultEditorActions = this . $_fileActions_editorActions . filter ( filterCallback )
156+ if ( defaultEditorActions . length ) {
157+ return defaultEditorActions [ 0 ]
158+ }
159+
160+ // second priority: `/app/open` endpoint of app provider if available
161+ // FIXME: files app should not know anything about the `external apps` app
162+ const externalAppsActions =
163+ this . $_fileActions_loadExternalAppActions ( resource ) . filter ( filterCallback )
164+ if ( externalAppsActions . length ) {
165+ return {
166+ handler : ( ) => this . $_fileActions_openLink ( undefined , resource . fileId )
167+ }
168+ }
169+
170+ // fallback: system actions
171+ return this . $_fileActions_systemActions . filter ( filterCallback )
150172 } ,
151173
152174 $_fileActions_getAllAvailableActions ( resource ) {
@@ -195,9 +217,11 @@ export default {
195217 } ,
196218
197219 $_fileActions_openLink ( appName , resourceId ) {
220+ const params = { file_id : resourceId }
221+ if ( appName ) params . app = appName
198222 const routeData = this . $router . resolve ( {
199223 name : 'external-apps' ,
200- params : { app : appName , file_id : resourceId }
224+ params
201225 } )
202226 // TODO: Let users configure whether to open in same/new tab (`_blank` vs `_self`)
203227 window . open ( routeData . href , '_blank' )
0 commit comments