@@ -8,9 +8,19 @@ import { UMB_APP_LANGUAGE_CONTEXT, UmbLanguageCollectionRepository } from '@umbr
8
8
import { UmbVariantId } from '@umbraco-cms/backoffice/variant' ;
9
9
import { UMB_CONFIRM_MODAL , UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal' ;
10
10
import { 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' ;
11
14
12
15
export class UmbDocumentPublishEntityBulkAction extends UmbEntityBulkActionBase < object > {
13
16
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
+
14
24
// If there is only one selection, we can refer to the regular publish entity action:
15
25
if ( this . selection . length === 1 ) {
16
26
const action = new UmbPublishDocumentEntityAction ( this . _host , {
@@ -43,6 +53,12 @@ export class UmbDocumentPublishEntityBulkAction extends UmbEntityBulkActionBase<
43
53
44
54
const modalManagerContext = await this . getContext ( UMB_MODAL_MANAGER_CONTEXT ) ;
45
55
56
+ const eventContext = await this . getContext ( UMB_ACTION_EVENT_CONTEXT ) ;
57
+ const event = new UmbRequestReloadChildrenOfEntityEvent ( {
58
+ entityType,
59
+ unique,
60
+ } ) ;
61
+
46
62
// If there is only one language available, we can skip the modal and publish directly:
47
63
if ( options . length === 1 ) {
48
64
const localizationController = new UmbLocalizationController ( this . _host ) ;
@@ -62,6 +78,7 @@ export class UmbDocumentPublishEntityBulkAction extends UmbEntityBulkActionBase<
62
78
const variantId = new UmbVariantId ( options [ 0 ] . language . unique , null ) ;
63
79
const publishingRepository = new UmbDocumentPublishingRepository ( this . _host ) ;
64
80
await publishingRepository . unpublish ( this . selection [ 0 ] , [ variantId ] ) ;
81
+ eventContext . dispatchEvent ( event ) ;
65
82
}
66
83
return ;
67
84
}
@@ -98,6 +115,7 @@ export class UmbDocumentPublishEntityBulkAction extends UmbEntityBulkActionBase<
98
115
unique ,
99
116
variantIds . map ( ( variantId ) => ( { variantId } ) ) ,
100
117
) ;
118
+ eventContext . dispatchEvent ( event ) ;
101
119
}
102
120
}
103
121
}
0 commit comments