From 5e1f7aba21f04e8c0e8b640dc6dee4085e1c4d00 Mon Sep 17 00:00:00 2001 From: leekelleher Date: Tue, 13 Feb 2024 10:07:20 +0000 Subject: [PATCH] Added stubs for bulk entity actions: Publish, Unpublish and Delete. --- .../delete/delete.action.ts | 14 ++++ .../entity-bulk-actions/manifests.ts | 79 +++++++++++++++---- .../publish/publish.action.ts | 14 ++++ .../unpublish/unpublish.action.ts | 14 ++++ 4 files changed, 105 insertions(+), 16 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-bulk-actions/delete/delete.action.ts create mode 100644 src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-bulk-actions/publish/publish.action.ts create mode 100644 src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-bulk-actions/unpublish/unpublish.action.ts diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-bulk-actions/delete/delete.action.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-bulk-actions/delete/delete.action.ts new file mode 100644 index 0000000000..bbbf974046 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-bulk-actions/delete/delete.action.ts @@ -0,0 +1,14 @@ +import type { UmbDocumentDetailRepository } from '../../repository/index.js'; +import { UmbEntityBulkActionBase } from '@umbraco-cms/backoffice/entity-bulk-action'; +import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; + +export class UmbDocumentDeleteEntityBulkAction extends UmbEntityBulkActionBase { + constructor(host: UmbControllerHostElement, repositoryAlias: string, selection: Array) { + super(host, repositoryAlias, selection); + } + + async execute() { + console.log(`execute delete for: ${this.selection}`); + //await this.repository?.delete(); + } +} diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-bulk-actions/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-bulk-actions/manifests.ts index fbb310371e..7f17133672 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-bulk-actions/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-bulk-actions/manifests.ts @@ -1,28 +1,44 @@ import { UMB_DOCUMENT_DETAIL_REPOSITORY_ALIAS } from '../repository/index.js'; import { UMB_DOCUMENT_COLLECTION_ALIAS } from '../collection/index.js'; -import { UmbDocumentMoveEntityBulkAction } from './move/move.action.js'; import { UmbDocumentCopyEntityBulkAction } from './copy/copy.action.js'; +import { UmbDocumentDeleteEntityBulkAction } from './delete/delete.action.js'; +import { UmbDocumentMoveEntityBulkAction } from './move/move.action.js'; +import { UmbDocumentPublishEntityBulkAction } from './publish/publish.action.js'; +import { UmbDocumentUnpublishEntityBulkAction } from './unpublish/unpublish.action.js'; import type { ManifestEntityBulkAction } from '@umbraco-cms/backoffice/extension-registry'; import { UMB_COLLECTION_ALIAS_CONDITION } from '@umbraco-cms/backoffice/collection'; -const entityActions: Array = [ - - // TODO: [LK] Add bulk entity actions for Publish, Unpublish and Delete. - // TODO: [LK] Wondering how these actions could be wired up to the `bulkActionPermissions` config? - +// TODO: [LK] Wondering how these actions could be wired up to the `bulkActionPermissions` config? +export const manifests: Array = [ { type: 'entityBulkAction', - alias: 'Umb.EntityBulkAction.Document.Move', - name: 'Move Document Entity Bulk Action', - weight: 10, - api: UmbDocumentMoveEntityBulkAction, + alias: 'Umb.EntityBulkAction.Document.Publish', + name: 'Publish Document Entity Bulk Action', + weight: 50, + api: UmbDocumentPublishEntityBulkAction, meta: { - label: 'Move', + label: 'Publish', + repositoryAlias: UMB_DOCUMENT_DETAIL_REPOSITORY_ALIAS, + }, + conditions: [ + { + alias: UMB_COLLECTION_ALIAS_CONDITION, + match: UMB_DOCUMENT_COLLECTION_ALIAS, + }, + ], + }, + { + type: 'entityBulkAction', + alias: 'Umb.EntityBulkAction.Document.Unpublish', + name: 'Unpublish Document Entity Bulk Action', + weight: 40, + api: UmbDocumentUnpublishEntityBulkAction, + meta: { + label: 'Unpublish', repositoryAlias: UMB_DOCUMENT_DETAIL_REPOSITORY_ALIAS, }, conditions: [ { - // TODO: this condition should be based on entity types in the selection alias: UMB_COLLECTION_ALIAS_CONDITION, match: UMB_DOCUMENT_COLLECTION_ALIAS, }, @@ -32,7 +48,7 @@ const entityActions: Array = [ type: 'entityBulkAction', alias: 'Umb.EntityBulkAction.Document.Copy', name: 'Copy Document Entity Bulk Action', - weight: 9, + weight: 30, api: UmbDocumentCopyEntityBulkAction, meta: { label: 'Copy', @@ -40,12 +56,43 @@ const entityActions: Array = [ }, conditions: [ { - // TODO: this condition should be based on entity types in the selection + alias: UMB_COLLECTION_ALIAS_CONDITION, + match: UMB_DOCUMENT_COLLECTION_ALIAS, + }, + ], + }, + { + type: 'entityBulkAction', + alias: 'Umb.EntityBulkAction.Document.Move', + name: 'Move Document Entity Bulk Action', + weight: 20, + api: UmbDocumentMoveEntityBulkAction, + meta: { + label: 'Move', + repositoryAlias: UMB_DOCUMENT_DETAIL_REPOSITORY_ALIAS, + }, + conditions: [ + { + alias: UMB_COLLECTION_ALIAS_CONDITION, + match: UMB_DOCUMENT_COLLECTION_ALIAS, + }, + ], + }, + { + type: 'entityBulkAction', + alias: 'Umb.EntityBulkAction.Document.Delete', + name: 'Delete Document Entity Bulk Action', + weight: 10, + api: UmbDocumentDeleteEntityBulkAction, + meta: { + label: 'Delete', + repositoryAlias: UMB_DOCUMENT_DETAIL_REPOSITORY_ALIAS, + }, + conditions: [ + { alias: UMB_COLLECTION_ALIAS_CONDITION, match: UMB_DOCUMENT_COLLECTION_ALIAS, }, ], }, ]; - -export const manifests = [...entityActions]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-bulk-actions/publish/publish.action.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-bulk-actions/publish/publish.action.ts new file mode 100644 index 0000000000..c20657de25 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-bulk-actions/publish/publish.action.ts @@ -0,0 +1,14 @@ +import type { UmbDocumentDetailRepository } from '../../repository/index.js'; +import { UmbEntityBulkActionBase } from '@umbraco-cms/backoffice/entity-bulk-action'; +import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; + +export class UmbDocumentPublishEntityBulkAction extends UmbEntityBulkActionBase { + constructor(host: UmbControllerHostElement, repositoryAlias: string, selection: Array) { + super(host, repositoryAlias, selection); + } + + async execute() { + console.log(`execute publish for: ${this.selection}`); + //await this.repository?.publish(); + } +} diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-bulk-actions/unpublish/unpublish.action.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-bulk-actions/unpublish/unpublish.action.ts new file mode 100644 index 0000000000..03e9d01c7a --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/entity-bulk-actions/unpublish/unpublish.action.ts @@ -0,0 +1,14 @@ +import type { UmbDocumentDetailRepository } from '../../repository/index.js'; +import { UmbEntityBulkActionBase } from '@umbraco-cms/backoffice/entity-bulk-action'; +import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; + +export class UmbDocumentUnpublishEntityBulkAction extends UmbEntityBulkActionBase { + constructor(host: UmbControllerHostElement, repositoryAlias: string, selection: Array) { + super(host, repositoryAlias, selection); + } + + async execute() { + console.log(`execute unpublish for: ${this.selection}`); + //await this.repository?.unpublish(); + } +}