mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
29 lines
869 B
TypeScript
29 lines
869 B
TypeScript
import { getBackendSrv } from '@grafana/runtime';
|
|
import { accessControlQueryParam } from 'app/core/utils/accessControl';
|
|
import { OrgUser } from 'app/types';
|
|
|
|
import { ThunkResult } from '../../../types';
|
|
|
|
import { usersLoaded } from './reducers';
|
|
|
|
export function loadUsers(): ThunkResult<void> {
|
|
return async (dispatch) => {
|
|
const users = await getBackendSrv().get('/api/org/users', accessControlQueryParam());
|
|
dispatch(usersLoaded(users));
|
|
};
|
|
}
|
|
|
|
export function updateUser(user: OrgUser): ThunkResult<void> {
|
|
return async (dispatch) => {
|
|
await getBackendSrv().patch(`/api/org/users/${user.userId}`, { role: user.role });
|
|
dispatch(loadUsers());
|
|
};
|
|
}
|
|
|
|
export function removeUser(userId: number): ThunkResult<void> {
|
|
return async (dispatch) => {
|
|
await getBackendSrv().delete(`/api/org/users/${userId}`);
|
|
dispatch(loadUsers());
|
|
};
|
|
}
|