Skip to content

Commit f6e8303

Browse files
Merge pull request #1847 from umbraco/bugfix/reload-user-collection-on-disable-enable-unlock
Bugfix: Reload user collection on disable, enable, and unlock
2 parents ffba115 + f1e7181 commit f6e8303

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
import { UmbDisableUserRepository } from '../../repository/index.js';
2+
import { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action';
23
import { UmbEntityBulkActionBase } from '@umbraco-cms/backoffice/entity-bulk-action';
4+
import { UmbRequestReloadChildrenOfEntityEvent } from '@umbraco-cms/backoffice/entity-action';
5+
import { UMB_ENTITY_CONTEXT } from '@umbraco-cms/backoffice/entity';
36

47
export class UmbDisableUserEntityBulkAction extends UmbEntityBulkActionBase<object> {
58
async execute() {
69
const repository = new UmbDisableUserRepository(this._host);
710
await repository.disable(this.selection);
11+
12+
const entityContext = await this.getContext(UMB_ENTITY_CONTEXT);
13+
const entityType = entityContext.getEntityType();
14+
const unique = entityContext.getUnique();
15+
16+
if (!entityType) throw new Error('Entity type not found');
17+
if (unique === undefined) throw new Error('Entity unique not found');
18+
19+
const eventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT);
20+
const event = new UmbRequestReloadChildrenOfEntityEvent({
21+
entityType,
22+
unique,
23+
});
24+
25+
eventContext.dispatchEvent(event);
826
}
927
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
import { UmbEnableUserRepository } from '../../repository/index.js';
2+
import { UMB_ENTITY_CONTEXT } from '@umbraco-cms/backoffice/entity';
23
import { UmbEntityBulkActionBase } from '@umbraco-cms/backoffice/entity-bulk-action';
4+
import { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action';
5+
import { UmbRequestReloadChildrenOfEntityEvent } from '@umbraco-cms/backoffice/entity-action';
36

47
export class UmbEnableUserEntityBulkAction extends UmbEntityBulkActionBase<object> {
58
async execute() {
69
const repository = new UmbEnableUserRepository(this._host);
710
await repository.enable(this.selection);
11+
12+
const entityContext = await this.getContext(UMB_ENTITY_CONTEXT);
13+
const entityType = entityContext.getEntityType();
14+
const unique = entityContext.getUnique();
15+
16+
if (!entityType) throw new Error('Entity type not found');
17+
if (unique === undefined) throw new Error('Entity unique not found');
18+
19+
const eventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT);
20+
const event = new UmbRequestReloadChildrenOfEntityEvent({
21+
entityType,
22+
unique,
23+
});
24+
25+
eventContext.dispatchEvent(event);
826
}
927
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
import { UmbUnlockUserRepository } from '../../repository/index.js';
2+
import { UMB_ENTITY_CONTEXT } from '@umbraco-cms/backoffice/entity';
23
import { UmbEntityBulkActionBase } from '@umbraco-cms/backoffice/entity-bulk-action';
4+
import { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action';
5+
import { UmbRequestReloadChildrenOfEntityEvent } from '@umbraco-cms/backoffice/entity-action';
36

47
export class UmbUnlockUserEntityBulkAction extends UmbEntityBulkActionBase<object> {
58
async execute() {
69
const repository = new UmbUnlockUserRepository(this._host);
710
await repository.unlock(this.selection);
11+
12+
const entityContext = await this.getContext(UMB_ENTITY_CONTEXT);
13+
const entityType = entityContext.getEntityType();
14+
const unique = entityContext.getUnique();
15+
16+
if (!entityType) throw new Error('Entity type not found');
17+
if (unique === undefined) throw new Error('Entity unique not found');
18+
19+
const eventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT);
20+
const event = new UmbRequestReloadChildrenOfEntityEvent({
21+
entityType,
22+
unique,
23+
});
24+
25+
eventContext.dispatchEvent(event);
826
}
927
}

0 commit comments

Comments
 (0)