Skip to content

Commit

Permalink
Merge pull request #2389 from umbraco/v15/feature/emm-entity-actions
Browse files Browse the repository at this point in the history
Extension Manifest Map: Entity Actions
  • Loading branch information
nielslyngsoe authored Oct 1, 2024
2 parents 776a414 + 8cebdcc commit e9d70b2
Show file tree
Hide file tree
Showing 48 changed files with 327 additions and 248 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { UmbEntityContext } from '../../entity/entity.context.js';
import type { UmbEntityAction } from '@umbraco-cms/backoffice/entity-action';
import type { UmbEntityAction, ManifestEntityActionDefaultKind } from '@umbraco-cms/backoffice/entity-action';
import type { PropertyValueMap } from '@umbraco-cms/backoffice/external/lit';
import { html, nothing, customElement, property, state, ifDefined } from '@umbraco-cms/backoffice/external/lit';
import type { UmbSectionSidebarContext } from '@umbraco-cms/backoffice/section';
import { UMB_SECTION_SIDEBAR_CONTEXT } from '@umbraco-cms/backoffice/section';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import type { ManifestEntityActionDefaultKind } from '@umbraco-cms/backoffice/extension-registry';
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
import { UmbExtensionsManifestInitializer, createExtensionApi } from '@umbraco-cms/backoffice/extension-api';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { UmbEntityActionBase } from '../../entity-action-base.js';
import { UmbRequestReloadStructureForEntityEvent } from '../../request-reload-structure-for-entity.event.js';
import { createExtensionApiByAlias, type MetaEntityActionDeleteKind } from '@umbraco-cms/backoffice/extension-registry';
import type { MetaEntityActionDeleteKind } from './types.js';
import { createExtensionApiByAlias } from '@umbraco-cms/backoffice/extension-registry';
import { umbConfirmModal } from '@umbraco-cms/backoffice/modal';
import type { UmbDetailRepository, UmbItemRepository } from '@umbraco-cms/backoffice/repository';
import { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action';
Expand Down
18 changes: 18 additions & 0 deletions src/packages/core/entity-action/common/delete/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { MetaEntityActionDefaultKind } from '../../default/index.js';
import type { ManifestEntityAction } from '../../entity-action.extension.js';

export interface ManifestEntityActionDeleteKind extends ManifestEntityAction<MetaEntityActionDeleteKind> {
type: 'entityAction';
kind: 'delete';
}

export interface MetaEntityActionDeleteKind extends MetaEntityActionDefaultKind {
detailRepositoryAlias: string;
itemRepositoryAlias: string;
}

declare global {
interface UmbExtensionManifestMap {
umbDeleteEntityActionKind: ManifestEntityActionDeleteKind;
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { UmbEntityActionBase } from '../../entity-action-base.js';
import { UmbRequestReloadStructureForEntityEvent } from '../../request-reload-structure-for-entity.event.js';
import type { UmbDuplicateRepository } from './duplicate-repository.interface.js';
import type { MetaEntityActionDuplicateToKind } from '@umbraco-cms/backoffice/extension-registry';
import { createExtensionApiByAlias } from '@umbraco-cms/backoffice/extension-registry';
import { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action';

export class UmbDuplicateEntityAction extends UmbEntityActionBase<MetaEntityActionDuplicateToKind> {
export class UmbDuplicateEntityAction extends UmbEntityActionBase<any> {
override async execute() {
if (!this.args.unique) throw new Error('Unique is not available');
if (!this.args.entityType) throw new Error('Entity Type is not available');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import type { UmbEntityAction } from '../entity-action.interface.js';
import type { UmbEntityActionElement } from '../entity-action-element.interface.js';
import type { ManifestEntityAction } from '../entity-action.extension.js';
import type { MetaEntityActionDefaultKind } 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';
import type { ManifestEntityAction, MetaEntityActionDefaultKind } from '@umbraco-cms/backoffice/extension-registry';

@customElement('umb-entity-action')
export class UmbEntityActionDefaultElement<
Expand Down
1 change: 1 addition & 0 deletions src/packages/core/entity-action/default/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './types.js';
40 changes: 40 additions & 0 deletions src/packages/core/entity-action/default/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import type { ManifestEntityAction, MetaEntityAction } from '../entity-action.extension.js';

export interface ManifestEntityActionDefaultKind extends ManifestEntityAction<MetaEntityActionDefaultKind> {
type: 'entityAction';
kind: 'default';
}

export interface MetaEntityActionDefaultKind extends MetaEntityAction {
/**
* 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 MetaEntityActionDefaultKind
*/
additionalOptions?: boolean;
}

declare global {
interface UmbExtensionManifestMap {
umbDefaultEntityActionKind: ManifestEntityActionDefaultKind;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { UmbEntityActionArgs } from './types.js';
import type { ManifestEntityAction, MetaEntityAction } from './entity-action.extension.js';
import { UmbEntityContext } from '@umbraco-cms/backoffice/entity';
import { html, customElement, property, state, css } from '@umbraco-cms/backoffice/external/lit';
import type { ManifestEntityAction, MetaEntityAction } from '@umbraco-cms/backoffice/extension-registry';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import type { UmbApiConstructorArgumentsMethodType } from '@umbraco-cms/backoffice/extension-api';

Expand Down
23 changes: 23 additions & 0 deletions src/packages/core/entity-action/entity-action.extension.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { ManifestElementAndApi, ManifestWithDynamicConditions } from '@umbraco-cms/backoffice/extension-api';
import type { UmbEntityAction, UmbEntityActionElement } from '@umbraco-cms/backoffice/entity-action';

/**
* An action to perform on an entity
* For example for content you may wish to create a new document etc
*/
export interface ManifestEntityAction<MetaType extends MetaEntityAction = MetaEntityAction>
extends ManifestElementAndApi<UmbEntityActionElement, UmbEntityAction<MetaType>>,
ManifestWithDynamicConditions<UmbExtensionCondition> {
type: 'entityAction';
forEntityTypes: Array<string>;
meta: MetaType;
}

// eslint-disable-next-line @typescript-eslint/no-empty-object-type
export interface MetaEntityAction {}

declare global {
interface UmbExtensionManifestMap {
umbEntityAction: ManifestEntityAction;
}
}
2 changes: 2 additions & 0 deletions src/packages/core/entity-action/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export * from './common/index.js';
export * from './default/index.js';
export * from './entity-action-base.js';
export * from './entity-action-list.element.js';
export * from './entity-action.event.js';
export * from './entity-action.extension.js';
export * from './entity-action.interface.js';
export * from './types.js';
export type * from './entity-action-element.interface.js';
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion src/packages/core/extension-registry/extensions/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export type * from './app-entry-point.extension.js';
export type * from './backoffice-entry-point.extension.js';
export type * from './entity-action.extension.js';
export type * from './entity-bulk-action.extension.js';
export type * from './entry-point.extension.js';
export type * from './external-login-provider-element.interface.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { UmbEntityActionBase } from '../../../entity-action/entity-action-base.js';
import type { UmbRecycleBinRepository } from '../../recycle-bin-repository.interface.js';
import type { MetaEntityActionEmptyRecycleBinKind } from './types.js';
import { umbConfirmModal } from '@umbraco-cms/backoffice/modal';
import {
createExtensionApiByAlias,
type MetaEntityActionEmptyRecycleBinKind,
} from '@umbraco-cms/backoffice/extension-registry';
import { createExtensionApiByAlias } from '@umbraco-cms/backoffice/extension-registry';
import { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action';
import { UmbRequestReloadChildrenOfEntityEvent } from '@umbraco-cms/backoffice/entity-action';
import { UmbEntityActionBase, UmbRequestReloadChildrenOfEntityEvent } from '@umbraco-cms/backoffice/entity-action';

/**
* Entity action for emptying the recycle bin.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './types.js';
export * from './empty-recycle-bin.action.js';
Loading

0 comments on commit e9d70b2

Please sign in to comment.