grafana/public/app/features/api-keys/state/reducers.ts
Hugo Häggmark e87d48921e
Admin: Keeps expired api keys visible in table after delete (#31636)
* Admin: Keeps expired keys visible in table after delete

* Chore: covers component in tests before refactor

* Refactor: splitting up into smaller components

* Chore: fixes a small issue with the validation

* Chore: forgot to export type
2021-03-04 13:20:38 +01:00

31 lines
735 B
TypeScript

import { createSlice } from '@reduxjs/toolkit';
import { ApiKeysState } from 'app/types';
export const initialApiKeysState: ApiKeysState = {
keys: [],
searchQuery: '',
hasFetched: false,
};
const apiKeysSlice = createSlice({
name: 'apiKeys',
initialState: initialApiKeysState,
reducers: {
apiKeysLoaded: (state, action): ApiKeysState => {
return { ...state, hasFetched: true, keys: action.payload };
},
setSearchQuery: (state, action): ApiKeysState => {
return { ...state, searchQuery: action.payload };
},
},
});
export const { setSearchQuery, apiKeysLoaded } = apiKeysSlice.actions;
export const apiKeysReducer = apiKeysSlice.reducer;
export default {
apiKeys: apiKeysReducer,
};