Skip to content

Commit 487e54e

Browse files
committed
feat: handle editor-less extensions
When an app does not expose any routes, mark it as editor-less so that we do not try to load editor actions for such extension.
1 parent 7a0789d commit 487e54e

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Enhancement: Handle extensions without editor
2+
3+
We've added a new property to extensions that asserts whether is has an editor or not. This property is computed by checking whether the extension exposes any routes.
4+
5+
https://github.com/owncloud/web/pull/12105

packages/web-pkg/src/apps/types.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ export interface ApplicationInformation {
8686
translations?: Translations
8787
/** @deprecated */
8888
applicationMenu?: ApplicationMenuItem
89+
/** Asserts whether the app has any route which works as an editor */
90+
hasEditor?: boolean
8991
}
9092

9193
/**
@@ -99,7 +101,7 @@ export interface ApplicationTranslations {
99101

100102
/** ClassicApplicationScript reflects classic application script structure */
101103
export interface ClassicApplicationScript {
102-
appInfo?: ApplicationInformation
104+
appInfo?: Omit<ApplicationInformation, 'hasEditor'>
103105
routes?: ((args: ComponentCustomProperties) => RouteRecordRaw[]) | RouteRecordRaw[]
104106
navItems?: ((args: ComponentCustomProperties) => AppNavigationItem[]) | AppNavigationItem[]
105107
translations?: ApplicationTranslations

packages/web-pkg/src/composables/actions/files/useFileActions.ts

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export const useFileActions = () => {
112112
}
113113

114114
return appsStore.fileExtensions
115+
.filter((fileExtension) => appsStore.apps[fileExtension.app]?.hasEditor)
115116
.map((fileExtension): FileAction => {
116117
const appInfo = appsStore.apps[fileExtension.app]
117118

packages/web-pkg/tests/unit/composables/actions/files/useFileActions.spec.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,22 @@ function getWrapper({ setup }: { setup: (instance: ReturnType<typeof useFileActi
9090
{
9191
extension: 'txt'
9292
}
93-
]
93+
],
94+
hasEditor: true
9495
},
9596
external: {
9697
defaultExtension: '',
9798
icon: 'check_box_outline_blank',
9899
name: 'External',
99-
id: 'external'
100+
id: 'external',
101+
hasEditor: true
102+
},
103+
'editor-less': {
104+
defaultExtension: '',
105+
icon: 'check_box_outline_blank',
106+
name: 'Editor Less',
107+
id: 'editor-less',
108+
hasEditor: false
100109
}
101110
},
102111
fileExtensions: [

packages/web-runtime/src/container/application/classic.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,10 @@ export const convertClassicApplication = ({
110110
})
111111

112112
const appsStore = useAppsStore()
113-
appsStore.registerApp(applicationScript.appInfo, applicationScript.translations)
113+
appsStore.registerApp(
114+
{ ...applicationScript.appInfo, hasEditor: applicationScript.routes?.length > 0 },
115+
applicationScript.translations
116+
)
114117

115118
if (applicationScript.extensions) {
116119
extensionRegistry.registerExtensions(applicationScript.extensions)

0 commit comments

Comments
 (0)