add enable and disable data sources
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbUserDisableDataSource } from '../../types';
|
||||
import { UserResource } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources';
|
||||
|
||||
/**
|
||||
* A data source for Data Type items that fetches data from the server
|
||||
* @export
|
||||
* @class UmbUserDisableServerDataSource
|
||||
*/
|
||||
export class UmbUserDisableServerDataSource implements UmbUserDisableDataSource {
|
||||
#host: UmbControllerHostElement;
|
||||
|
||||
/**
|
||||
* Creates an instance of UmbUserDisableServerDataSource.
|
||||
* @param {UmbControllerHostElement} host
|
||||
* @memberof UmbUserDisableServerDataSource
|
||||
*/
|
||||
constructor(host: UmbControllerHostElement) {
|
||||
this.#host = host;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set groups for users
|
||||
* @param {Array<string>} id
|
||||
* @return {*}
|
||||
* @memberof UmbUserDisableServerDataSource
|
||||
*/
|
||||
async disable(userIds: string[]) {
|
||||
if (!userIds) throw new Error('User ids are missing');
|
||||
|
||||
return tryExecuteAndNotify(
|
||||
this.#host,
|
||||
UserResource.postUserDisable({
|
||||
requestBody: {
|
||||
userIds,
|
||||
},
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbUserEnableDataSource } from '../../types';
|
||||
import { UserResource } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources';
|
||||
|
||||
/**
|
||||
* A data source for Data Type items that fetches data from the server
|
||||
* @export
|
||||
* @class UmbUserEnableServerDataSource
|
||||
*/
|
||||
export class UmbUserEnableServerDataSource implements UmbUserEnableDataSource {
|
||||
#host: UmbControllerHostElement;
|
||||
|
||||
/**
|
||||
* Creates an instance of UmbUserEnableServerDataSource.
|
||||
* @param {UmbControllerHostElement} host
|
||||
* @memberof UmbUserEnableServerDataSource
|
||||
*/
|
||||
constructor(host: UmbControllerHostElement) {
|
||||
this.#host = host;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set groups for users
|
||||
* @param {Array<string>} id
|
||||
* @return {*}
|
||||
* @memberof UmbUserEnableServerDataSource
|
||||
*/
|
||||
async enable(userIds: string[]) {
|
||||
if (!userIds) throw new Error('User ids are missing');
|
||||
|
||||
return tryExecuteAndNotify(
|
||||
this.#host,
|
||||
UserResource.postUserEnable({
|
||||
requestBody: {
|
||||
userIds,
|
||||
},
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import {
|
||||
UmbUserCollectionFilterModel,
|
||||
UmbUserDetailDataSource,
|
||||
@@ -16,7 +17,6 @@ import {
|
||||
UmbItemDataSource,
|
||||
UmbItemRepository,
|
||||
} from '@umbraco-cms/backoffice/repository';
|
||||
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
|
||||
import {
|
||||
CreateUserRequestModel,
|
||||
InviteUserRequestModel,
|
||||
|
||||
@@ -44,6 +44,13 @@ export interface UmbUserSetGroupDataSource {
|
||||
setGroups(userIds: string[], userGroupIds: string[]): Promise<UmbDataSourceErrorResponse>;
|
||||
}
|
||||
|
||||
export interface UmbUserDisableDataSource {
|
||||
disable(userIds: string[]): Promise<UmbDataSourceErrorResponse>;
|
||||
}
|
||||
export interface UmbUserEnableDataSource {
|
||||
enable(userIds: string[]): Promise<UmbDataSourceErrorResponse>;
|
||||
}
|
||||
|
||||
export interface UmbUserDetailRepository
|
||||
extends UmbDetailRepository<
|
||||
CreateUserRequestModel,
|
||||
|
||||
Reference in New Issue
Block a user