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-10-17 07:36:18 -05:00
|
|
|
import { PluginDashboard } from '../../../types/plugins';
|
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-10-11 04:49:34 -05:00
|
|
|
hasFetched: false,
|
2018-10-17 07:36:18 -05:00
|
|
|
dashboards: [] as PluginDashboard[],
|
2018-09-27 07:23:46 -05:00
|
|
|
};
|
2018-09-25 07:53:55 -05:00
|
|
|
|
|
|
|
export const pluginsReducer = (state = initialState, action: Action): PluginsState => {
|
|
|
|
switch (action.type) {
|
|
|
|
case ActionTypes.LoadPlugins:
|
2018-10-11 04:49:34 -05:00
|
|
|
return { ...state, hasFetched: true, 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-10-17 07:36:18 -05:00
|
|
|
|
|
|
|
case ActionTypes.LoadPluginDashboards:
|
|
|
|
return { ...state, dashboards: action.payload };
|
2018-09-25 07:53:55 -05:00
|
|
|
}
|
|
|
|
return state;
|
|
|
|
};
|
|
|
|
|
|
|
|
export default {
|
|
|
|
plugins: pluginsReducer,
|
|
|
|
};
|