mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Support Bundles: Improve creating bundle UX * Refactor create bundle page * Fix typo * Don't show loading indicaror after deleting bundle
61 lines
2.0 KiB
TypeScript
61 lines
2.0 KiB
TypeScript
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
|
|
|
import { SupportBundle, SupportBundleCollector, SupportBundlesState } from 'app/types';
|
|
|
|
export const initialState: SupportBundlesState = {
|
|
supportBundles: [],
|
|
isLoading: false,
|
|
supportBundleCollectors: [],
|
|
createBundlePageLoading: false,
|
|
loadBundlesError: '',
|
|
createBundleError: '',
|
|
};
|
|
|
|
const supportBundlesSlice = createSlice({
|
|
name: 'supportBundles',
|
|
initialState,
|
|
reducers: {
|
|
supportBundlesLoaded: (state, action: PayloadAction<SupportBundle[]>): SupportBundlesState => {
|
|
return { ...state, supportBundles: action.payload, isLoading: false };
|
|
},
|
|
fetchBegin: (state): SupportBundlesState => {
|
|
return { ...state, isLoading: true };
|
|
},
|
|
fetchEnd: (state): SupportBundlesState => {
|
|
return { ...state, isLoading: false };
|
|
},
|
|
collectorsFetchBegin: (state): SupportBundlesState => {
|
|
return { ...state, createBundlePageLoading: true };
|
|
},
|
|
collectorsFetchEnd: (state): SupportBundlesState => {
|
|
return { ...state, createBundlePageLoading: false };
|
|
},
|
|
supportBundleCollectorsLoaded: (state, action: PayloadAction<SupportBundleCollector[]>): SupportBundlesState => {
|
|
return { ...state, supportBundleCollectors: action.payload, createBundlePageLoading: false };
|
|
},
|
|
setLoadBundleError: (state, action: PayloadAction<string>): SupportBundlesState => {
|
|
return { ...state, loadBundlesError: action.payload, supportBundleCollectors: [] };
|
|
},
|
|
setCreateBundleError: (state, action: PayloadAction<string>): SupportBundlesState => {
|
|
return { ...state, createBundleError: action.payload };
|
|
},
|
|
},
|
|
});
|
|
|
|
export const {
|
|
supportBundlesLoaded,
|
|
fetchBegin,
|
|
fetchEnd,
|
|
supportBundleCollectorsLoaded,
|
|
collectorsFetchBegin,
|
|
collectorsFetchEnd,
|
|
setLoadBundleError,
|
|
setCreateBundleError,
|
|
} = supportBundlesSlice.actions;
|
|
|
|
export const supportBundlesReducer = supportBundlesSlice.reducer;
|
|
|
|
export default {
|
|
supportBundles: supportBundlesReducer,
|
|
};
|