Skip to content

Commit

Permalink
Introduce more extension points and delete scopes (#10758)
Browse files Browse the repository at this point in the history
* feat: introduce extension points
  • Loading branch information
kulmann committed May 16, 2024
1 parent 51017bb commit 9f04956
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 39 deletions.
61 changes: 36 additions & 25 deletions extension-system/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ geekdocCollapseSection: true

## Concepts and Building Blocks

The ownCloud Web can be extended through various entry points with custom **apps** and **extensions**.
ownCloud Web can be extended through various entry points with custom **apps** and **extensions**.

### Distinction between Apps and Extensions

Expand All @@ -27,6 +27,11 @@ It serves two main purposes:
Both parts are optional. This means that an application can be a file editor without any custom extensions, or even contain
no custom application code at all and only host extensions to be registered in the extension registry, or a combination of both.

### Examples

You can find open source examples for apps and extensions in our [curated list of ownCloud apps and extensions](https://github.com/owncloud/awesome-ocis).
Feel free to contribute or just be inspired for your own apps or extensions.

### Apps

To get started, define a `src/index.ts`. Below is the most basic example of its content:
Expand Down Expand Up @@ -96,22 +101,22 @@ In contrast to applications, extensions usually have a rather small scope and de

The globally available extension registry provided by the ownCloud Web runtime can be used to both register and query extensions. All extensions
which are being made available via an `app` get registered in the extension registry automatically. In your custom application code you can
then query any of the available extensions by providing a `type` string and optionally a list of `scopes`. Throughout the ownCloud Web platform
then query any of the available extensions by providing an `extensionPoint` entity. Throughout the ownCloud Web platform
and most prominently also in the `files` app we have defined some extension points which automatically use certain extensions, see the
`Extension Points` section below.

#### Extension Types

For building an extension you can choose from the types predefined by the ownCloud Web extension system. See the full list of available extension types below.

1. `ActionExtension` (type `action`) - An extension that can register `Action` items which then get shown in various places (e.g. context menus, batch actions), depending on their
respective scope. Most commonly used for file and folder actions (e.g. copy, rename, delete, etc.). For details, please refer to the [action docs]({{< ref "extension-types/actions.md" >}})
2. `SearchExtension` (type `search`) - An extension that can register additional search providers. For details, please refer to the [search docs]({{< ref "extension-types/search.md" >}})
3. `SidebarNavExtension` (type `sidebarNav`) - An extension that can register additional navigation items to the left sidebar. These can be scoped to specific apps, and programmatically enabled/disabled.
For details, please refer to the [sidebar nav docs]({{< ref "extension-types/left-sidebar-menu-item.md" >}})
4. `SidebarPanelExtension`, (type `sidebarPanel`) - An extension that can register panels to the right sidebar. For details, please refer to the [sidebar panel docs]({{< ref "extension-types/right-sidebar-panels.md" >}})
5. `FolderViewExtension` (type `folderView`) - An extension that can register additional ways of displaying the content of a folder (resources, so spaces, folders or files) to the user.
For details, please refer to the [folder view docs]({{< ref "extension-types/folder-view.md" >}})
1. `ActionExtension` (type `action`) - An extension that can register `Action` items which then get shown in various places (e.g. context menus, batch actions), depending on the
extension points referenced in the extension respectively. Most commonly used for file and folder actions (e.g. copy, rename, delete, etc.). For details, please refer to the [action docs]({{< ref "extension-types/actions.md" >}}).
2. `SearchExtension` (type `search`) - An extension that can register additional search providers. For details, please refer to the [search docs]({{< ref "extension-types/search.md" >}}).
3. `SidebarNavExtension` (type `sidebarNav`) - An extension that can register additional navigation items for the left sidebar. These can be scoped to specific apps, and programmatically enabled/disabled.
For details, please refer to the [sidebar nav docs]({{< ref "extension-types/left-sidebar-menu-item.md" >}}).
4. `SidebarPanelExtension`, (type `sidebarPanel`) - An extension that can register panels for the right sidebar. For details, please refer to the [sidebar panel docs]({{< ref "extension-types/right-sidebar-panels.md" >}}).
5. `FolderViewExtension` (type `folderView`) - An extension that can register additional ways of displaying the content of a folder (resources like spaces, folders or files) to the user.
For details, please refer to the [folder view docs]({{< ref "extension-types/folder-view.md" >}}).
6. `CustomComponentExtension` (type `customComponent`) - An extension that can register a custom component for a render target. For details, please refer to the
[custom component docs]({{< ref "extension-types/custom-components.md" >}})

Expand All @@ -120,7 +125,7 @@ that an important extension type is missing and would be beneficial for the plat

#### Extension Base Configuration

Any extension is required to define at least an `id` and a `type`.
Any extension is required to define at least an `id` and a `type` in order to fulfill the generic `Extension` interface.

The `id` is supposed to be unique throughout the ownCloud Web ecosystem. In order to keep `id`s readable for humans we didn't want to enforce uniqueness through e.g. uuids.
Instead, we chose to use dot-formatted namespaces like e.g. `com.github.owncloud.web.files.search`. We'd like to encourage you to follow the same format for your own extensions.
Expand All @@ -133,18 +138,24 @@ You can find predefined extension point ids in the extension points section belo

#### Extension Points

There are standardized components and places where extensions are being used automatically. The following are the ones that are currently provided
by the ownCloud Web runtime or the `files` app.

1. Left Sidebar for Navigation
2. Right Sidebar in any file(s) context
3. Folder Views in the files app
4. Right click context menu in the files app
5. Batch actions in the files app
6. Upload menu in the files app
7. Quick actions in the files list of the files app
8. Search results in the search app
9. Global progress bar for the global loading state. Extension point id `app.runtime.global-progress-bar`. Allows to render a single custom component.
There are standardized components and places where extensions are being used automatically. The following ones are currently provided by the ownCloud Web runtime or
the `files` app. If you decide to develop an extension which fulfills the type and registers itself for the extensionPointId of the respective extension point,
your extension will be used automatically.

1. Left Sidebar for Navigation. ExtensionPointId `app.${appName}.navItems` (dynamically created for each app). Mounts extensions of type `sidebarNav`.
2. Global top bar
1. Center area. ExtensionPointId `app.runtime.header.center`. Mounts extensions of type `customComponent`.
2. Progress bar for the global loading state. ExtensionPointId `app.runtime.global-progress-bar`. Mounts a single extensions of type `customComponent`. If multiple exist, the user can choose via the account page.
3. Files app
1. Right sidebar. ExtensionPointId `app.files.sidebar`. Mounts extensions of type `sidebarPanel`. Used in any file(s) context (files app, file viewer apps, file editor apps).
2. Folder views for regular folders. ExtensionPointId `app.files.folder-views.folder`. Mounts extensions of type `folderView`.
3. Folder views for the project spaces overview. ExtensionPointId `app.files.folder-views.project-spaces`. Mounts extensions of type `folderView`.
4. Folder views for the favorites page. ExtensionPointId `app.files.folder-views.favorites`. Mounts extensions of type `folderView`.
5. Right click context menu. ExtensionPointId `app.files.context-actions`. Mounts extensions of type `action`.
6. Batch actions in the app bar above file lists. ExtensionPointId `app.files.batch-actions`. Mounts extensions of type `action`.
7. Upload menu. ExtensionPointId `app.files.upload-menu`. Mounts extensions of type `action`.
8. Quick actions. ExtensionPointId `app.files.quick-actions`. Mounts extensions of type `action`.
4. Global search providers. ExtensionPointId `app.search.providers`. Utilizes extensions of type `search` as search engines for the search input in the global top bar.

#### User Preferences for Extensions

Expand All @@ -154,7 +165,7 @@ The user can then select one out of all the extensions which have been registere

### Helpful packages

We currently offer two packages that can be integrated into your app, providing useful utilities and types.
We currently offer the following packages that can be integrated into your app, providing useful utilities and types.

- `web-client` - This package serves as an abstraction layer between the server APIs and an app or extension. It converts API data into objects with helpful types and utilities. For details, please refer to the package's [README.md](https://github.com/owncloud/web/blob/master/packages/web-client/README.md).
- `web-client` - This package serves as an abstraction layer between the server APIs and an app or extension. It converts raw API data into objects with helpful types and utilities. For details, please refer to the package's [README.md](https://github.com/owncloud/web/blob/master/packages/web-client/README.md).
- `web-pkg` - This package provides utilities, most importantly a variety of components and composables, that can be useful when developing apps and extensions. For details, please refer to the package's [README.md](https://github.com/owncloud/web/blob/master/packages/web-pkg/README.md).
6 changes: 3 additions & 3 deletions extension-system/extension-types/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ Actions are one of the possible extension types. Registered actions get rendered

### Configuration

This is what the ActionExtension interface looks like:
This is what the `ActionExtension` interface looks like:

```typescript
interface ActionExtension {
id: string
type: 'action'
scopes?: ExtensionScope[]
extensionPointIds?: string[]
action: Action // Please check the Action section below
}
```

For `id`, `type`, and `scopes`, please see [extension base section]({{< ref "../_index.md#extension-base-configuration" >}}) in top level docs.
For `id`, `type`, and `extensionPointIds`, please see [extension base section]({{< ref "../_index.md#extension-base-configuration" >}}) in top level docs.

#### Action

Expand Down
6 changes: 3 additions & 3 deletions extension-system/extension-types/custom-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ Here's what it looks like:

```typescript
interface CustomComponentExtension {
id: string,
type: 'customComponent',
extensionPointIds: string[],
id: string
type: 'customComponent'
extensionPointIds?: string[]
content: Slot | Component
}
```
Expand Down
4 changes: 2 additions & 2 deletions extension-system/extension-types/folder-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ This is what the FolderViewExtension interface looks like:
```typescript
interface FolderViewExtension {
id: string
scopes?: ExtensionScope[]
type: 'folderView'
extensionPointIds?: string[]
folderView: FolderView // See FolderView section below
}
```

For `id`, `type`, and `scopes`, please see [extension base section]({{< ref "../_index.md#extension-base-configuration" >}}) in top level docs.
For `id`, `type`, and `extensionPointIds`, please see [extension base section]({{< ref "../_index.md#extension-base-configuration" >}}) in top level docs.

#### FolderView

Expand Down
4 changes: 2 additions & 2 deletions extension-system/extension-types/left-sidebar-menu-item.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ It looks like this:
interface SidebarNavExtension {
id: string
type: 'sidebarNav'
scopes?: ExtensionScope[]
extensionPointIds?: string[]
navItem: AppNavigationItem // Please check the AppNavigationItem section below
}
}
```

For `id`, `type`, and `scopes`, please see [extension base section]({{< ref "../_index.md#extension-base-configuration" >}}) in top level docs.
For `id`, `type`, and `extensionPointIds`, please see [extension base section]({{< ref "../_index.md#extension-base-configuration" >}}) in top level docs.

#### AppNavigationItem

Expand Down
4 changes: 2 additions & 2 deletions extension-system/extension-types/right-sidebar-panels.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ It can be found below:
interface SidebarPanelExtension<R extends Item, P extends Item, T extends Item> {
id: string
type: 'sidebarPanel'
scopes?: ExtensionScope[]
extensionPointIds?: string[]
panel: SideBarPanel<R, P, T> // Please check the SideBarPanel section below
}
```

For `id`, `type`, and `scopes`, please see [extension base section]({{< ref "../_index.md#extension-base-configuration" >}}) in the top level docs.
For `id`, `type`, and `extensionPointIds`, please see [extension base section]({{< ref "../_index.md#extension-base-configuration" >}}) in the top level docs.

The `panel` object configures the actual sidebar panel. It consists of different properties and functions, where all the functions get called with a
`SideBarPanelContext` entity from the integrating extension points.
Expand Down
4 changes: 2 additions & 2 deletions extension-system/extension-types/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ An example of a search extension configuration can be found below:
interface SearchExtension {
id: string
type: 'search'
scopes?: ExtensionScope[]
extensionPointIds?: string[]
searchProvider: {
id: string
available: boolean
Expand All @@ -34,7 +34,7 @@ interface SearchExtension {
}
```

For `id`, `type`, and `scopes`, please see [extension base section]({{< ref "../_index.md#extension-base-configuration" >}}) in top level docs.
For `id`, `type`, and `extensionPointIds`, please see [extension base section]({{< ref "../_index.md#extension-base-configuration" >}}) in top level docs.

The `searchProvider` object configures the actual provider. It consist of the following:

Expand Down

0 comments on commit 9f04956

Please sign in to comment.