update more entity actions

This commit is contained in:
Mads Rasmussen
2024-03-03 16:25:34 +01:00
parent 7996ce0a39
commit 79427d7b7c
5 changed files with 21 additions and 17 deletions

View File

@@ -1,14 +1,16 @@
import type { UmbDocumentDetailRepository } from '../repository/index.js';
import type { UmbEntityActionArgs } from '@umbraco-cms/backoffice/entity-action';
import { UmbEntityActionBase } from '@umbraco-cms/backoffice/entity-action';
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
export class UmbCreateDocumentBlueprintEntityAction extends UmbEntityActionBase<UmbDocumentDetailRepository> {
constructor(host: UmbControllerHostElement, repositoryAlias: string, unique: string, entityType: string) {
super(host, repositoryAlias, unique, entityType);
export class UmbCreateDocumentBlueprintEntityAction extends UmbEntityActionBase<UmbEntityActionArgs<never>> {
constructor(host: UmbControllerHost, args: UmbEntityActionArgs<never>) {
super(host, args);
}
async execute() {
console.log(`execute for: ${this.unique}`);
console.log(`execute for: ${this.args.unique}`);
//await this.repository?.createBlueprint();
}
destroy(): void {}
}

View File

@@ -13,7 +13,6 @@ const entityActions: Array<ManifestEntityAction> = [
meta: {
icon: 'icon-add',
label: 'Create',
repositoryAlias: UMB_DOCUMENT_DETAIL_REPOSITORY_ALIAS,
entityTypes: [UMB_DOCUMENT_ROOT_ENTITY_TYPE, UMB_DOCUMENT_ENTITY_TYPE],
},
/* removed until we have permissions in place

View File

@@ -1,13 +1,15 @@
import type { UmbEntityActionArgs } from '@umbraco-cms/backoffice/entity-action';
import { UmbEntityActionBase } from '@umbraco-cms/backoffice/entity-action';
import { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal';
import { UMB_CULTURE_AND_HOSTNAMES_MODAL, type UmbDocumentDetailRepository } from '@umbraco-cms/backoffice/document';
import { UMB_CULTURE_AND_HOSTNAMES_MODAL } from '@umbraco-cms/backoffice/document';
export class UmbDocumentCultureAndHostnamesEntityAction extends UmbEntityActionBase<UmbDocumentDetailRepository> {
export class UmbDocumentCultureAndHostnamesEntityAction extends UmbEntityActionBase<UmbEntityActionArgs<never>> {
async execute() {
if (!this.repository) return;
const modalManager = await this.getContext(UMB_MODAL_MANAGER_CONTEXT);
modalManager.open(this, UMB_CULTURE_AND_HOSTNAMES_MODAL, {
data: { unique: this.unique ?? null },
data: { unique: this.args.unique },
});
}
destroy(): void {}
}

View File

@@ -2,18 +2,19 @@ import { umbPickDocumentVariantModal } from '../modals/pick-document-variant-mod
import { UmbDocumentDetailRepository, UmbDocumentPublishingRepository } from '../repository/index.js';
import { UmbDocumentVariantState } from '../types.js';
import { UmbLanguageCollectionRepository } from '@umbraco-cms/backoffice/language';
import type { UmbEntityActionArgs } from '@umbraco-cms/backoffice/entity-action';
import { UmbEntityActionBase } from '@umbraco-cms/backoffice/entity-action';
import { UmbVariantId } from '@umbraco-cms/backoffice/variant';
export class UmbUnpublishDocumentEntityAction extends UmbEntityActionBase<unknown> {
export class UmbUnpublishDocumentEntityAction extends UmbEntityActionBase<UmbEntityActionArgs<never>> {
async execute() {
if (!this.unique) throw new Error('The document unique identifier is missing');
if (!this.args.unique) throw new Error('The document unique identifier is missing');
const languageRepository = new UmbLanguageCollectionRepository(this._host);
const { data: languageData } = await languageRepository.requestCollection({});
const documentRepository = new UmbDocumentDetailRepository(this._host);
const { data: documentData } = await documentRepository.requestByUnique(this.unique);
const { data: documentData } = await documentRepository.requestByUnique(this.args.unique);
if (!documentData) throw new Error('The document was not found');
@@ -39,7 +40,9 @@ export class UmbUnpublishDocumentEntityAction extends UmbEntityActionBase<unknow
if (selectedVariants.length) {
const publishingRepository = new UmbDocumentPublishingRepository(this._host);
await publishingRepository.unpublish(this.unique, selectedVariants);
await publishingRepository.unpublish(this.args.unique, selectedVariants);
}
}
destroy(): void {}
}

View File

@@ -1,4 +1,3 @@
import { UMB_MEDIA_DETAIL_REPOSITORY_ALIAS } from '../../repository/index.js';
import { UMB_MEDIA_ENTITY_TYPE, UMB_MEDIA_ROOT_ENTITY_TYPE } from '../../entity.js';
import { UmbCreateMediaEntityAction } from './create.action.js';
import type { ManifestEntityAction, ManifestModal } from '@umbraco-cms/backoffice/extension-registry';
@@ -14,7 +13,6 @@ const entityActions: Array<ManifestEntityAction> = [
icon: 'icon-add',
label: 'Create',
entityTypes: [UMB_MEDIA_ROOT_ENTITY_TYPE, UMB_MEDIA_ENTITY_TYPE],
repositoryAlias: UMB_MEDIA_DETAIL_REPOSITORY_ALIAS,
},
/* removed until we have permissions in place
conditions: [