From 901dc917f7338abee8a08871b397e9b33648549a Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Tue, 21 May 2024 13:07:50 +0200 Subject: [PATCH] reload user collection on disable, enable, and unlock --- .../disable/disable.action.ts | 18 ++++++++++++++++++ .../enable/enable.action.ts | 18 ++++++++++++++++++ .../unlock/unlock.action.ts | 18 ++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-bulk-actions/disable/disable.action.ts b/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-bulk-actions/disable/disable.action.ts index 2e93cba594..d1e873e188 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-bulk-actions/disable/disable.action.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-bulk-actions/disable/disable.action.ts @@ -1,9 +1,27 @@ import { UmbDisableUserRepository } from '../../repository/index.js'; +import { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action'; import { UmbEntityBulkActionBase } from '@umbraco-cms/backoffice/entity-bulk-action'; +import { UmbRequestReloadChildrenOfEntityEvent } from '@umbraco-cms/backoffice/entity-action'; +import { UMB_ENTITY_CONTEXT } from '@umbraco-cms/backoffice/entity'; export class UmbDisableUserEntityBulkAction extends UmbEntityBulkActionBase { async execute() { const repository = new UmbDisableUserRepository(this._host); await repository.disable(this.selection); + + const entityContext = await this.getContext(UMB_ENTITY_CONTEXT); + const entityType = entityContext.getEntityType(); + const unique = entityContext.getUnique(); + + if (!entityType) throw new Error('Entity type not found'); + if (unique === undefined) throw new Error('Entity unique not found'); + + const eventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT); + const event = new UmbRequestReloadChildrenOfEntityEvent({ + entityType, + unique, + }); + + eventContext.dispatchEvent(event); } } diff --git a/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-bulk-actions/enable/enable.action.ts b/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-bulk-actions/enable/enable.action.ts index b663558dd0..3236083032 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-bulk-actions/enable/enable.action.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-bulk-actions/enable/enable.action.ts @@ -1,9 +1,27 @@ import { UmbEnableUserRepository } from '../../repository/index.js'; +import { UMB_ENTITY_CONTEXT } from '@umbraco-cms/backoffice/entity'; import { UmbEntityBulkActionBase } from '@umbraco-cms/backoffice/entity-bulk-action'; +import { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action'; +import { UmbRequestReloadChildrenOfEntityEvent } from '@umbraco-cms/backoffice/entity-action'; export class UmbEnableUserEntityBulkAction extends UmbEntityBulkActionBase { async execute() { const repository = new UmbEnableUserRepository(this._host); await repository.enable(this.selection); + + const entityContext = await this.getContext(UMB_ENTITY_CONTEXT); + const entityType = entityContext.getEntityType(); + const unique = entityContext.getUnique(); + + if (!entityType) throw new Error('Entity type not found'); + if (unique === undefined) throw new Error('Entity unique not found'); + + const eventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT); + const event = new UmbRequestReloadChildrenOfEntityEvent({ + entityType, + unique, + }); + + eventContext.dispatchEvent(event); } } diff --git a/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-bulk-actions/unlock/unlock.action.ts b/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-bulk-actions/unlock/unlock.action.ts index 3dcc43fd92..b2d00aa668 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-bulk-actions/unlock/unlock.action.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-bulk-actions/unlock/unlock.action.ts @@ -1,9 +1,27 @@ import { UmbUnlockUserRepository } from '../../repository/index.js'; +import { UMB_ENTITY_CONTEXT } from '@umbraco-cms/backoffice/entity'; import { UmbEntityBulkActionBase } from '@umbraco-cms/backoffice/entity-bulk-action'; +import { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action'; +import { UmbRequestReloadChildrenOfEntityEvent } from '@umbraco-cms/backoffice/entity-action'; export class UmbUnlockUserEntityBulkAction extends UmbEntityBulkActionBase { async execute() { const repository = new UmbUnlockUserRepository(this._host); await repository.unlock(this.selection); + + const entityContext = await this.getContext(UMB_ENTITY_CONTEXT); + const entityType = entityContext.getEntityType(); + const unique = entityContext.getUnique(); + + if (!entityType) throw new Error('Entity type not found'); + if (unique === undefined) throw new Error('Entity unique not found'); + + const eventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT); + const event = new UmbRequestReloadChildrenOfEntityEvent({ + entityType, + unique, + }); + + eventContext.dispatchEvent(event); } }