diff --git a/src/Umbraco.Web.UI.Client/src/packages/users/users/entity-bulk-actions/unlock/unlock.action.ts b/src/Umbraco.Web.UI.Client/src/packages/users/users/entity-bulk-actions/unlock/unlock.action.ts index 114e8924e5..27fe636138 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/users/users/entity-bulk-actions/unlock/unlock.action.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/users/users/entity-bulk-actions/unlock/unlock.action.ts @@ -1,6 +1,6 @@ +import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; import { UmbUserRepository } from '../../repository/user.repository'; import { UmbEntityBulkActionBase } from '@umbraco-cms/backoffice/entity-action'; -import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; export class UmbUnlockUserEntityBulkAction extends UmbEntityBulkActionBase { constructor(host: UmbControllerHostElement, repositoryAlias: string, selection: Array) { @@ -8,7 +8,6 @@ export class UmbUnlockUserEntityBulkAction extends UmbEntityBulkActionBase} id + * @return {*} + * @memberof UmbUserUnlockServerDataSource + */ + async unlock(userIds: string[]) { + if (!userIds) throw new Error('User ids are missing'); + + return tryExecuteAndNotify( + this.#host, + UserResource.postUserUnlock({ + requestBody: { + userIds, + }, + }) + ); + } +} diff --git a/src/Umbraco.Web.UI.Client/src/packages/users/users/repository/user.repository.ts b/src/Umbraco.Web.UI.Client/src/packages/users/users/repository/user.repository.ts index ab34c28810..6875089fe2 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/users/users/repository/user.repository.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/users/users/repository/user.repository.ts @@ -13,6 +13,7 @@ import { UMB_USER_ITEM_STORE_CONTEXT_TOKEN, UmbUserItemStore } from './user-item import { UmbUserSetGroupsServerDataSource } from './sources/user-set-group.server.data'; import { UmbUserEnableServerDataSource } from './sources/user-enable.server.data'; import { UmbUserDisableServerDataSource } from './sources/user-disable.server.data'; +import { UmbUserUnlockServerDataSource } from './sources/user-unlock.server.data'; import { UmbCollectionDataSource, UmbCollectionRepository, @@ -41,8 +42,10 @@ export class UmbUserRepository #itemStore?: UmbUserItemStore; #setUserGroupsSource: UmbUserSetGroupDataSource; + //ACTIONS #enableSource: UmbUserEnableServerDataSource; #disableSource: UmbUserDisableServerDataSource; + #unlockSource: UmbUserUnlockServerDataSource; #collectionSource: UmbCollectionDataSource; @@ -55,6 +58,7 @@ export class UmbUserRepository this.#collectionSource = new UmbUserCollectionServerDataSource(this.#host); this.#enableSource = new UmbUserEnableServerDataSource(this.#host); this.#disableSource = new UmbUserDisableServerDataSource(this.#host); + this.#unlockSource = new UmbUserUnlockServerDataSource(this.#host); this.#itemSource = new UmbUserItemServerDataSource(this.#host); this.#setUserGroupsSource = new UmbUserSetGroupsServerDataSource(this.#host); @@ -226,4 +230,16 @@ export class UmbUserRepository this.#notificationContext?.peek('positive', notification); } } + + async unlock(ids: Array) { + if (ids.length === 0) throw new Error('User ids are missing'); + + const { error } = await this.#unlockSource.unlock(ids); + + if (!error) { + //TODO: UPDATE STORE + const notification = { data: { message: `${ids.length > 1 ? 'Users' : 'User'} unlocked` } }; + this.#notificationContext?.peek('positive', notification); + } + } } diff --git a/src/Umbraco.Web.UI.Client/src/packages/users/users/types.ts b/src/Umbraco.Web.UI.Client/src/packages/users/users/types.ts index 79119afdd5..e52348d32c 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/users/users/types.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/users/users/types.ts @@ -41,6 +41,9 @@ export interface UmbUserDisableDataSource { export interface UmbUserEnableDataSource { enable(userIds: string[]): Promise; } +export interface UmbUserUnlockDataSource { + unlock(userIds: string[]): Promise; +} export interface UmbUserDetailRepository extends UmbDetailRepository<