Added stubs for bulk entity actions: Publish, Unpublish and Delete.

This commit is contained in:
leekelleher
2024-02-13 10:07:20 +00:00
parent d6bc1b859f
commit 5e1f7aba21
4 changed files with 105 additions and 16 deletions

View File

@@ -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<UmbDocumentDetailRepository> {
constructor(host: UmbControllerHostElement, repositoryAlias: string, selection: Array<string>) {
super(host, repositoryAlias, selection);
}
async execute() {
console.log(`execute delete for: ${this.selection}`);
//await this.repository?.delete();
}
}

View File

@@ -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<ManifestEntityBulkAction> = [
// 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<ManifestEntityBulkAction> = [
{
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<ManifestEntityBulkAction> = [
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<ManifestEntityBulkAction> = [
},
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];

View File

@@ -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<UmbDocumentDetailRepository> {
constructor(host: UmbControllerHostElement, repositoryAlias: string, selection: Array<string>) {
super(host, repositoryAlias, selection);
}
async execute() {
console.log(`execute publish for: ${this.selection}`);
//await this.repository?.publish();
}
}

View File

@@ -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<UmbDocumentDetailRepository> {
constructor(host: UmbControllerHostElement, repositoryAlias: string, selection: Array<string>) {
super(host, repositoryAlias, selection);
}
async execute() {
console.log(`execute unpublish for: ${this.selection}`);
//await this.repository?.unpublish();
}
}