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