Skip to content

Commit

Permalink
refactor: rename files scope to resource
Browse files Browse the repository at this point in the history
  • Loading branch information
kulmann committed Dec 6, 2023
1 parent 9a9e182 commit e97bc86
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,7 @@ export default defineComponent({
const extensionActions = computed(() => {
return [
...extensionRegistry
.requestExtensions<ActionExtension>('action')
.filter(({ scopes }) => scopes.includes('upload-menu'))
.requestExtensions<ActionExtension>('action', ['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,8 +39,7 @@ export default defineComponent({
const filteredActions = computed(() => {
return unref(extensionRegistry)
.requestExtensions<ActionExtension>('action')
.filter(({ scopes }) => scopes.includes('files.quick-action'))
.requestExtensions<ActionExtension>('action', ['resource.quick-action'])
.map((e) => e.action)
.filter(({ isEnabled }) => isEnabled({ space: props.space, resources: [props.item] }))
})
Expand Down
4 changes: 2 additions & 2 deletions packages/web-app-files/src/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ export const extensions = ({ applicationConfig }: ApplicationSetupOptions) => {
},
{
id: 'com.github.owncloud.web.files.quick-action.collaborator',
scopes: ['files', 'files.quick-action'],
scopes: ['resource', 'resource.quick-action'],
type: 'action',
action: unref(showSharesActions)[0]
},
{
id: 'com.github.owncloud.web.files.quick-action.quicklink',
scopes: ['files', 'files.quick-action'],
scopes: ['resource', 'resource.quick-action'],
type: 'action',
action: unref(quickLinkActions)[0]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ function getWrapper({ embedModeEnabled = false } = {}) {
useExtensionRegistryMock({
requestExtensions: () =>
[
mock<ActionExtension>({ scopes: ['files.quick-action'], action: collaboratorAction }),
mock<ActionExtension>({ scopes: ['files.quick-action'], action: quicklinkAction })
mock<ActionExtension>({ scopes: ['resource.quick-action'], action: collaboratorAction }),
mock<ActionExtension>({ scopes: ['resource.quick-action'], action: quicklinkAction })
] as any
})
)
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-importer/src/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const extensions = ({ applicationConfig }: ApplicationSetupOptions) => {
{
id: 'com.github.owncloud.web.import-file',
type: 'action',
scopes: ['files', 'upload-menu'],
scopes: ['resource', 'upload-menu'],
action: {
name: 'import-files',
icon: 'cloud',
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-ocm/src/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const extensions = (options: ApplicationSetupOptions) => {
{
id: 'com.github.owncloud.web.open-file-remote',
type: 'action',
scopes: ['files', 'files.context-menu'],
scopes: ['resource', 'resource.context-menu'],
action: {
name: 'open-file-remote',
icon: 'remote-control',
Expand Down
3 changes: 1 addition & 2 deletions packages/web-pkg/src/components/FilesList/ContextActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ export default defineComponent({
const extensionRegistry = useExtensionRegistry()
const extensionContextActions = computed(() => {
return extensionRegistry
.requestExtensions<ActionExtension>('action')
.filter(({ scopes }) => scopes.includes('files.context-menu'))
.requestExtensions<ActionExtension>('action', ['resource.context-menu'])
.map((e) => e.action)
})
Expand Down
2 changes: 1 addition & 1 deletion packages/web-pkg/src/components/SideBar/FileSideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export default defineComponent({
const availablePanels = computed(() =>
extensionRegistry
.requestExtensions<SidebarPanelExtension<Resource, Resource>>('sidebarPanel', 'resource')
.requestExtensions<SidebarPanelExtension<Resource, Resource>>('sidebarPanel', ['resource'])
.map((e) => e.panel)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ export const useExtensionRegistry = ({
getters: {
requestExtensions:
(state) =>
<ExtensionType extends Extension>(type: string, scope?: string) => {
<ExtensionType extends Extension>(type: string, scopes?: string[]) => {
return state.extensions
.map((e) =>
unref(e).filter(
(e) =>
e.type === type &&
!options.disabledExtensions.includes(e.id) &&
(!scope || e.scopes?.includes(scope))
(!scopes || e.scopes?.some((s) => scopes.includes(s)))
)
)
.flat() as ExtensionType[]
Expand Down
5 changes: 4 additions & 1 deletion packages/web-runtime/src/layouts/Application.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ export default defineComponent({
const extensionNavItems = computed(() =>
extensionRegistry
.requestExtensions<SidebarNavExtension>('sidebarNav', unref(activeApp))
.requestExtensions<SidebarNavExtension>('sidebarNav', [
unref(activeApp),
`app.${unref(activeApp)}`
])
.map(({ navItem }) => navItem)
.filter((n) => n.enabled(store.getters.capabilities))
)
Expand Down

0 comments on commit e97bc86

Please sign in to comment.