add unregister extension entity action
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
import { manifests as unregisterManifests } from './unregister/manifests.js';
|
||||
|
||||
export const manifests = [...unregisterManifests];
|
||||
@@ -0,0 +1,16 @@
|
||||
import { UMB_EXTENSION_ENTITY_TYPE } from '../../entity.js';
|
||||
|
||||
export const manifests = [
|
||||
{
|
||||
type: 'entityAction',
|
||||
kind: 'default',
|
||||
alias: 'Umb.EntityAction.Extension.Unregister',
|
||||
name: 'Unregister Extension Entity Action',
|
||||
api: () => import('./unregister-extension.action.js'),
|
||||
forEntityTypes: [UMB_EXTENSION_ENTITY_TYPE],
|
||||
meta: {
|
||||
label: 'Unregister',
|
||||
icon: 'icon-trash',
|
||||
},
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,33 @@
|
||||
import { umbExtensionsRegistry } from '../../registry.js';
|
||||
import { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action';
|
||||
import { UmbEntityActionBase, UmbRequestReloadStructureForEntityEvent } from '@umbraco-cms/backoffice/entity-action';
|
||||
import { umbConfirmModal } from '@umbraco-cms/backoffice/modal';
|
||||
import { html } from '@umbraco-cms/backoffice/external/lit';
|
||||
|
||||
export class UmbUnregisterExtensionEntityAction extends UmbEntityActionBase<unknown> {
|
||||
async execute() {
|
||||
if (!this.args.unique) throw new Error('Cannot delete an item without a unique identifier.');
|
||||
|
||||
const extension = umbExtensionsRegistry.getByAlias(this.args.unique);
|
||||
if (!extension) throw new Error('Extension not found');
|
||||
|
||||
await umbConfirmModal(this, {
|
||||
headline: 'Unregister extension',
|
||||
confirmLabel: 'Unregister',
|
||||
content: html`<p>Are you sure you want to unregister the extension <strong>${extension.alias}</strong>?</p>`,
|
||||
color: 'danger',
|
||||
});
|
||||
|
||||
umbExtensionsRegistry.unregister(extension.alias);
|
||||
|
||||
const actionEventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT);
|
||||
const event = new UmbRequestReloadStructureForEntityEvent({
|
||||
unique: this.args.unique,
|
||||
entityType: this.args.entityType,
|
||||
});
|
||||
|
||||
actionEventContext.dispatchEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
export { UmbUnregisterExtensionEntityAction as api };
|
||||
@@ -2,6 +2,7 @@ import { manifests as conditionManifests } from './conditions/manifests.js';
|
||||
import { manifests as menuItemManifests } from './menu-item/manifests.js';
|
||||
import { manifests as workspaceManifests } from './workspace/manifests.js';
|
||||
import { manifests as collectionManifests } from './collection/manifests.js';
|
||||
import { manifests as entityActionManifests } from './entity-actions/manifests.js';
|
||||
import type { ManifestTypes } from './models/index.js';
|
||||
|
||||
export const manifests: Array<ManifestTypes> = [
|
||||
@@ -9,4 +10,5 @@ export const manifests: Array<ManifestTypes> = [
|
||||
...menuItemManifests,
|
||||
...workspaceManifests,
|
||||
...collectionManifests,
|
||||
...entityActionManifests,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user