reducers.ts 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { combineReducers } from 'redux';
  2. import { createAsyncMapSlice, createAsyncSlice } from '../utils/redux';
  3. import {
  4. createOrUpdateSilenceAction,
  5. deleteAlertManagerConfigAction,
  6. fetchAlertGroupsAction,
  7. fetchAlertManagerConfigAction,
  8. fetchAmAlertsAction,
  9. fetchEditableRuleAction,
  10. fetchExternalAlertmanagersAction,
  11. fetchExternalAlertmanagersConfigAction,
  12. fetchFolderAction,
  13. fetchGrafanaAnnotationsAction,
  14. fetchGrafanaNotifiersAction,
  15. fetchPromRulesAction,
  16. fetchRulerRulesAction,
  17. fetchRulesSourceBuildInfoAction,
  18. fetchSilencesAction,
  19. saveRuleFormAction,
  20. testReceiversAction,
  21. updateAlertManagerConfigAction,
  22. updateLotexNamespaceAndGroupAction,
  23. } from './actions';
  24. export const reducer = combineReducers({
  25. dataSources: createAsyncMapSlice(
  26. 'dataSources',
  27. fetchRulesSourceBuildInfoAction,
  28. ({ rulesSourceName }) => rulesSourceName
  29. ).reducer,
  30. promRules: createAsyncMapSlice('promRules', fetchPromRulesAction, ({ rulesSourceName }) => rulesSourceName).reducer,
  31. rulerRules: createAsyncMapSlice('rulerRules', fetchRulerRulesAction, ({ rulesSourceName }) => rulesSourceName)
  32. .reducer,
  33. amConfigs: createAsyncMapSlice(
  34. 'amConfigs',
  35. fetchAlertManagerConfigAction,
  36. (alertManagerSourceName) => alertManagerSourceName
  37. ).reducer,
  38. silences: createAsyncMapSlice('silences', fetchSilencesAction, (alertManagerSourceName) => alertManagerSourceName)
  39. .reducer,
  40. ruleForm: combineReducers({
  41. saveRule: createAsyncSlice('saveRule', saveRuleFormAction).reducer,
  42. existingRule: createAsyncSlice('existingRule', fetchEditableRuleAction).reducer,
  43. }),
  44. grafanaNotifiers: createAsyncSlice('grafanaNotifiers', fetchGrafanaNotifiersAction).reducer,
  45. saveAMConfig: createAsyncSlice('saveAMConfig', updateAlertManagerConfigAction).reducer,
  46. deleteAMConfig: createAsyncSlice('deleteAMConfig', deleteAlertManagerConfigAction).reducer,
  47. updateSilence: createAsyncSlice('updateSilence', createOrUpdateSilenceAction).reducer,
  48. amAlerts: createAsyncMapSlice('amAlerts', fetchAmAlertsAction, (alertManagerSourceName) => alertManagerSourceName)
  49. .reducer,
  50. folders: createAsyncMapSlice('folders', fetchFolderAction, (uid) => uid).reducer,
  51. amAlertGroups: createAsyncMapSlice(
  52. 'amAlertGroups',
  53. fetchAlertGroupsAction,
  54. (alertManagerSourceName) => alertManagerSourceName
  55. ).reducer,
  56. testReceivers: createAsyncSlice('testReceivers', testReceiversAction).reducer,
  57. updateLotexNamespaceAndGroup: createAsyncSlice('updateLotexNamespaceAndGroup', updateLotexNamespaceAndGroupAction)
  58. .reducer,
  59. externalAlertmanagers: combineReducers({
  60. alertmanagerConfig: createAsyncSlice('alertmanagerConfig', fetchExternalAlertmanagersConfigAction).reducer,
  61. discoveredAlertmanagers: createAsyncSlice('discoveredAlertmanagers', fetchExternalAlertmanagersAction).reducer,
  62. }),
  63. managedAlertStateHistory: createAsyncSlice('managedAlertStateHistory', fetchGrafanaAnnotationsAction).reducer,
  64. });
  65. export type UnifiedAlertingState = ReturnType<typeof reducer>;
  66. export default reducer;