mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 16:45:43 -06:00
* Updated package json but not updated source files * Update eslint plugin * updated files
32 lines
1014 B
TypeScript
32 lines
1014 B
TypeScript
import { getBackendSrv } from 'app/core/services/backend_srv';
|
|
import { ApiKey, ThunkResult } from 'app/types';
|
|
import { apiKeysLoaded, setSearchQuery } from './reducers';
|
|
|
|
export function addApiKey(
|
|
apiKey: ApiKey,
|
|
openModal: (key: string) => void,
|
|
includeExpired: boolean
|
|
): ThunkResult<void> {
|
|
return async (dispatch) => {
|
|
const result = await getBackendSrv().post('/api/auth/keys', apiKey);
|
|
dispatch(setSearchQuery(''));
|
|
dispatch(loadApiKeys(includeExpired));
|
|
openModal(result.key);
|
|
};
|
|
}
|
|
|
|
export function loadApiKeys(includeExpired: boolean): ThunkResult<void> {
|
|
return async (dispatch) => {
|
|
const response = await getBackendSrv().get('/api/auth/keys?includeExpired=' + includeExpired);
|
|
dispatch(apiKeysLoaded(response));
|
|
};
|
|
}
|
|
|
|
export function deleteApiKey(id: number, includeExpired: boolean): ThunkResult<void> {
|
|
return async (dispatch) => {
|
|
getBackendSrv()
|
|
.delete(`/api/auth/keys/${id}`)
|
|
.then(() => dispatch(loadApiKeys(includeExpired)));
|
|
};
|
|
}
|