Skip to content

Commit 11c0a2f

Browse files
committed
Apps fixes
Allow img instead of icon Ensure canBeDefault is honored
1 parent 135db5f commit 11c0a2f

File tree

4 files changed

+45
-32
lines changed

4 files changed

+45
-32
lines changed

packages/web-app-files/src/components/FilesList/ContextActions.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
:class="['oc-text-bold', action.class]"
1818
v-on="getComponentListeners(action, item)"
1919
>
20-
<oc-icon v-if="action.icon" :name="action.icon" size="medium" />
20+
<oc-icon v-if="action.icon && !action.img" :name="action.icon" size="medium" />
2121
<oc-img v-if="action.img" :src="action.img" alt="" class="oc-icon oc-icon-m" />
2222
<span class="oc-files-context-action-label">{{ action.label(item) }}</span>
2323
<span

packages/web-app-files/src/components/SideBar/Actions/FileActions.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
:class="['oc-text-bold', action.class]"
88
@click.stop="action.handler(highlightedFile, action.handlerData)"
99
>
10-
<oc-icon v-if="action.icon" :name="action.icon" size="medium" />
10+
<oc-icon v-if="action.icon && !action.img" :name="action.icon" size="medium" />
1111
<oc-img v-if="action.img" :src="action.img" alt="" class="oc-icon oc-icon-m" />
1212
<span class="oc-files-actions-sidebar-action-label">{{
1313
action.label(highlightedFile)

packages/web-app-files/src/mixins/fileActions.js

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -66,33 +66,42 @@ export default {
6666
},
6767

6868
$_fileActions_editorActions() {
69-
return this.apps.fileEditors.map((editor) => {
70-
return {
71-
label: () => {
72-
const translated = this.$gettext('Open in %{app}')
73-
return this.$gettextInterpolate(
74-
translated,
75-
{ app: this.apps.meta[editor.app].name },
76-
true
77-
)
78-
},
79-
icon: this.apps.meta[editor.app].icon,
80-
handler: (item) =>
81-
this.$_fileActions_openEditor(editor, item.path, item.id, EDITOR_MODE_EDIT),
82-
isEnabled: ({ resource }) => {
83-
if (editor.routes?.length > 0 && !checkRoute(editor.routes, this.$route.name)) {
84-
return false
85-
}
86-
87-
return resource.extension === editor.extension
88-
},
89-
canBeDefault: true,
90-
componentType: 'oc-button',
91-
class: `oc-files-actions-${kebabCase(
92-
this.apps.meta[editor.app].name
93-
).toLowerCase()}-trigger`
94-
}
95-
})
69+
return this.apps.fileEditors
70+
.map((editor) => {
71+
return {
72+
label: () => {
73+
const translated = this.$gettext('Open in %{app}')
74+
return this.$gettextInterpolate(
75+
translated,
76+
{ app: this.apps.meta[editor.app].name },
77+
true
78+
)
79+
},
80+
icon: this.apps.meta[editor.app].icon,
81+
img: this.apps.meta[editor.app].img,
82+
handler: (item) =>
83+
this.$_fileActions_openEditor(editor, item.path, item.id, EDITOR_MODE_EDIT),
84+
isEnabled: ({ resource }) => {
85+
if (editor.routes?.length > 0 && !checkRoute(editor.routes, this.$route.name)) {
86+
return false
87+
}
88+
89+
return resource.extension === editor.extension
90+
},
91+
canBeDefault: editor.canBeDefault,
92+
componentType: 'oc-button',
93+
class: `oc-files-actions-${kebabCase(
94+
this.apps.meta[editor.app].name
95+
).toLowerCase()}-trigger`
96+
}
97+
})
98+
.sort((first, second) => {
99+
// We make the default action based on the order, so put the ones who can be default on top
100+
if (second.canBeDefault !== first.canBeDefault && second.canBeDefault) {
101+
return 1
102+
}
103+
return 0
104+
})
96105
}
97106
},
98107

@@ -183,7 +192,8 @@ export default {
183192
return appProviders.map((app) => {
184193
const label = this.$gettext('Open in %{ appName }')
185194
return {
186-
img: app.icon,
195+
icon: app.icon,
196+
img: app.img,
187197
componentType: 'oc-button',
188198
class: `oc-files-actions-${app.name}-trigger`,
189199
isEnabled: () => true,

packages/web-runtime/src/store/apps.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,13 @@ const mutations = {
4646
const editor = {
4747
app,
4848
icon: extension.icon,
49+
img: extension.img,
4950
newTab: extension.newTab || false,
5051
routeName: extension.routeName,
5152
routes: extension.routes || [],
5253
extension: extension.extension,
53-
handler: extension.handler
54+
handler: extension.handler,
55+
canBeDefault: 'canBeDefault' in extension ? extension.canBeDefault : true
5456
}
5557

5658
state.fileEditors.push(editor)
@@ -94,7 +96,8 @@ const mutations = {
9496
const app = {
9597
name: appInfo.name || appInfo.id,
9698
id: appInfo.id,
97-
icon: appInfo.icon || 'check_box_outline_blank'
99+
icon: appInfo.icon || 'check_box_outline_blank',
100+
img: appInfo.img || null
98101
}
99102
state.meta[app.id] = app
100103
},

0 commit comments

Comments
 (0)