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

23 lines
672 B
TypeScript
Raw Normal View History

2018-09-25 07:53:55 -05:00
import { Action, ActionTypes } from './actions';
import { Plugin, PluginsState } from 'app/types';
2018-09-25 09:21:52 -05:00
export const initialState: PluginsState = { plugins: [] as Plugin[], searchQuery: '', layoutMode: '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,
};