diff --git a/src/packages/user/user/repository/disable/disable-user.repository.ts b/src/packages/user/user/repository/disable/disable-user.repository.ts index d7c94c6beb..81bc35ff41 100644 --- a/src/packages/user/user/repository/disable/disable-user.repository.ts +++ b/src/packages/user/user/repository/disable/disable-user.repository.ts @@ -1,10 +1,14 @@ import { UmbUserRepositoryBase } from '../user-repository-base.js'; +import { UmbUserItemRepository } from '../item/index.js'; import { UmbDisableUserServerDataSource } from './disable-user.server.data-source.js'; +import { UmbLocalizationController } from '@umbraco-cms/backoffice/localization-api'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import { UserStateModel } from '@umbraco-cms/backoffice/external/backend-api'; export class UmbDisableUserRepository extends UmbUserRepositoryBase { #disableSource: UmbDisableUserServerDataSource; + #localize = new UmbLocalizationController(this); + #userItemRepository = new UmbUserItemRepository(this); constructor(host: UmbControllerHost) { super(host); @@ -18,11 +22,22 @@ export class UmbDisableUserRepository extends UmbUserRepositoryBase { const { data, error } = await this.#disableSource.disable(ids); if (!error) { + const { data: items } = await this.#userItemRepository.requestItems(ids); + if (!items) throw new Error('Could not load user item'); + + // TODO: get state from item when available ids.forEach((id) => { this.detailStore?.updateItem(id, { state: UserStateModel.DISABLED }); }); - const notification = { data: { message: `User disabled` } }; + let message = this.#localize.term('speechBubbles_disableUsersSuccess', items.length); + + if (items.length === 1) { + const names = items?.map((item) => item.name).join(', '); + message = this.#localize.term('speechBubbles_disableUserSuccess', names); + } + + const notification = { data: { message } }; this.notificationContext?.peek('positive', notification); } diff --git a/src/packages/user/user/repository/enable/enable-user.repository.ts b/src/packages/user/user/repository/enable/enable-user.repository.ts index 2728c4807d..4c871e5fd5 100644 --- a/src/packages/user/user/repository/enable/enable-user.repository.ts +++ b/src/packages/user/user/repository/enable/enable-user.repository.ts @@ -1,10 +1,14 @@ import { UmbUserRepositoryBase } from '../user-repository-base.js'; +import { UmbUserItemRepository } from '../item/index.js'; import { UmbEnableUserServerDataSource } from './enable-user.server.data-source.js'; +import { UmbLocalizationController } from '@umbraco-cms/backoffice/localization-api'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import { UserStateModel } from '@umbraco-cms/backoffice/external/backend-api'; export class UmbEnableUserRepository extends UmbUserRepositoryBase { #enableSource: UmbEnableUserServerDataSource; + #localize = new UmbLocalizationController(this); + #userItemRepository = new UmbUserItemRepository(this); constructor(host: UmbControllerHost) { super(host); @@ -18,11 +22,22 @@ export class UmbEnableUserRepository extends UmbUserRepositoryBase { const { data, error } = await this.#enableSource.enable(ids); if (!error) { + const { data: items } = await this.#userItemRepository.requestItems(ids); + if (!items) throw new Error('Could not load user item'); + + // TODO: get state from item when available ids.forEach((id) => { this.detailStore?.updateItem(id, { state: UserStateModel.ACTIVE }); }); - const notification = { data: { message: `User disabled` } }; + let message = this.#localize.term('speechBubbles_enableUsersSuccess', items.length); + + if (items.length === 1) { + const names = items?.map((item) => item.name).join(', '); + message = this.#localize.term('speechBubbles_enableUserSuccess', names); + } + + const notification = { data: { message } }; this.notificationContext?.peek('positive', notification); }