@@ -8,9 +8,19 @@ import { UmbEntityBulkActionBase } from '@umbraco-cms/backoffice/entity-bulk-act
88import { UMB_APP_LANGUAGE_CONTEXT , UmbLanguageCollectionRepository } from '@umbraco-cms/backoffice/language' ;
99import { UmbVariantId } from '@umbraco-cms/backoffice/variant' ;
1010import { UmbLocalizationController } from '@umbraco-cms/backoffice/localization-api' ;
11+ import { UMB_ENTITY_CONTEXT } from '@umbraco-cms/backoffice/entity' ;
12+ import { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action' ;
13+ import { UmbRequestReloadChildrenOfEntityEvent } from '@umbraco-cms/backoffice/entity-action' ;
1114
1215export class UmbDocumentUnpublishEntityBulkAction extends UmbEntityBulkActionBase < object > {
1316 async execute ( ) {
17+ const entityContext = await this . getContext ( UMB_ENTITY_CONTEXT ) ;
18+ const entityType = entityContext . getEntityType ( ) ;
19+ const unique = entityContext . getUnique ( ) ;
20+
21+ if ( ! entityType ) throw new Error ( 'Entity type not found' ) ;
22+ if ( unique === undefined ) throw new Error ( 'Entity unique not found' ) ;
23+
1424 // If there is only one selection, we can refer to the regular unpublish entity action:
1525 if ( this . selection . length === 1 ) {
1626 const action = new UmbUnpublishDocumentEntityAction ( this . _host , {
@@ -43,6 +53,12 @@ export class UmbDocumentUnpublishEntityBulkAction extends UmbEntityBulkActionBas
4353
4454 const modalManagerContext = await this . getContext ( UMB_MODAL_MANAGER_CONTEXT ) ;
4555
56+ const eventContext = await this . getContext ( UMB_ACTION_EVENT_CONTEXT ) ;
57+ const event = new UmbRequestReloadChildrenOfEntityEvent ( {
58+ entityType,
59+ unique,
60+ } ) ;
61+
4662 // If there is only one language available, we can skip the modal and unpublish directly:
4763 if ( options . length === 1 ) {
4864 const localizationController = new UmbLocalizationController ( this . _host ) ;
@@ -62,6 +78,7 @@ export class UmbDocumentUnpublishEntityBulkAction extends UmbEntityBulkActionBas
6278 const variantId = new UmbVariantId ( options [ 0 ] . language . unique , null ) ;
6379 const publishingRepository = new UmbDocumentPublishingRepository ( this . _host ) ;
6480 await publishingRepository . unpublish ( this . selection [ 0 ] , [ variantId ] ) ;
81+ eventContext . dispatchEvent ( event ) ;
6582 }
6683 return ;
6784 }
@@ -95,6 +112,7 @@ export class UmbDocumentUnpublishEntityBulkAction extends UmbEntityBulkActionBas
95112 if ( variantIds . length ) {
96113 for ( const unique of this . selection ) {
97114 await repository . unpublish ( unique , variantIds ) ;
115+ eventContext . dispatchEvent ( event ) ;
98116 }
99117 }
100118 }
0 commit comments