Chore: infer combined reducer state types (#39118)
This commit is contained in:
@@ -46,7 +46,7 @@ export const createRootReducer = () => {
|
|||||||
...addedReducers,
|
...addedReducers,
|
||||||
});
|
});
|
||||||
|
|
||||||
return (state: any, action: AnyAction): any => {
|
return (state: any, action: AnyAction) => {
|
||||||
if (action.type !== cleanUpAction.type) {
|
if (action.type !== cleanUpAction.type) {
|
||||||
return appReducer(state, action);
|
return appReducer(state, action);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
import { AnyAction, createSlice, PayloadAction, Reducer } from '@reduxjs/toolkit';
|
||||||
import { PluginMeta, PanelPlugin, PluginError } from '@grafana/data';
|
import { PluginMeta, PanelPlugin, PluginError } from '@grafana/data';
|
||||||
import { PluginsState } from 'app/types';
|
import { PluginsState } from 'app/types';
|
||||||
import { config } from 'app/core/config';
|
import { config } from 'app/core/config';
|
||||||
@@ -52,7 +52,9 @@ export const {
|
|||||||
panelPluginLoaded,
|
panelPluginLoaded,
|
||||||
} = pluginsSlice.actions;
|
} = pluginsSlice.actions;
|
||||||
|
|
||||||
export const pluginsReducer = config.pluginAdminEnabled ? pluginCatalogReducer : pluginsSlice.reducer;
|
export const pluginsReducer: Reducer<PluginsState, AnyAction> = config.pluginAdminEnabled
|
||||||
|
? ((pluginCatalogReducer as unknown) as Reducer<PluginsState, AnyAction>)
|
||||||
|
: pluginsSlice.reducer;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
plugins: pluginsReducer,
|
plugins: pluginsReducer,
|
||||||
|
|||||||
@@ -1,18 +1,9 @@
|
|||||||
import { combineReducers } from '@reduxjs/toolkit';
|
import { combineReducers } from '@reduxjs/toolkit';
|
||||||
import { optionsPickerReducer, OptionsPickerState } from '../pickers/OptionsPicker/reducer';
|
import { optionsPickerReducer } from '../pickers/OptionsPicker/reducer';
|
||||||
import { variableEditorReducer, VariableEditorState } from '../editor/reducer';
|
import { variableEditorReducer } from '../editor/reducer';
|
||||||
import { variablesReducer } from './variablesReducer';
|
import { variablesReducer } from './variablesReducer';
|
||||||
import { VariableModel } from '../types';
|
import { transactionReducer } from './transactionReducer';
|
||||||
import { transactionReducer, TransactionState } from './transactionReducer';
|
import { variableInspectReducer } from '../inspect/reducer';
|
||||||
import { variableInspectReducer, VariableInspectState } from '../inspect/reducer';
|
|
||||||
|
|
||||||
export interface TemplatingState {
|
|
||||||
variables: Record<string, VariableModel>;
|
|
||||||
optionsPicker: OptionsPickerState;
|
|
||||||
editor: VariableEditorState;
|
|
||||||
transaction: TransactionState;
|
|
||||||
inspect: VariableInspectState;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const templatingReducers = combineReducers({
|
export const templatingReducers = combineReducers({
|
||||||
editor: variableEditorReducer,
|
editor: variableEditorReducer,
|
||||||
@@ -22,6 +13,8 @@ export const templatingReducers = combineReducers({
|
|||||||
inspect: variableInspectReducer,
|
inspect: variableInspectReducer,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export type TemplatingState = ReturnType<typeof templatingReducers>;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
templating: templatingReducers,
|
templating: templatingReducers,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,49 +1,8 @@
|
|||||||
import { ThunkAction, ThunkDispatch as GenericThunkDispatch } from 'redux-thunk';
|
import { ThunkAction, ThunkDispatch as GenericThunkDispatch } from 'redux-thunk';
|
||||||
import { Action, PayloadAction } from '@reduxjs/toolkit';
|
import { Action, PayloadAction } from '@reduxjs/toolkit';
|
||||||
import { NavIndex } from '@grafana/data';
|
import type { createRootReducer } from 'app/core/reducers/root';
|
||||||
import { AlertRulesState, NotificationChannelState } from './alerting';
|
|
||||||
import { TeamsState, TeamState } from './teams';
|
|
||||||
import { FolderState } from './folders';
|
|
||||||
import { DashboardState } from './dashboard';
|
|
||||||
import { DataSourceSettingsState, DataSourcesState } from './datasources';
|
|
||||||
import { ExploreState } from './explore';
|
|
||||||
import { UserAdminState, UserListAdminState, UsersState } from './user';
|
|
||||||
import { OrganizationState } from './organization';
|
|
||||||
import { AppNotificationsState } from './appNotifications';
|
|
||||||
import { PluginsState } from './plugins';
|
|
||||||
import { LdapState } from './ldap';
|
|
||||||
import { PanelEditorState } from '../features/dashboard/components/PanelEditor/state/reducers';
|
|
||||||
import { ApiKeysState } from './apiKeys';
|
|
||||||
import { TemplatingState } from '../features/variables/state/reducers';
|
|
||||||
import { ImportDashboardState } from '../features/manage-dashboards/state/reducers';
|
|
||||||
import { UserState } from 'app/features/profile/state/reducers';
|
|
||||||
import { UnifiedAlertingState } from 'app/features/alerting/unified/state/reducers';
|
|
||||||
|
|
||||||
export interface StoreState {
|
export type StoreState = ReturnType<ReturnType<typeof createRootReducer>>;
|
||||||
navIndex: NavIndex;
|
|
||||||
alertRules: AlertRulesState;
|
|
||||||
teams: TeamsState;
|
|
||||||
team: TeamState;
|
|
||||||
folder: FolderState;
|
|
||||||
dashboard: DashboardState;
|
|
||||||
panelEditor: PanelEditorState;
|
|
||||||
dataSources: DataSourcesState;
|
|
||||||
dataSourceSettings: DataSourceSettingsState;
|
|
||||||
explore: ExploreState;
|
|
||||||
users: UsersState;
|
|
||||||
organization: OrganizationState;
|
|
||||||
appNotifications: AppNotificationsState;
|
|
||||||
user: UserState;
|
|
||||||
plugins: PluginsState;
|
|
||||||
ldap: LdapState;
|
|
||||||
apiKeys: ApiKeysState;
|
|
||||||
userAdmin: UserAdminState;
|
|
||||||
userListAdmin: UserListAdminState;
|
|
||||||
templating: TemplatingState;
|
|
||||||
importDashboard: ImportDashboardState;
|
|
||||||
notificationChannel: NotificationChannelState;
|
|
||||||
unifiedAlerting: UnifiedAlertingState;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Utility type to get strongly types thunks
|
* Utility type to get strongly types thunks
|
||||||
|
|||||||
Reference in New Issue
Block a user