The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/invites/state/actions.ts

23 lines
906 B

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.OrgUsersAdd)) {
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;
});