V15: Workspace buttons cannot be overwritten in all cases (#18525)
* fix: consider that overwrites can be strings OR arrays * chore: formatting * chore(mock): use correct javascript for mock plugins * chore: uses intersection helper method to save on code * fix: should work without requesting extra update to the the extensions controller refreshing the state
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
export const manifests: Array<UmbExtensionManifest> = [
|
||||
export const manifests = [
|
||||
{
|
||||
type: 'section',
|
||||
alias: 'MyBundle.Section.Custom',
|
||||
name: 'Custom Section',
|
||||
js: '/App_Plugins/section.js',
|
||||
element: () => import('./section.js'),
|
||||
weight: 1,
|
||||
meta: {
|
||||
label: 'My Bundle Section',
|
||||
|
||||
@@ -27,34 +27,32 @@ export class UmbWorkspaceActionMenuElement extends UmbLitElement {
|
||||
}
|
||||
|
||||
override render() {
|
||||
return this.items?.length
|
||||
? html`
|
||||
<uui-button
|
||||
id="popover-trigger"
|
||||
popovertarget="workspace-action-popover"
|
||||
look="${this.look}"
|
||||
color="${this.color}"
|
||||
label=${this.localize.term('visuallyHiddenTexts_tabExpand')}
|
||||
compact>
|
||||
<uui-symbol-expand id="expand-symbol" .open=${this._popoverOpen}></uui-symbol-expand>
|
||||
</uui-button>
|
||||
<uui-popover-container
|
||||
id="workspace-action-popover"
|
||||
margin="6"
|
||||
placement="top-end"
|
||||
@toggle=${this.#onPopoverToggle}>
|
||||
<umb-popover-layout>
|
||||
<uui-scroll-container>
|
||||
${repeat(
|
||||
this.items,
|
||||
(ext) => ext.alias,
|
||||
(ext) => ext.component,
|
||||
)}
|
||||
</uui-scroll-container>
|
||||
</umb-popover-layout>
|
||||
</uui-popover-container>
|
||||
`
|
||||
: nothing;
|
||||
if (!this.items?.length) return nothing;
|
||||
|
||||
return html`<uui-button
|
||||
id="popover-trigger"
|
||||
popovertarget="workspace-action-popover"
|
||||
look="${this.look}"
|
||||
color="${this.color}"
|
||||
label=${this.localize.term('visuallyHiddenTexts_tabExpand')}
|
||||
compact>
|
||||
<uui-symbol-expand id="expand-symbol" .open=${this._popoverOpen}></uui-symbol-expand>
|
||||
</uui-button>
|
||||
<uui-popover-container
|
||||
id="workspace-action-popover"
|
||||
margin="6"
|
||||
placement="top-end"
|
||||
@toggle=${this.#onPopoverToggle}>
|
||||
<umb-popover-layout>
|
||||
<uui-scroll-container>
|
||||
${repeat(
|
||||
this.items,
|
||||
(ext) => ext.alias,
|
||||
(ext) => ext.component,
|
||||
)}
|
||||
</uui-scroll-container>
|
||||
</umb-popover-layout>
|
||||
</uui-popover-container>`;
|
||||
}
|
||||
|
||||
static override styles = [
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
type UmbExtensionElementAndApiInitializer,
|
||||
UmbExtensionsElementAndApiInitializer,
|
||||
} from '@umbraco-cms/backoffice/extension-api';
|
||||
import { stringOrStringArrayIntersects } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
import '../../workspace-action-menu/index.js';
|
||||
|
||||
@@ -38,7 +39,6 @@ export class UmbWorkspaceActionElement<
|
||||
this._href = value?.meta.href;
|
||||
this._additionalOptions = value?.meta.additionalOptions;
|
||||
this.#createAliases();
|
||||
this.requestUpdate('manifest', oldValue);
|
||||
}
|
||||
}
|
||||
public get manifest() {
|
||||
@@ -90,7 +90,10 @@ export class UmbWorkspaceActionElement<
|
||||
// TODO: This works on one level for now, which will be enough for the current use case. However, you can overwrite the overwrites, so we need to make this recursive. Perhaps we could move this to the extensions initializer.
|
||||
// Add overwrites so that we can show any previously registered actions on the original workspace action
|
||||
if (this.#manifest.overwrites) {
|
||||
for (const alias of this.#manifest.overwrites) {
|
||||
const overwrites = Array.isArray(this.#manifest.overwrites)
|
||||
? this.#manifest.overwrites
|
||||
: [this.#manifest.overwrites];
|
||||
for (const alias of overwrites) {
|
||||
aliases.add(alias);
|
||||
}
|
||||
}
|
||||
@@ -145,11 +148,7 @@ export class UmbWorkspaceActionElement<
|
||||
umbExtensionsRegistry,
|
||||
'workspaceActionMenuItem',
|
||||
ExtensionApiArgsMethod,
|
||||
(action) => {
|
||||
return Array.isArray(action.forWorkspaceActions)
|
||||
? action.forWorkspaceActions.some((alias) => aliases.includes(alias))
|
||||
: aliases.includes(action.forWorkspaceActions);
|
||||
},
|
||||
(action) => stringOrStringArrayIntersects(action.forWorkspaceActions, aliases),
|
||||
(extensionControllers) => {
|
||||
this._items = extensionControllers;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user