Skip to content

Commit 7c7887a

Browse files
authored
Merge pull request #12105 from owncloud/feat/editorless-extensions
feat: handle editor-less extensions
2 parents e94dab7 + 487e54e commit 7c7887a

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
@@ -92,6 +92,8 @@ export interface ApplicationInformation {
9292
translations?: Translations
9393
/** @deprecated */
9494
applicationMenu?: ApplicationMenuItem
95+
/** Asserts whether the app has any route which works as an editor */
96+
hasEditor?: boolean
9597
}
9698

9799
/**
@@ -105,7 +107,7 @@ export interface ApplicationTranslations {
105107

106108
/** ClassicApplicationScript reflects classic application script structure */
107109
export interface ClassicApplicationScript {
108-
appInfo?: ApplicationInformation
110+
appInfo?: Omit<ApplicationInformation, 'hasEditor'>
109111
routes?: ((args: ComponentCustomProperties) => RouteRecordRaw[]) | RouteRecordRaw[]
110112
navItems?: ((args: ComponentCustomProperties) => AppNavigationItem[]) | AppNavigationItem[]
111113
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)