mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
Primarily- moving majority of the types and utils from @grafana/ui to @grafana/data * Move types from grafana-ui to grafana-data * Move valueFormats to grafana-data * Move utils from grafana-ui to grafana-data * Update imports in grafana-ui * revert data's tsconfig change * Update imports in grafana-runtime * Fix import paths in grafana-ui * Move rxjs to devDeps * Core import updates batch 1 * Import updates batch 2 * Imports fix batch 3 * Imports fixes batch i don't know * Fix imorts in grafana-toolkit * Fix imports after master merge
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { Action, ActionTypes } from './actions';
|
|
import { PluginsState } from 'app/types';
|
|
import { LayoutModes } from '../../../core/components/LayoutSelector/LayoutSelector';
|
|
import { PluginDashboard } from '../../../types/plugins';
|
|
import { PluginMeta } from '@grafana/data';
|
|
|
|
export const initialState: PluginsState = {
|
|
plugins: [] as PluginMeta[],
|
|
searchQuery: '',
|
|
layoutMode: LayoutModes.Grid,
|
|
hasFetched: false,
|
|
dashboards: [] as PluginDashboard[],
|
|
isLoadingPluginDashboards: false,
|
|
};
|
|
|
|
export const pluginsReducer = (state = initialState, action: Action): PluginsState => {
|
|
switch (action.type) {
|
|
case ActionTypes.LoadPlugins:
|
|
return { ...state, hasFetched: true, plugins: action.payload };
|
|
|
|
case ActionTypes.SetPluginsSearchQuery:
|
|
return { ...state, searchQuery: action.payload };
|
|
|
|
case ActionTypes.SetLayoutMode:
|
|
return { ...state, layoutMode: action.payload };
|
|
|
|
case ActionTypes.LoadPluginDashboards:
|
|
return { ...state, dashboards: [], isLoadingPluginDashboards: true };
|
|
|
|
case ActionTypes.LoadedPluginDashboards:
|
|
return { ...state, dashboards: action.payload, isLoadingPluginDashboards: false };
|
|
}
|
|
return state;
|
|
};
|
|
|
|
export default {
|
|
plugins: pluginsReducer,
|
|
};
|