diff --git a/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-actions/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-actions/manifests.ts index 39b1b6d04b..ebfa4f30a1 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-actions/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-actions/manifests.ts @@ -8,6 +8,7 @@ import { UMB_USER_ENTITY_TYPE } from '../index.js'; import { UmbDisableUserEntityAction } from './disable/disable-user.action.js'; import { UmbEnableUserEntityAction } from './enable/enable-user.action.js'; import { UmbChangeUserPasswordEntityAction } from './change-password/change-user-password.action.js'; +import { UmbUnlockUserEntityAction } from './unlock/unlock-user.action.js'; import { UmbDeleteEntityAction } from '@umbraco-cms/backoffice/entity-action'; import { ManifestTypes } from '@umbraco-cms/backoffice/extension-registry'; @@ -74,6 +75,19 @@ const entityActions: Array = [ entityTypes: [UMB_USER_ENTITY_TYPE], }, }, + { + type: 'entityAction', + alias: 'Umb.EntityAction.User.Unlock', + name: 'Unlock User Entity Action', + weight: 600, + api: UmbUnlockUserEntityAction, + meta: { + icon: 'umb:key', + label: 'Change Password', + repositoryAlias: CHANGE_USER_PASSWORD_REPOSITORY_ALIAS, + entityTypes: [UMB_USER_ENTITY_TYPE], + }, + }, ]; export const manifests = [...entityActions]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-actions/unlock/unlock-user.action.ts b/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-actions/unlock/unlock-user.action.ts new file mode 100644 index 0000000000..b2458b5ee0 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/user/user/entity-actions/unlock/unlock-user.action.ts @@ -0,0 +1,43 @@ +import { type UmbUnlockUserRepository, UmbUserRepository } from '../../repository/index.js'; +import { UmbEntityActionBase } from '@umbraco-cms/backoffice/entity-action'; +import { UmbContextConsumerController } from '@umbraco-cms/backoffice/context-api'; +import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; +import { + type UmbModalManagerContext, + UMB_MODAL_MANAGER_CONTEXT_TOKEN, + UMB_CONFIRM_MODAL, +} from '@umbraco-cms/backoffice/modal'; + +export class UmbUnlockUserEntityAction extends UmbEntityActionBase { + #modalManager?: UmbModalManagerContext; + #itemRepository: UmbUserRepository; + + constructor(host: UmbControllerHostElement, repositoryAlias: string, unique: string) { + super(host, repositoryAlias, unique); + + this.#itemRepository = new UmbUserRepository(this.host); + + new UmbContextConsumerController(this.host, UMB_MODAL_MANAGER_CONTEXT_TOKEN, (instance) => { + this.#modalManager = instance; + }); + } + + async execute() { + if (!this.repository || !this.#modalManager) return; + + const { data } = await this.#itemRepository.requestItems([this.unique]); + + if (data) { + const item = data[0]; + + const modalContext = this.#modalManager.open(UMB_CONFIRM_MODAL, { + headline: `Unlock ${item.name}`, + content: 'Are you sure you want to unlock this user?', + confirmLabel: 'Unlock', + }); + + await modalContext.onSubmit(); + await this.repository?.unlock([this.unique]); + } + } +}