remove element from create action option manifest
This commit is contained in:
committed by
Niels Lyngsø
parent
69958b4370
commit
340dff742c
@@ -1,87 +0,0 @@
|
||||
import type { UmbEntityCreateOptionAction } from '../entity-create-option-action.interface.js';
|
||||
import type { UmbEntityCreateOptionActionElement } from '../entity-create-option-action-element.interface.js';
|
||||
import type { ManifestEntityCreateOptionAction } from '../entity-create-option-action.extension.js';
|
||||
import type { MetaEntityCreateOptionActionDefaultKind } from './types.js';
|
||||
import { UmbActionExecutedEvent } from '@umbraco-cms/backoffice/event';
|
||||
import { html, nothing, ifDefined, customElement, property, state } from '@umbraco-cms/backoffice/external/lit';
|
||||
import type { UUIMenuItemEvent } from '@umbraco-cms/backoffice/external/uui';
|
||||
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
|
||||
|
||||
const elementName = 'umb-entity-create-option-action';
|
||||
@customElement(elementName)
|
||||
export class UmbEntityCreateOptionActionDefaultElement<
|
||||
MetaType extends MetaEntityCreateOptionActionDefaultKind = MetaEntityCreateOptionActionDefaultKind,
|
||||
ApiType extends UmbEntityCreateOptionAction<MetaType> = UmbEntityCreateOptionAction<MetaType>,
|
||||
>
|
||||
extends UmbLitElement
|
||||
implements UmbEntityCreateOptionActionElement
|
||||
{
|
||||
#api?: ApiType;
|
||||
|
||||
// TODO: Do these need to be properties? [NL]
|
||||
@property({ type: String })
|
||||
entityType?: string | null;
|
||||
|
||||
// TODO: Do these need to be properties? [NL]
|
||||
@property({ type: String })
|
||||
public unique?: string | null;
|
||||
|
||||
@property({ attribute: false })
|
||||
public manifest?: ManifestEntityCreateOptionAction<MetaType>;
|
||||
|
||||
public set api(api: ApiType | undefined) {
|
||||
this.#api = api;
|
||||
|
||||
// TODO: Fix so when we use a HREF it does not refresh the page?
|
||||
this.#api?.getHref?.().then((href) => {
|
||||
this._href = href;
|
||||
// TODO: Do we need to update the component here? [NL]
|
||||
});
|
||||
}
|
||||
|
||||
@state()
|
||||
_href?: string;
|
||||
|
||||
override async focus() {
|
||||
await this.updateComplete;
|
||||
this.shadowRoot?.querySelector('uui-menu-item')?.focus();
|
||||
}
|
||||
|
||||
async #onClickLabel(event: UUIMenuItemEvent) {
|
||||
if (!this._href) {
|
||||
event.stopPropagation();
|
||||
await this.#api?.execute();
|
||||
}
|
||||
this.dispatchEvent(new UmbActionExecutedEvent());
|
||||
}
|
||||
|
||||
// TODO: we need to stop the regular click event from bubbling up to the table so it doesn't select the row.
|
||||
// This should probably be handled in the UUI Menu item component. so we don't dispatch a label-click event and click event at the same time.
|
||||
#onClick(event: PointerEvent) {
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
override render() {
|
||||
const label = this.manifest?.meta.label ? this.localize.string(this.manifest.meta.label) : this.manifest?.name;
|
||||
|
||||
return html`
|
||||
<uui-menu-item
|
||||
label=${ifDefined(this.manifest?.meta.additionalOptions ? label + '...' : label)}
|
||||
href=${ifDefined(this._href)}
|
||||
@click-label=${this.#onClickLabel}
|
||||
@click=${this.#onClick}>
|
||||
${this.manifest?.meta.icon
|
||||
? html`<umb-icon slot="icon" name="${this.manifest?.meta.icon}"></umb-icon>`
|
||||
: nothing}
|
||||
</uui-menu-item>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
export { UmbEntityCreateOptionActionDefaultElement as element };
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
[elementName]: UmbEntityCreateOptionActionDefaultElement;
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export * from './types.js';
|
||||
@@ -1,20 +0,0 @@
|
||||
import type { UmbExtensionManifestKind } from '@umbraco-cms/backoffice/extension-registry';
|
||||
|
||||
export const manifests: Array<UmbExtensionManifest | UmbExtensionManifestKind> = [
|
||||
{
|
||||
type: 'kind',
|
||||
alias: 'Umb.Kind.EntityCreateOptionAction.Default',
|
||||
matchKind: 'default',
|
||||
matchType: 'entityCreateOptionAction',
|
||||
manifest: {
|
||||
type: 'entityCreateOptionAction',
|
||||
kind: 'default',
|
||||
weight: 1000,
|
||||
element: () => import('./entity-create-option-action.element.js'),
|
||||
meta: {
|
||||
icon: '',
|
||||
label: 'Default Entity Create Option Action',
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -1,44 +0,0 @@
|
||||
import type {
|
||||
ManifestEntityCreateOptionAction,
|
||||
MetaEntityCreateOptionAction,
|
||||
} from '../entity-create-option-action.extension.js';
|
||||
|
||||
export interface ManifestEntityCreateOptionActionDefaultKind
|
||||
extends ManifestEntityCreateOptionAction<MetaEntityCreateOptionActionDefaultKind> {
|
||||
type: 'entityCreateOptionAction';
|
||||
kind: 'default';
|
||||
}
|
||||
|
||||
export interface MetaEntityCreateOptionActionDefaultKind extends MetaEntityCreateOptionAction {
|
||||
/**
|
||||
* An icon to represent the action to be performed
|
||||
* @examples [
|
||||
* "icon-box",
|
||||
* "icon-grid"
|
||||
* ]
|
||||
*/
|
||||
icon: string;
|
||||
|
||||
/**
|
||||
* The friendly name of the action to perform
|
||||
* @examples [
|
||||
* "Create",
|
||||
* "Create Content Template"
|
||||
* ]
|
||||
*/
|
||||
label: string;
|
||||
|
||||
/**
|
||||
* The action requires additional input from the user.
|
||||
* A dialog will prompt the user for more information or to make a choice.
|
||||
* @type {boolean}
|
||||
* @memberof MetaEntityCreateOptionActionDefaultKind
|
||||
*/
|
||||
additionalOptions?: boolean;
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface UmbExtensionManifestMap {
|
||||
umbDefaultEntityCreateOptionActionKind: ManifestEntityCreateOptionActionDefaultKind;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
||||
export interface UmbEntityCreateOptionActionElement extends UmbControllerHostElement {}
|
||||
@@ -1,9 +1,9 @@
|
||||
import type { UmbEntityCreateOptionAction } from './entity-create-option-action.interface.js';
|
||||
import type { ManifestElementAndApi, ManifestWithDynamicConditions } from '@umbraco-cms/backoffice/extension-api';
|
||||
import type { ManifestApi, ManifestWithDynamicConditions } from '@umbraco-cms/backoffice/extension-api';
|
||||
|
||||
export interface ManifestEntityCreateOptionAction<
|
||||
MetaType extends MetaEntityCreateOptionAction = MetaEntityCreateOptionAction,
|
||||
> extends ManifestElementAndApi<any, UmbEntityCreateOptionAction<unknown>>,
|
||||
> extends ManifestApi<UmbEntityCreateOptionAction<unknown>>,
|
||||
ManifestWithDynamicConditions<UmbExtensionConditionConfig> {
|
||||
type: 'entityCreateOptionAction';
|
||||
forEntityTypes: Array<string>;
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
import './global-components/index.js';
|
||||
|
||||
export * from './default/index.js';
|
||||
export * from './global-components/index.js';
|
||||
|
||||
export * from './entity-create-option-action-base.js';
|
||||
export * from './entity-create-option-action.extension.js';
|
||||
export * from './entity-create-option-action.interface.js';
|
||||
|
||||
export type * from './entity-create-option-action-element.interface.js';
|
||||
|
||||
export * from './types.js';
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
import { manifests as defaultManifests } from './default/manifests.js';
|
||||
import type { UmbExtensionManifestKind } from '@umbraco-cms/backoffice/extension-registry';
|
||||
|
||||
export const manifests: Array<UmbExtensionManifest | UmbExtensionManifestKind> = [...defaultManifests];
|
||||
@@ -23,7 +23,7 @@ export class UmbCreateEntityAction extends UmbEntityActionBase<MetaEntityActionC
|
||||
async (actionOptions) => {
|
||||
this.#hasSingleOption = actionOptions.length === 1;
|
||||
this.#singleActionOptionManifest = this.#hasSingleOption
|
||||
? (actionOptions[0].manifest as ManifestEntityCreateOptionAction)
|
||||
? (actionOptions[0].manifest as unknown as ManifestEntityCreateOptionAction)
|
||||
: undefined;
|
||||
},
|
||||
'umbEntityActionsObserver',
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { manifest as createKindManifest } from './create.action.kind.js';
|
||||
import { manifests as modalManifests } from './modal/manifests.js';
|
||||
import { manifests as createOptionActionManifests } from './create-option-action/manifests.js';
|
||||
|
||||
export const manifests = [createKindManifest, ...modalManifests, ...createOptionActionManifests];
|
||||
export const manifests = [createKindManifest, ...modalManifests];
|
||||
|
||||
Reference in New Issue
Block a user