@@ -62,41 +62,50 @@ export default {
6262 } ,
6363
6464 $_fileActions_editorActions ( ) {
65- return this . apps . fileEditors . map ( ( editor ) => {
66- return {
67- label : ( ) => {
68- const translated = this . $gettext ( 'Open in %{app}' )
69- return this . $gettextInterpolate (
70- translated ,
71- { app : this . apps . meta [ editor . app ] . name } ,
72- true
73- )
74- } ,
75- icon : this . apps . meta [ editor . app ] . icon ,
76- handler : ( { resources } ) =>
77- this . $_fileActions_openEditor (
78- editor ,
79- resources [ 0 ] . path ,
80- resources [ 0 ] . id ,
81- EDITOR_MODE_EDIT
82- ) ,
83- isEnabled : ( { resources } ) => {
84- if ( resources . length !== 1 ) {
85- return false
86- }
87- if ( Array . isArray ( editor . routes ) && ! checkRoute ( editor . routes , this . $route . name ) ) {
88- return false
89- }
90-
91- return resources [ 0 ] . extension . toLowerCase ( ) === editor . extension . toLowerCase ( )
92- } ,
93- canBeDefault : true ,
94- componentType : 'oc-button' ,
95- class : `oc-files-actions-${ kebabCase (
96- this . apps . meta [ editor . app ] . name
97- ) . toLowerCase ( ) } -trigger`
98- }
99- } )
65+ return this . apps . fileEditors
66+ . map ( ( editor ) => {
67+ return {
68+ label : ( ) => {
69+ const translated = this . $gettext ( 'Open in %{app}' )
70+ return this . $gettextInterpolate (
71+ translated ,
72+ { app : this . apps . meta [ editor . app ] . name } ,
73+ true
74+ )
75+ } ,
76+ icon : this . apps . meta [ editor . app ] . icon ,
77+ img : this . apps . meta [ editor . app ] . img ,
78+ handler : ( { resources } ) =>
79+ this . $_fileActions_openEditor (
80+ editor ,
81+ resources [ 0 ] . path ,
82+ resources [ 0 ] . id ,
83+ EDITOR_MODE_EDIT
84+ ) ,
85+ isEnabled : ( { resources } ) => {
86+ if ( resources . length !== 1 ) {
87+ return false
88+ }
89+ if ( Array . isArray ( editor . routes ) && ! checkRoute ( editor . routes , this . $route . name ) ) {
90+ return false
91+ }
92+
93+ return resources [ 0 ] . extension . toLowerCase ( ) === editor . extension . toLowerCase ( )
94+ } ,
95+ canBeDefault : editor . canBeDefault ,
96+ componentType : 'oc-button' ,
97+ class : `oc-files-actions-${ kebabCase (
98+ this . apps . meta [ editor . app ] . name
99+ ) . toLowerCase ( ) } -trigger`
100+ }
101+ } )
102+ . sort ( ( first , second ) => {
103+ // Ensure default are listed first
104+ if ( second . canBeDefault !== first . canBeDefault && second . canBeDefault ) {
105+ return 1
106+ }
107+ return 0
108+ } )
100109 }
101110 } ,
102111
@@ -214,7 +223,8 @@ export default {
214223 const label = this . $gettext ( 'Open in %{ appName }' )
215224 return {
216225 name : app . name ,
217- img : app . icon ,
226+ icon : app . icon ,
227+ img : app . img ,
218228 componentType : 'oc-button' ,
219229 class : `oc-files-actions-${ app . name } -trigger` ,
220230 isEnabled : ( ) => true ,
0 commit comments