grafana/public/app/features/plugins/state/reducers.ts

28 lines
775 B
TypeScript
Raw Normal View History

2018-09-25 07:53:55 -05:00
import { Action, ActionTypes } from './actions';
2018-09-27 07:45:36 -05:00
import { Plugin, PluginsState } from 'app/types';
2018-09-27 05:15:41 -05:00
import { LayoutModes } from '../../../core/components/LayoutSelector/LayoutSelector';
2018-09-25 07:53:55 -05:00
2018-09-27 07:23:46 -05:00
export const initialState: PluginsState = {
2018-09-27 07:45:36 -05:00
plugins: [] as Plugin[],
2018-09-27 07:23:46 -05:00
searchQuery: '',
layoutMode: LayoutModes.Grid,
};
2018-09-25 07:53:55 -05:00
export const pluginsReducer = (state = initialState, action: Action): PluginsState => {
switch (action.type) {
case ActionTypes.LoadPlugins:
return { ...state, plugins: action.payload };
2018-09-25 09:21:52 -05:00
case ActionTypes.SetPluginsSearchQuery:
return { ...state, searchQuery: action.payload };
case ActionTypes.SetLayoutMode:
return { ...state, layoutMode: action.payload };
2018-09-25 07:53:55 -05:00
}
return state;
};
export default {
plugins: pluginsReducer,
};