mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 08:05:43 -06:00
24 lines
906 B
TypeScript
24 lines
906 B
TypeScript
import { getBackendSrv } from '@grafana/runtime';
|
|
import { contextSrv } from 'app/core/core';
|
|
import { FormModel } from 'app/features/org/UserInviteForm';
|
|
import { AccessControlAction, createAsyncThunk, Invitee } from 'app/types';
|
|
|
|
export const fetchInvitees = createAsyncThunk('users/fetchInvitees', async () => {
|
|
if (!contextSrv.hasPermission(AccessControlAction.UsersCreate)) {
|
|
return [];
|
|
}
|
|
|
|
const invitees: Invitee[] = await getBackendSrv().get('/api/org/invites');
|
|
return invitees;
|
|
});
|
|
|
|
export const addInvitee = createAsyncThunk('users/addInvitee', async (addInviteForm: FormModel, { dispatch }) => {
|
|
await getBackendSrv().post(`/api/org/invites`, addInviteForm);
|
|
await dispatch(fetchInvitees());
|
|
});
|
|
|
|
export const revokeInvite = createAsyncThunk('users/revokeInvite', async (code: string) => {
|
|
await getBackendSrv().patch(`/api/org/invites/${code}/revoke`, {});
|
|
return code;
|
|
});
|