2023-08-01 12:56:21 +01:00
|
|
|
import { ReducersMapObject } from '@reduxjs/toolkit';
|
2020-01-13 08:03:22 +01:00
|
|
|
import { AnyAction, combineReducers } from 'redux';
|
2022-04-22 14:33:13 +01:00
|
|
|
|
2019-10-08 21:37:07 -07:00
|
|
|
import sharedReducers from 'app/core/reducers';
|
2022-04-22 14:33:13 +01:00
|
|
|
import ldapReducers from 'app/features/admin/state/reducers';
|
2019-10-08 21:37:07 -07:00
|
|
|
import alertingReducers from 'app/features/alerting/state/reducers';
|
|
|
|
|
import apiKeysReducers from 'app/features/api-keys/state/reducers';
|
2023-04-13 17:07:43 +03:00
|
|
|
import authConfigReducers from 'app/features/auth-config/state/reducers';
|
2023-04-12 10:44:01 +01:00
|
|
|
import { browseDashboardsAPI } from 'app/features/browse-dashboards/api/browseDashboardsAPI';
|
2023-04-20 16:37:00 +01:00
|
|
|
import browseDashboardsReducers from 'app/features/browse-dashboards/state/slice';
|
2022-09-22 09:35:04 -03:00
|
|
|
import { publicDashboardApi } from 'app/features/dashboard/api/publicDashboardApi';
|
2022-04-22 14:33:13 +01:00
|
|
|
import panelEditorReducers from 'app/features/dashboard/components/PanelEditor/state/reducers';
|
2019-10-08 21:37:07 -07:00
|
|
|
import dashboardReducers from 'app/features/dashboard/state/reducers';
|
|
|
|
|
import dataSourcesReducers from 'app/features/datasources/state/reducers';
|
2022-04-22 14:33:13 +01:00
|
|
|
import exploreReducers from 'app/features/explore/state/main';
|
|
|
|
|
import foldersReducers from 'app/features/folders/state/reducers';
|
2022-02-21 11:37:49 +00:00
|
|
|
import invitesReducers from 'app/features/invites/state/reducers';
|
2020-03-31 16:29:44 +02:00
|
|
|
import importDashboardReducers from 'app/features/manage-dashboards/state/reducers';
|
2024-04-02 16:01:33 +01:00
|
|
|
import { cloudMigrationAPI } from 'app/features/migrate-to-cloud/api';
|
2022-04-22 14:33:13 +01:00
|
|
|
import organizationReducers from 'app/features/org/state/reducers';
|
2021-10-13 08:53:36 +02:00
|
|
|
import panelsReducers from 'app/features/panel/state/reducers';
|
2022-04-22 14:33:13 +01:00
|
|
|
import { reducer as pluginsReducer } from 'app/features/plugins/admin/state/reducer';
|
|
|
|
|
import userReducers from 'app/features/profile/state/reducers';
|
2022-01-05 15:32:38 +01:00
|
|
|
import serviceAccountsReducer from 'app/features/serviceaccounts/state/reducers';
|
2023-01-17 17:50:14 +01:00
|
|
|
import supportBundlesReducer from 'app/features/support-bundles/state/reducers';
|
2022-04-22 14:33:13 +01:00
|
|
|
import teamsReducers from 'app/features/teams/state/reducers';
|
|
|
|
|
import usersReducers from 'app/features/users/state/reducers';
|
2022-02-18 06:06:04 +01:00
|
|
|
import templatingReducers from 'app/features/variables/state/keyedVariablesReducer';
|
2019-10-08 21:37:07 -07:00
|
|
|
|
2022-08-16 16:01:57 +02:00
|
|
|
import { alertingApi } from '../../features/alerting/unified/api/alertingApi';
|
2025-01-31 17:12:55 +00:00
|
|
|
import { iamApi } from '../../features/iam/api/api';
|
2024-07-05 16:01:10 +03:00
|
|
|
import { userPreferencesAPI } from '../../features/preferences/api';
|
2022-09-05 14:56:08 +02:00
|
|
|
import { cleanUpAction } from '../actions/cleanUp';
|
2022-04-22 14:33:13 +01:00
|
|
|
|
2019-10-08 21:37:07 -07:00
|
|
|
const rootReducers = {
|
|
|
|
|
...sharedReducers,
|
|
|
|
|
...alertingReducers,
|
|
|
|
|
...teamsReducers,
|
|
|
|
|
...apiKeysReducers,
|
|
|
|
|
...foldersReducers,
|
|
|
|
|
...dashboardReducers,
|
|
|
|
|
...exploreReducers,
|
|
|
|
|
...dataSourcesReducers,
|
|
|
|
|
...usersReducers,
|
2022-01-05 15:32:38 +01:00
|
|
|
...serviceAccountsReducer,
|
2019-10-08 21:37:07 -07:00
|
|
|
...userReducers,
|
2022-02-21 11:37:49 +00:00
|
|
|
...invitesReducers,
|
2019-10-08 21:37:07 -07:00
|
|
|
...organizationReducers,
|
2023-04-20 16:37:00 +01:00
|
|
|
...browseDashboardsReducers,
|
2019-10-08 21:37:07 -07:00
|
|
|
...ldapReducers,
|
2020-03-31 16:29:44 +02:00
|
|
|
...importDashboardReducers,
|
2021-10-25 13:55:06 +02:00
|
|
|
...panelEditorReducers,
|
2021-10-13 08:53:36 +02:00
|
|
|
...panelsReducers,
|
2022-02-18 06:06:04 +01:00
|
|
|
...templatingReducers,
|
2023-01-17 17:50:14 +01:00
|
|
|
...supportBundlesReducer,
|
2023-04-13 17:07:43 +03:00
|
|
|
...authConfigReducers,
|
2021-11-19 13:42:26 +01:00
|
|
|
plugins: pluginsReducer,
|
2022-08-16 16:01:57 +02:00
|
|
|
[alertingApi.reducerPath]: alertingApi.reducer,
|
2022-09-22 09:35:04 -03:00
|
|
|
[publicDashboardApi.reducerPath]: publicDashboardApi.reducer,
|
2023-04-12 10:44:01 +01:00
|
|
|
[browseDashboardsAPI.reducerPath]: browseDashboardsAPI.reducer,
|
2024-04-02 16:01:33 +01:00
|
|
|
[cloudMigrationAPI.reducerPath]: cloudMigrationAPI.reducer,
|
2025-01-31 17:12:55 +00:00
|
|
|
[iamApi.reducerPath]: iamApi.reducer,
|
2024-07-05 16:01:10 +03:00
|
|
|
[userPreferencesAPI.reducerPath]: userPreferencesAPI.reducer,
|
2019-10-08 21:37:07 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const addedReducers = {};
|
|
|
|
|
|
2023-08-01 12:56:21 +01:00
|
|
|
export const addReducer = (newReducers: ReducersMapObject) => {
|
2020-01-17 16:05:08 +01:00
|
|
|
Object.assign(addedReducers, newReducers);
|
2019-10-08 21:37:07 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const createRootReducer = () => {
|
|
|
|
|
const appReducer = combineReducers({
|
|
|
|
|
...rootReducers,
|
|
|
|
|
...addedReducers,
|
|
|
|
|
});
|
|
|
|
|
|
2024-05-03 17:21:37 +01:00
|
|
|
return (state: Parameters<typeof appReducer>[0], action: AnyAction) => {
|
2019-10-08 21:37:07 -07:00
|
|
|
if (action.type !== cleanUpAction.type) {
|
|
|
|
|
return appReducer(state, action);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-05 14:56:08 +02:00
|
|
|
const { cleanupAction } = action.payload;
|
|
|
|
|
cleanupAction(state);
|
2019-10-08 21:37:07 -07:00
|
|
|
|
|
|
|
|
return appReducer(state, action);
|
|
|
|
|
};
|
|
|
|
|
};
|