Chore: infer combined reducer state types (#39118)
This commit is contained in:
@@ -46,7 +46,7 @@ export const createRootReducer = () => {
|
||||
...addedReducers,
|
||||
});
|
||||
|
||||
return (state: any, action: AnyAction): any => {
|
||||
return (state: any, action: AnyAction) => {
|
||||
if (action.type !== cleanUpAction.type) {
|
||||
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 { PluginsState } from 'app/types';
|
||||
import { config } from 'app/core/config';
|
||||
@@ -52,7 +52,9 @@ export const {
|
||||
panelPluginLoaded,
|
||||
} = 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 {
|
||||
plugins: pluginsReducer,
|
||||
|
||||
@@ -1,18 +1,9 @@
|
||||
import { combineReducers } from '@reduxjs/toolkit';
|
||||
import { optionsPickerReducer, OptionsPickerState } from '../pickers/OptionsPicker/reducer';
|
||||
import { variableEditorReducer, VariableEditorState } from '../editor/reducer';
|
||||
import { optionsPickerReducer } from '../pickers/OptionsPicker/reducer';
|
||||
import { variableEditorReducer } from '../editor/reducer';
|
||||
import { variablesReducer } from './variablesReducer';
|
||||
import { VariableModel } from '../types';
|
||||
import { transactionReducer, TransactionState } from './transactionReducer';
|
||||
import { variableInspectReducer, VariableInspectState } from '../inspect/reducer';
|
||||
|
||||
export interface TemplatingState {
|
||||
variables: Record<string, VariableModel>;
|
||||
optionsPicker: OptionsPickerState;
|
||||
editor: VariableEditorState;
|
||||
transaction: TransactionState;
|
||||
inspect: VariableInspectState;
|
||||
}
|
||||
import { transactionReducer } from './transactionReducer';
|
||||
import { variableInspectReducer } from '../inspect/reducer';
|
||||
|
||||
export const templatingReducers = combineReducers({
|
||||
editor: variableEditorReducer,
|
||||
@@ -22,6 +13,8 @@ export const templatingReducers = combineReducers({
|
||||
inspect: variableInspectReducer,
|
||||
});
|
||||
|
||||
export type TemplatingState = ReturnType<typeof templatingReducers>;
|
||||
|
||||
export default {
|
||||
templating: templatingReducers,
|
||||
};
|
||||
|
||||
@@ -1,49 +1,8 @@
|
||||
import { ThunkAction, ThunkDispatch as GenericThunkDispatch } from 'redux-thunk';
|
||||
import { Action, PayloadAction } from '@reduxjs/toolkit';
|
||||
import { NavIndex } from '@grafana/data';
|
||||
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';
|
||||
import type { createRootReducer } from 'app/core/reducers/root';
|
||||
|
||||
export interface StoreState {
|
||||
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;
|
||||
}
|
||||
export type StoreState = ReturnType<ReturnType<typeof createRootReducer>>;
|
||||
|
||||
/*
|
||||
* Utility type to get strongly types thunks
|
||||
|
||||
Reference in New Issue
Block a user