The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
grafana/public/app/features/plugins/state/reducers.ts

39 lines
1.2 KiB

7 years ago
import { Action, ActionTypes } from './actions';
import { PluginsState } from 'app/types';
import { LayoutModes } from '../../../core/components/LayoutSelector/LayoutSelector';
7 years ago
import { PluginDashboard } from '../../../types/plugins';
import { PluginMeta } from '@grafana/data';
7 years ago
export const initialState: PluginsState = {
plugins: [] as PluginMeta[],
searchQuery: '',
layoutMode: LayoutModes.Grid,
hasFetched: false,
7 years ago
dashboards: [] as PluginDashboard[],
isLoadingPluginDashboards: false,
};
7 years ago
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 };
7 years ago
case ActionTypes.LoadPluginDashboards:
return { ...state, dashboards: [], isLoadingPluginDashboards: true };
case ActionTypes.LoadedPluginDashboards:
return { ...state, dashboards: action.payload, isLoadingPluginDashboards: false };
7 years ago
}
return state;
};
export default {
plugins: pluginsReducer,
};