Skip to content

Commit

Permalink
feat: extension points, custom components, preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann committed Feb 8, 2024
1 parent 7217b37 commit 8a93f99
Show file tree
Hide file tree
Showing 34 changed files with 1,440 additions and 113 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/enhancement-custom-component-extension
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Enhancement: Custom component extension type

We've introduced a new extension type `customComponent`. This allows to register a custom component via an extension which
can then be rendered in a custom component render target. For the mapping to the render target, an extension point needs to be
registered and a CustomComponentTarget for this extension point needs to be in place in a vue template.

https://github.com/owncloud/web/pull/10443
16 changes: 16 additions & 0 deletions changelog/unreleased/enhancement-extension-points
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Enhancement: Add extensionPoint concept

The extension system now allows developers to register extension points. An extension point defines the metadata for the
integration of a certain extension type in a certain context. Examples for extension points are render targets for
custom components, targets for file actions (e.g. the right click context menu, the batch actions, the whitespace context
menu), etc.

Extensions can now specify that they are only valid for a certain or multiple extension points. This way a file action extension
can e.g. specify to be rendered only in the context menu, but not in the batch actions. Consequently, the extension points
concept is the next iteration of the `scopes` concept. The `scopes` concept will most likely be removed in a future release.

Extension points can define if users should be able to choose preferences for the extension point. E.g. for the global progress
bar extension point, users can choose which of the available progress bar extensions should be used, since the extension point
only allows one extension to be active. At the moment we persist the user choice in the local storage of the browser.

https://github.com/owncloud/web/pull/10443
3 changes: 2 additions & 1 deletion dev/docker/ocis.web.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
"external",
"admin-settings",
"ocm",
"webfinger"
"webfinger",
"progress-bars"
],
"external_apps": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ export default defineComponent({
const extensionActions = computed(() => {
return [
...extensionRegistry
.requestExtensions<ActionExtension>('action', ['upload-menu'])
.requestExtensions<ActionExtension>('action', { scopes: ['upload-menu'] })
.map((e) => e.action)
].filter((e) => e.isEnabled())
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default defineComponent({
const filteredActions = computed(() => {
return unref(extensionRegistry)
.requestExtensions<ActionExtension>('action', ['resource.quick-action'])
.requestExtensions<ActionExtension>('action', { scopes: ['resource.quick-action'] })
.map((e) => e.action)
.filter(({ isEnabled }) => isEnabled({ space: props.space, resources: [props.item] }))
})
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/views/Favorites.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default defineComponent({
const viewModes = computed(() => {
return [
...extensionRegistry
.requestExtensions<FolderViewExtension>('folderView', ['favorite'])
.requestExtensions<FolderViewExtension>('folderView', { scopes: ['favorite'] })
.map((e) => e.folderView)
]
})
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/views/spaces/GenericSpace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export default defineComponent({
const viewModes = computed(() => {
return [
...extensionRegistry
.requestExtensions<FolderViewExtension>('folderView', ['resource'])
.requestExtensions<FolderViewExtension>('folderView', { scopes: ['resource'] })
.map((e) => e.folderView)
]
})
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/views/spaces/Projects.vue
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export default defineComponent({
const viewModes = computed(() => {
return [
...extensionRegistry
.requestExtensions<FolderViewExtension>('folderView', ['space'])
.requestExtensions<FolderViewExtension>('folderView', { scopes: ['space'] })
.map((e) => e.folderView)
]
})
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/tests/unit/views/Favorites.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function getMountedWrapper({ mocks = {}, files = [], loading = false } = {}) {

vi.mocked(useExtensionRegistry).mockImplementation(() =>
useExtensionRegistryMock({
requestExtensions<ExtensionType>(type: string, scopes: string[]) {
requestExtensions<ExtensionType>(type: string) {
return extensions as ExtensionType[]
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ function getMountedWrapper({

vi.mocked(useExtensionRegistry).mockImplementation(() =>
useExtensionRegistryMock({
requestExtensions<ExtensionType>(type: string, scopes: string[]) {
requestExtensions<ExtensionType>(type: string) {
return extensions as ExtensionType[]
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function getMountedWrapper({ mocks = {}, spaces = [], abilities = [], stubAppBar

vi.mocked(useExtensionRegistry).mockImplementation(() =>
useExtensionRegistryMock({
requestExtensions<ExtensionType>(type: string, scopes: string[]) {
requestExtensions<ExtensionType>(type: string) {
return extensions as ExtensionType[]
}
})
Expand Down
9 changes: 9 additions & 0 deletions packages/web-app-progress-bars/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "web-app-progress-bars",
"version": "0.0.0",
"description": "Progress Bars",
"license": "AGPL-3.0",
"peerDependencies": {
"@ownclouders/web-pkg": "workspace:*"
}
}
Loading

0 comments on commit 8a93f99

Please sign in to comment.