@spinnaker/kayenta 0.0.0-2025.1-0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) hide show
  1. package/.editorconfig +9 -0
  2. package/.eslintrc.js +1 -0
  3. package/.huskyrc +5 -0
  4. package/.lintstagedrc.json +4 -0
  5. package/.prettierignore +4 -0
  6. package/.prettierrc.js +1 -0
  7. package/LICENSE.txt +203 -0
  8. package/README.md +81 -0
  9. package/__mocks__/styleMock.js +1 -0
  10. package/__mocks__/version.json +4 -0
  11. package/babel.config.js +3 -0
  12. package/build.gradle +67 -0
  13. package/build_scripts/checkLicenses.js +79 -0
  14. package/gradle.properties +0 -0
  15. package/jest.config.js +204 -0
  16. package/jest.setup.js +5 -0
  17. package/package.json +166 -0
  18. package/rollup-plugin-angularjs-template-loader.js +82 -0
  19. package/rollup.config.js +30 -0
  20. package/src/index.ts +2 -0
  21. package/src/kayenta/actions/creators.ts +163 -0
  22. package/src/kayenta/actions/index.ts +98 -0
  23. package/src/kayenta/canary.dataSource.bridge.ts +53 -0
  24. package/src/kayenta/canary.dataSource.stub.ts +64 -0
  25. package/src/kayenta/canary.help.ts +136 -0
  26. package/src/kayenta/canary.less +168 -0
  27. package/src/kayenta/canary.settings.ts +26 -0
  28. package/src/kayenta/canary.tsx +67 -0
  29. package/src/kayenta/components/canaryScore.component.less +77 -0
  30. package/src/kayenta/components/canaryScore.component.ts +12 -0
  31. package/src/kayenta/components/canaryScore.tsx +63 -0
  32. package/src/kayenta/components/canaryScores.component.ts +20 -0
  33. package/src/kayenta/components/canaryScores.less +22 -0
  34. package/src/kayenta/components/canaryScores.tsx +163 -0
  35. package/src/kayenta/components/loadStates.tsx +52 -0
  36. package/src/kayenta/domain/ICanaryConfig.ts +57 -0
  37. package/src/kayenta/domain/ICanaryConfigSummary.ts +7 -0
  38. package/src/kayenta/domain/ICanaryConfigUpdateResponse.ts +3 -0
  39. package/src/kayenta/domain/ICanaryExecutionStatusResult.ts +72 -0
  40. package/src/kayenta/domain/ICanaryJudgeResult.ts +51 -0
  41. package/src/kayenta/domain/ICanaryJudgeResultSummary.ts +5 -0
  42. package/src/kayenta/domain/ICanaryScoreThresholds.ts +4 -0
  43. package/src/kayenta/domain/IJudge.ts +5 -0
  44. package/src/kayenta/domain/IKayentaAccount.ts +14 -0
  45. package/src/kayenta/domain/IKayentaStageConfig.ts +58 -0
  46. package/src/kayenta/domain/IMetricSetPair.ts +17 -0
  47. package/src/kayenta/domain/IMetricsServiceMetadata.ts +2 -0
  48. package/src/kayenta/domain/ISetupCanaryStage.ts +11 -0
  49. package/src/kayenta/domain/MetricClassificationLabel.ts +8 -0
  50. package/src/kayenta/domain/ScoreClassificationLabel.ts +7 -0
  51. package/src/kayenta/domain/index.ts +15 -0
  52. package/src/kayenta/edit/changeMetricGroupModal.tsx +107 -0
  53. package/src/kayenta/edit/configDetail.tsx +31 -0
  54. package/src/kayenta/edit/configDetailActionButtons.tsx +24 -0
  55. package/src/kayenta/edit/configDetailHeader.tsx +104 -0
  56. package/src/kayenta/edit/configDetailLoadStates.tsx +36 -0
  57. package/src/kayenta/edit/configDetailLoader.tsx +60 -0
  58. package/src/kayenta/edit/configJson.less +42 -0
  59. package/src/kayenta/edit/configJsonModal.tsx +158 -0
  60. package/src/kayenta/edit/configList.less +7 -0
  61. package/src/kayenta/edit/configList.tsx +57 -0
  62. package/src/kayenta/edit/copyConfigButton.tsx +34 -0
  63. package/src/kayenta/edit/createConfigButton.tsx +34 -0
  64. package/src/kayenta/edit/deleteModal.tsx +87 -0
  65. package/src/kayenta/edit/edit.tsx +24 -0
  66. package/src/kayenta/edit/editMetricEffectSizes.tsx +186 -0
  67. package/src/kayenta/edit/editMetricModal.less +9 -0
  68. package/src/kayenta/edit/editMetricModal.spec.tsx +129 -0
  69. package/src/kayenta/edit/editMetricModal.tsx +294 -0
  70. package/src/kayenta/edit/editMetricValidation.spec.ts +63 -0
  71. package/src/kayenta/edit/editMetricValidation.ts +50 -0
  72. package/src/kayenta/edit/filterTemplateSelector.less +15 -0
  73. package/src/kayenta/edit/filterTemplateSelector.spec.tsx +106 -0
  74. package/src/kayenta/edit/filterTemplateSelector.tsx +194 -0
  75. package/src/kayenta/edit/filterTemplatesValidation.spec.ts +108 -0
  76. package/src/kayenta/edit/filterTemplatesValidation.ts +95 -0
  77. package/src/kayenta/edit/footer.less +30 -0
  78. package/src/kayenta/edit/footer.tsx +12 -0
  79. package/src/kayenta/edit/groupName.tsx +80 -0
  80. package/src/kayenta/edit/groupTabs.tsx +106 -0
  81. package/src/kayenta/edit/groupWeight.tsx +80 -0
  82. package/src/kayenta/edit/groupWeights.tsx +38 -0
  83. package/src/kayenta/edit/inlineTemplateEditor.spec.tsx +42 -0
  84. package/src/kayenta/edit/inlineTemplateEditor.tsx +61 -0
  85. package/src/kayenta/edit/judgeSelect.tsx +82 -0
  86. package/src/kayenta/edit/metricConfigurerDelegator.tsx +30 -0
  87. package/src/kayenta/edit/metricList.less +21 -0
  88. package/src/kayenta/edit/metricList.tsx +215 -0
  89. package/src/kayenta/edit/metricStoreSelector.tsx +66 -0
  90. package/src/kayenta/edit/nameAndDescription.tsx +90 -0
  91. package/src/kayenta/edit/openConfigJsonModalButton.tsx +33 -0
  92. package/src/kayenta/edit/openDeleteModalButton.tsx +50 -0
  93. package/src/kayenta/edit/ownedBy.tsx +34 -0
  94. package/src/kayenta/edit/save.tsx +19 -0
  95. package/src/kayenta/edit/saveConfigButton.tsx +65 -0
  96. package/src/kayenta/edit/saveConfigError.tsx +59 -0
  97. package/src/kayenta/edit/scoring.tsx +35 -0
  98. package/src/kayenta/edit/selectConfig.tsx +10 -0
  99. package/src/kayenta/edit/validationErrors.tsx +39 -0
  100. package/src/kayenta/index.ts +6 -0
  101. package/src/kayenta/layout/addNewButton.tsx +20 -0
  102. package/src/kayenta/layout/centeredDetail.tsx +13 -0
  103. package/src/kayenta/layout/deleteButton.tsx +11 -0
  104. package/src/kayenta/layout/disableable.tsx +87 -0
  105. package/src/kayenta/layout/formList.tsx +26 -0
  106. package/src/kayenta/layout/formRow.tsx +36 -0
  107. package/src/kayenta/layout/formattedDate.tsx +14 -0
  108. package/src/kayenta/layout/index.ts +2 -0
  109. package/src/kayenta/layout/keyValueList.less +20 -0
  110. package/src/kayenta/layout/keyValueList.tsx +114 -0
  111. package/src/kayenta/layout/list.less +9 -0
  112. package/src/kayenta/layout/list.spec.tsx +83 -0
  113. package/src/kayenta/layout/list.tsx +73 -0
  114. package/src/kayenta/layout/listDetail.tsx +33 -0
  115. package/src/kayenta/layout/radioChoice.tsx +29 -0
  116. package/src/kayenta/layout/styleguide.tsx +16 -0
  117. package/src/kayenta/layout/table/index.ts +5 -0
  118. package/src/kayenta/layout/table/nativeTable.tsx +51 -0
  119. package/src/kayenta/layout/table/nativeTableHeader.tsx +26 -0
  120. package/src/kayenta/layout/table/table.tsx +56 -0
  121. package/src/kayenta/layout/table/tableColumn.ts +7 -0
  122. package/src/kayenta/layout/table/tableHeader.tsx +23 -0
  123. package/src/kayenta/layout/tabs.tsx +26 -0
  124. package/src/kayenta/layout/titledSection.less +16 -0
  125. package/src/kayenta/layout/titledSection.tsx +20 -0
  126. package/src/kayenta/layout/titledSubsection.less +11 -0
  127. package/src/kayenta/layout/titledSubsection.tsx +22 -0
  128. package/src/kayenta/manualAnalysis/ManualAnalysisModal.tsx +716 -0
  129. package/src/kayenta/metricStore/atlas/atlasMetricConfigurer.tsx +130 -0
  130. package/src/kayenta/metricStore/atlas/index.ts +8 -0
  131. package/src/kayenta/metricStore/datadog/domain/IDatadogMetricDescriptor.ts +5 -0
  132. package/src/kayenta/metricStore/datadog/index.ts +9 -0
  133. package/src/kayenta/metricStore/datadog/metricConfigurer.tsx +90 -0
  134. package/src/kayenta/metricStore/datadog/metricTypeSelector.spec.tsx +59 -0
  135. package/src/kayenta/metricStore/datadog/metricTypeSelector.tsx +73 -0
  136. package/src/kayenta/metricStore/graphite/domain/IGraphiteMetricDescriptor.ts +5 -0
  137. package/src/kayenta/metricStore/graphite/index.ts +8 -0
  138. package/src/kayenta/metricStore/graphite/metricConfigurer.tsx +54 -0
  139. package/src/kayenta/metricStore/graphite/metricTypeSelector.tsx +80 -0
  140. package/src/kayenta/metricStore/graphite/typeahead.less +3 -0
  141. package/src/kayenta/metricStore/index.ts +8 -0
  142. package/src/kayenta/metricStore/metricStoreConfig.service.ts +12 -0
  143. package/src/kayenta/metricStore/newrelic/domain/INewRelicMetricDescriptor.ts +5 -0
  144. package/src/kayenta/metricStore/newrelic/index.ts +8 -0
  145. package/src/kayenta/metricStore/newrelic/metricConfigurer.tsx +58 -0
  146. package/src/kayenta/metricStore/prometheus/domain/IPrometheusCanaryMetricSetQueryConfig.ts +14 -0
  147. package/src/kayenta/metricStore/prometheus/domain/IPrometheusMetricDescriptor.ts +5 -0
  148. package/src/kayenta/metricStore/prometheus/index.ts +12 -0
  149. package/src/kayenta/metricStore/prometheus/metricConfigurer.tsx +157 -0
  150. package/src/kayenta/metricStore/prometheus/metricTypeSelector.less +5 -0
  151. package/src/kayenta/metricStore/prometheus/metricTypeSelector.spec.tsx +62 -0
  152. package/src/kayenta/metricStore/prometheus/metricTypeSelector.tsx +144 -0
  153. package/src/kayenta/metricStore/prometheus/queryTypeSelectors.spec.ts +61 -0
  154. package/src/kayenta/metricStore/prometheus/queryTypeSelectors.ts +38 -0
  155. package/src/kayenta/metricStore/signalfx/domain/ISignalFxCanaryMetricSetQueryConfig.ts +7 -0
  156. package/src/kayenta/metricStore/signalfx/index.ts +8 -0
  157. package/src/kayenta/metricStore/signalfx/metricConfigurer.less +10 -0
  158. package/src/kayenta/metricStore/signalfx/metricConfigurer.tsx +187 -0
  159. package/src/kayenta/metricStore/stackdriver/domain/IStackdriverCanaryMetricSetQueryConfig.ts +9 -0
  160. package/src/kayenta/metricStore/stackdriver/domain/IStackdriverMetricDescriptor.ts +17 -0
  161. package/src/kayenta/metricStore/stackdriver/index.ts +12 -0
  162. package/src/kayenta/metricStore/stackdriver/metricConfigurer.tsx +144 -0
  163. package/src/kayenta/metricStore/stackdriver/metricTypeSelector.spec.tsx +92 -0
  164. package/src/kayenta/metricStore/stackdriver/metricTypeSelector.tsx +113 -0
  165. package/src/kayenta/middleware/actionInterceptor.ts +29 -0
  166. package/src/kayenta/middleware/asyncDispatch.ts +37 -0
  167. package/src/kayenta/middleware/epics.ts +211 -0
  168. package/src/kayenta/middleware/index.ts +3 -0
  169. package/src/kayenta/navigation/canary.states.stub.ts +28 -0
  170. package/src/kayenta/navigation/canary.states.ts +182 -0
  171. package/src/kayenta/reducers/app.ts +56 -0
  172. package/src/kayenta/reducers/asyncRequest.ts +5 -0
  173. package/src/kayenta/reducers/data.ts +169 -0
  174. package/src/kayenta/reducers/editingTemplate.ts +54 -0
  175. package/src/kayenta/reducers/group.ts +82 -0
  176. package/src/kayenta/reducers/index.ts +245 -0
  177. package/src/kayenta/reducers/prometheusMetricConfig.spec.ts +33 -0
  178. package/src/kayenta/reducers/prometheusMetricConfig.ts +56 -0
  179. package/src/kayenta/reducers/selectedConfig.spec.ts +190 -0
  180. package/src/kayenta/reducers/selectedConfig.ts +566 -0
  181. package/src/kayenta/reducers/selectedRun.ts +101 -0
  182. package/src/kayenta/reducers/signalFxMetricConfig.ts +36 -0
  183. package/src/kayenta/reducers/stackdriverMetricConfig.spec.ts +33 -0
  184. package/src/kayenta/reducers/stackdriverMetricConfig.ts +41 -0
  185. package/src/kayenta/reducers/templates.spec.ts +192 -0
  186. package/src/kayenta/reducers/validators.ts +118 -0
  187. package/src/kayenta/report/detail/allMetricResultsHeader.tsx +32 -0
  188. package/src/kayenta/report/detail/clickableHeader.tsx +21 -0
  189. package/src/kayenta/report/detail/colors.ts +47 -0
  190. package/src/kayenta/report/detail/detail.less +16 -0
  191. package/src/kayenta/report/detail/detail.tsx +48 -0
  192. package/src/kayenta/report/detail/detailLoader.tsx +55 -0
  193. package/src/kayenta/report/detail/graph/graph.tsx +37 -0
  194. package/src/kayenta/report/detail/graph/metricSetPairGraph.service.ts +35 -0
  195. package/src/kayenta/report/detail/graph/semiotic/boxplot.less +45 -0
  196. package/src/kayenta/report/detail/graph/semiotic/boxplot.tsx +283 -0
  197. package/src/kayenta/report/detail/graph/semiotic/chartHeader.tsx +19 -0
  198. package/src/kayenta/report/detail/graph/semiotic/chartLegend.less +26 -0
  199. package/src/kayenta/report/detail/graph/semiotic/chartLegend.tsx +42 -0
  200. package/src/kayenta/report/detail/graph/semiotic/circleIcon.tsx +16 -0
  201. package/src/kayenta/report/detail/graph/semiotic/config.less +5 -0
  202. package/src/kayenta/report/detail/graph/semiotic/config.ts +38 -0
  203. package/src/kayenta/report/detail/graph/semiotic/customAxisTickLabel.tsx +17 -0
  204. package/src/kayenta/report/detail/graph/semiotic/declarations/labella.d.ts +16 -0
  205. package/src/kayenta/report/detail/graph/semiotic/declarations/react-container-dimensions.d.ts +3 -0
  206. package/src/kayenta/report/detail/graph/semiotic/declarations/semiotic.d.ts +160 -0
  207. package/src/kayenta/report/detail/graph/semiotic/differenceArea.less +17 -0
  208. package/src/kayenta/report/detail/graph/semiotic/differenceArea.tsx +186 -0
  209. package/src/kayenta/report/detail/graph/semiotic/histogram.less +22 -0
  210. package/src/kayenta/report/detail/graph/semiotic/histogram.tsx +251 -0
  211. package/src/kayenta/report/detail/graph/semiotic/index.tsx +19 -0
  212. package/src/kayenta/report/detail/graph/semiotic/noValidDataSign.less +5 -0
  213. package/src/kayenta/report/detail/graph/semiotic/noValidDataSign.tsx +10 -0
  214. package/src/kayenta/report/detail/graph/semiotic/secondaryTSXAxis.less +6 -0
  215. package/src/kayenta/report/detail/graph/semiotic/secondaryTSXAxis.tsx +58 -0
  216. package/src/kayenta/report/detail/graph/semiotic/semiotic.service.ts +32 -0
  217. package/src/kayenta/report/detail/graph/semiotic/semioticGraph.less +53 -0
  218. package/src/kayenta/report/detail/graph/semiotic/semioticGraph.tsx +49 -0
  219. package/src/kayenta/report/detail/graph/semiotic/timeSeries.less +42 -0
  220. package/src/kayenta/report/detail/graph/semiotic/timeSeries.tsx +473 -0
  221. package/src/kayenta/report/detail/graph/semiotic/tooltip.tsx +55 -0
  222. package/src/kayenta/report/detail/graph/semiotic/utils.ts +90 -0
  223. package/src/kayenta/report/detail/graphTypeSelector.less +4 -0
  224. package/src/kayenta/report/detail/graphTypeSelector.tsx +50 -0
  225. package/src/kayenta/report/detail/groupScores.tsx +68 -0
  226. package/src/kayenta/report/detail/header.less +70 -0
  227. package/src/kayenta/report/detail/header.tsx +39 -0
  228. package/src/kayenta/report/detail/headerArrow.tsx +13 -0
  229. package/src/kayenta/report/detail/loadStates.tsx +31 -0
  230. package/src/kayenta/report/detail/metricResultActions.less +29 -0
  231. package/src/kayenta/report/detail/metricResultActions.tsx +87 -0
  232. package/src/kayenta/report/detail/metricResultClassification.tsx +22 -0
  233. package/src/kayenta/report/detail/metricResultDetail.tsx +20 -0
  234. package/src/kayenta/report/detail/metricResultDetailLayout.tsx +19 -0
  235. package/src/kayenta/report/detail/metricResultDeviation.tsx +25 -0
  236. package/src/kayenta/report/detail/metricResultStats.less +9 -0
  237. package/src/kayenta/report/detail/metricResultStats.tsx +120 -0
  238. package/src/kayenta/report/detail/metricResults.less +12 -0
  239. package/src/kayenta/report/detail/metricResults.tsx +52 -0
  240. package/src/kayenta/report/detail/metricResultsClassificationFilters.tsx +65 -0
  241. package/src/kayenta/report/detail/metricResultsColumns.tsx +27 -0
  242. package/src/kayenta/report/detail/metricResultsList.less +44 -0
  243. package/src/kayenta/report/detail/metricResultsList.tsx +120 -0
  244. package/src/kayenta/report/detail/metricSetPairLoadStates.tsx +22 -0
  245. package/src/kayenta/report/detail/multipleResultsTable.tsx +81 -0
  246. package/src/kayenta/report/detail/reportException.tsx +57 -0
  247. package/src/kayenta/report/detail/reportExplanation.less +12 -0
  248. package/src/kayenta/report/detail/reportExplanation.tsx +32 -0
  249. package/src/kayenta/report/detail/reportMetadata.tsx +167 -0
  250. package/src/kayenta/report/detail/reportScores.less +47 -0
  251. package/src/kayenta/report/detail/reportScores.tsx +80 -0
  252. package/src/kayenta/report/detail/score.tsx +33 -0
  253. package/src/kayenta/report/detail/sourceLinks.tsx +69 -0
  254. package/src/kayenta/report/list/configLink.tsx +32 -0
  255. package/src/kayenta/report/list/executionList.less +7 -0
  256. package/src/kayenta/report/list/loadStates.tsx +32 -0
  257. package/src/kayenta/report/list/pipelineLink.tsx +15 -0
  258. package/src/kayenta/report/list/reportLink.tsx +33 -0
  259. package/src/kayenta/report/list/table.tsx +309 -0
  260. package/src/kayenta/report/report.tsx +11 -0
  261. package/src/kayenta/selectors/filterTemplatesSelectors.ts +87 -0
  262. package/src/kayenta/selectors/index.ts +62 -0
  263. package/src/kayenta/service/canaryConfig.service.ts +122 -0
  264. package/src/kayenta/service/canaryRun.service.ts +60 -0
  265. package/src/kayenta/service/delegateFactory.ts +24 -0
  266. package/src/kayenta/service/metricsServiceMetadata.service.ts +9 -0
  267. package/src/kayenta/stages/kayentaStage/AnalysisType.spec.tsx +47 -0
  268. package/src/kayenta/stages/kayentaStage/AnalysisType.tsx +49 -0
  269. package/src/kayenta/stages/kayentaStage/CanaryExecutionLabel.tsx +26 -0
  270. package/src/kayenta/stages/kayentaStage/analysisType.component.ts +12 -0
  271. package/src/kayenta/stages/kayentaStage/canaryRunSummaries.component.ts +12 -0
  272. package/src/kayenta/stages/kayentaStage/canaryRunSummaries.less +5 -0
  273. package/src/kayenta/stages/kayentaStage/canaryRunSummaries.tsx +136 -0
  274. package/src/kayenta/stages/kayentaStage/forAnalysisType.component.ts +45 -0
  275. package/src/kayenta/stages/kayentaStage/kayentaStage.controller.ts +789 -0
  276. package/src/kayenta/stages/kayentaStage/kayentaStage.html +528 -0
  277. package/src/kayenta/stages/kayentaStage/kayentaStage.less +5 -0
  278. package/src/kayenta/stages/kayentaStage/kayentaStage.transformer.ts +179 -0
  279. package/src/kayenta/stages/kayentaStage/kayentaStage.ts +221 -0
  280. package/src/kayenta/stages/kayentaStage/kayentaStageConfigSection.component.ts +21 -0
  281. package/src/kayenta/stages/kayentaStage/kayentaStageExecutionDetails.controller.ts +88 -0
  282. package/src/kayenta/stages/kayentaStage/kayentaStageExecutionDetails.html +114 -0
  283. package/src/kayenta/stages/kayentaStage/kayentaStageExecutionDetails.less +6 -0
  284. package/src/kayenta/stages/kayentaStage/stageTypes.ts +5 -0
  285. package/src/kayenta/utils/duration.spec.ts +69 -0
  286. package/src/kayenta/utils/duration.ts +48 -0
  287. package/src/lazy.ts +29 -0
  288. package/src/stub.ts +60 -0
  289. package/tsconfig.json +11 -0
@@ -0,0 +1,566 @@
1
+ import { chain, cloneDeep, flatMap, fromPairs, get, has, omit, pick, set, unset } from 'lodash';
2
+ import { Action, combineReducers } from 'redux';
3
+ import { combineActions, handleActions } from 'redux-actions';
4
+
5
+ import * as Actions from '../actions';
6
+ import { AsyncRequestState } from './asyncRequest';
7
+ import { CanarySettings } from '../canary.settings';
8
+ import { ICanaryConfig, ICanaryJudgeConfig, ICanaryMetricConfig, IGroupWeights } from '../domain/ICanaryConfig';
9
+ import { IJudge } from '../domain/IJudge';
10
+ import { ALL } from '../edit/groupTabs';
11
+ import { JudgeSelectRenderState } from '../edit/judgeSelect';
12
+ import { editingTemplate, IEditingTemplateState } from './editingTemplate';
13
+ import { group, IGroupState } from './group';
14
+ import { prometheusMetricConfigReducer } from './prometheusMetricConfig';
15
+ import { signalFxMetricConfigReducer } from './signalFxMetricConfig';
16
+ import { stackdriverMetricConfigReducer } from './stackdriverMetricConfig';
17
+ import { IConfigValidationError } from './validators';
18
+
19
+ export interface ILoadState {
20
+ state: AsyncRequestState;
21
+ }
22
+
23
+ export interface ISaveState {
24
+ state: AsyncRequestState;
25
+ error: string;
26
+ }
27
+
28
+ // Mixing destroy/delete here because delete is a JS keyword.
29
+ export interface IDestroyState {
30
+ state: AsyncRequestState;
31
+ error: string;
32
+ }
33
+
34
+ export interface IJsonState {
35
+ configJson: string;
36
+ error: string;
37
+ }
38
+
39
+ export interface IJudgeState {
40
+ judgeConfig: ICanaryJudgeConfig;
41
+ renderState: JudgeSelectRenderState;
42
+ }
43
+
44
+ export interface IChangeMetricGroupState {
45
+ metric: string;
46
+ toGroup: string;
47
+ }
48
+
49
+ export interface ISelectedConfigState {
50
+ config: ICanaryConfig;
51
+ isInSyncWithServer: boolean;
52
+ metricList: ICanaryMetricConfig[];
53
+ editingMetric: ICanaryMetricConfig;
54
+ judge: IJudgeState;
55
+ group: IGroupState;
56
+ load: ILoadState;
57
+ save: ISaveState;
58
+ destroy: IDestroyState;
59
+ json: IJsonState;
60
+ changeMetricGroup: IChangeMetricGroupState;
61
+ validationErrors: IConfigValidationError[];
62
+ editingTemplate: IEditingTemplateState;
63
+ selectedStore: string;
64
+ }
65
+
66
+ const config = handleActions(
67
+ {
68
+ [Actions.SELECT_CONFIG]: (_state: ICanaryConfig, action: Action & any) => action.payload.config,
69
+ [Actions.UPDATE_CONFIG_NAME]: (state: ICanaryConfig, action: Action & any) => ({
70
+ ...state,
71
+ name: action.payload.name,
72
+ }),
73
+ [Actions.UPDATE_CONFIG_DESCRIPTION]: (state: ICanaryConfig, action: Action & any) => ({
74
+ ...state,
75
+ description: action.payload.description,
76
+ }),
77
+ [combineActions(Actions.DELETE_CONFIG_SUCCESS, Actions.CLEAR_SELECTED_CONFIG)]: () => null,
78
+ [Actions.DELETE_TEMPLATE]: (state: ICanaryConfig, action: Action & any) => {
79
+ if (!action.payload.name) {
80
+ return state;
81
+ }
82
+
83
+ return {
84
+ ...state,
85
+ templates: omit(state.templates, action.payload.name),
86
+ };
87
+ },
88
+ },
89
+ null,
90
+ );
91
+
92
+ const load = combineReducers({
93
+ state: handleActions(
94
+ {
95
+ [Actions.LOAD_CONFIG_REQUEST]: () => AsyncRequestState.Requesting,
96
+ [Actions.LOAD_CONFIG_FAILURE]: () => AsyncRequestState.Failed,
97
+ [Actions.SELECT_CONFIG]: () => AsyncRequestState.Fulfilled,
98
+ },
99
+ AsyncRequestState.Requesting,
100
+ ),
101
+ });
102
+
103
+ function idMetrics(metrics: ICanaryMetricConfig[] = []) {
104
+ return metrics.map((metric, index) => ({ ...metric, id: '#' + index }));
105
+ }
106
+
107
+ const metricList = handleActions(
108
+ {
109
+ [Actions.SELECT_CONFIG]: (_state: ICanaryMetricConfig[], action: Action & any) =>
110
+ idMetrics(action.payload.config.metrics),
111
+ [Actions.ADD_METRIC]: (state: ICanaryMetricConfig[], action: Action & any) =>
112
+ idMetrics(state.concat([action.payload.metric])),
113
+ [Actions.REMOVE_METRIC]: (state: ICanaryMetricConfig[], action: Action & any) =>
114
+ idMetrics(state.filter((metric) => metric.id !== action.payload.id)),
115
+ [Actions.DELETE_TEMPLATE]: (state: ICanaryMetricConfig[], action: Action & any) =>
116
+ state.map((m) => removeDeletedTemplateFromMetric(m, action.payload.name)),
117
+ },
118
+ [],
119
+ );
120
+
121
+ function removeDeletedTemplateFromMetric(metric: ICanaryMetricConfig, deletedTemplateName: string) {
122
+ if (get(metric, 'query.customFilterTemplate') === deletedTemplateName) {
123
+ return {
124
+ ...metric,
125
+ query: {
126
+ ...metric.query,
127
+ customFilterTemplate: null,
128
+ },
129
+ };
130
+ }
131
+ return metric;
132
+ }
133
+
134
+ const editingMetric = handleActions(
135
+ {
136
+ [Actions.RENAME_METRIC]: (state: ICanaryMetricConfig, action: Action & any) => ({
137
+ ...state,
138
+ name: action.payload.name,
139
+ }),
140
+ [Actions.UPDATE_METRIC_DIRECTION]: (state: ICanaryMetricConfig, action: Action & any) =>
141
+ set(cloneDeep(state), ['analysisConfigurations', 'canary', 'direction'], action.payload.direction),
142
+ [Actions.UPDATE_METRIC_NAN_STRATEGY]: (state: ICanaryMetricConfig, { payload }: Action & any) => {
143
+ const newState = cloneDeep(state);
144
+
145
+ payload.strategy === 'default'
146
+ ? unset(newState, ['analysisConfigurations', 'canary', 'nanStrategy'])
147
+ : set(newState, ['analysisConfigurations', 'canary', 'nanStrategy'], payload.strategy);
148
+
149
+ return newState;
150
+ },
151
+ [Actions.UPDATE_METRIC_OUTLIER_STRATEGY]: (state: ICanaryMetricConfig, { payload }: Action & any) => {
152
+ const newState = cloneDeep(state);
153
+
154
+ payload.strategy === 'default'
155
+ ? unset(newState, ['analysisConfigurations', 'canary', 'outliers', 'strategy'])
156
+ : set(newState, ['analysisConfigurations', 'canary', 'outliers', 'strategy'], payload.strategy);
157
+
158
+ return newState;
159
+ },
160
+ [Actions.UPDATE_METRIC_CRITICALITY]: (state: ICanaryMetricConfig, { payload }: Action & any) => {
161
+ const newState = cloneDeep(state);
162
+
163
+ payload.critical
164
+ ? set(newState, ['analysisConfigurations', 'canary', 'critical'], payload.critical)
165
+ : unset(newState, ['analysisConfigurations', 'canary', 'critical']);
166
+
167
+ return newState;
168
+ },
169
+ [Actions.UPDATE_METRIC_DATA_REQUIRED]: (state: ICanaryMetricConfig, { payload }: Action & any) => {
170
+ const newState = cloneDeep(state);
171
+ payload.mustHaveData
172
+ ? set(newState, ['analysisConfigurations', 'canary', 'mustHaveData'], payload.mustHaveData)
173
+ : unset(newState, ['analysisConfigurations', 'canary', 'mustHaveData']);
174
+
175
+ return newState;
176
+ },
177
+ [Actions.UPDATE_EFFECT_SIZE]: (state: ICanaryMetricConfig, { payload }: Action & any) => {
178
+ const newState = cloneDeep(state);
179
+ Object.keys(payload.value).length
180
+ ? set(newState, ['analysisConfigurations', 'canary', 'effectSize'], payload.value)
181
+ : unset(newState, ['analysisConfigurations', 'canary', 'effectSize']);
182
+ return newState;
183
+ },
184
+ [Actions.UPDATE_METRIC_GROUP]: (state: ICanaryMetricConfig, action: Action & any) => ({
185
+ ...state,
186
+ groups: [action.payload.group],
187
+ }),
188
+ [Actions.UPDATE_ATLAS_QUERY]: (state: ICanaryMetricConfig, action: Action & any) => ({
189
+ ...state,
190
+ query: { ...state.query, q: action.query },
191
+ }),
192
+ [Actions.UPDATE_DATADOG_METRIC_NAME]: (state: ICanaryMetricConfig, action: Action & any) => ({
193
+ ...state,
194
+ query: { ...state.query, metricName: action.payload.metricName },
195
+ }),
196
+ [Actions.UPDATE_NEWRELIC_SELECT]: (state: ICanaryMetricConfig, action: Action & any) => ({
197
+ ...state,
198
+ query: { ...state.query, select: action.payload.select },
199
+ }),
200
+ [Actions.SELECT_TEMPLATE]: (state: ICanaryMetricConfig, action: Action & any) => ({
201
+ ...state,
202
+ query: { ...state.query, customFilterTemplate: action.payload.name },
203
+ }),
204
+ [Actions.UPDATE_METRIC_SCOPE_NAME]: (state: ICanaryMetricConfig, action: Action & any) => ({
205
+ ...state,
206
+ scopeName: action.payload.scopeName,
207
+ }),
208
+ [Actions.UPDATE_GRAPHITE_METRIC_NAME]: (state: ICanaryMetricConfig, action: Action & any) => ({
209
+ ...state,
210
+ query: { ...state.query, metricName: action.payload.metricName },
211
+ }),
212
+ [Actions.EDIT_INLINE_TEMPLATE]: (state: ICanaryMetricConfig, action: Action & any) => ({
213
+ ...state,
214
+ query: { ...state.query, customInlineTemplate: action.payload.value },
215
+ }),
216
+ },
217
+ null,
218
+ );
219
+
220
+ const save = combineReducers<ISaveState>({
221
+ state: handleActions(
222
+ {
223
+ [Actions.SAVE_CONFIG_REQUEST]: () => AsyncRequestState.Requesting,
224
+ [combineActions(Actions.SAVE_CONFIG_SUCCESS, Actions.DISMISS_SAVE_CONFIG_ERROR)]: () =>
225
+ AsyncRequestState.Fulfilled,
226
+ [Actions.SAVE_CONFIG_FAILURE]: () => AsyncRequestState.Failed,
227
+ },
228
+ AsyncRequestState.Fulfilled,
229
+ ),
230
+ error: handleActions(
231
+ {
232
+ [Actions.SAVE_CONFIG_FAILURE]: (_state: string, action: Action & any) =>
233
+ get(action, 'payload.error.data.message', null),
234
+ },
235
+ null,
236
+ ),
237
+ });
238
+
239
+ const destroy = combineReducers<IDestroyState>({
240
+ state: handleActions(
241
+ {
242
+ [Actions.DELETE_CONFIG_REQUEST]: () => AsyncRequestState.Requesting,
243
+ [Actions.DELETE_CONFIG_SUCCESS]: () => AsyncRequestState.Fulfilled,
244
+ [Actions.DELETE_CONFIG_FAILURE]: () => AsyncRequestState.Failed,
245
+ },
246
+ AsyncRequestState.Fulfilled,
247
+ ),
248
+ error: handleActions(
249
+ {
250
+ [Actions.DELETE_CONFIG_FAILURE]: (_state: string, action: Action & any) =>
251
+ get(action, 'payload.error.data.message', null),
252
+ },
253
+ null,
254
+ ),
255
+ });
256
+
257
+ const json = combineReducers<IJsonState>({
258
+ configJson: handleActions(
259
+ {
260
+ [Actions.SET_CONFIG_JSON]: (_state: IJsonState, action: Action & any) => action.payload.json,
261
+ [combineActions(Actions.CONFIG_JSON_MODAL_CLOSE, Actions.SELECT_CONFIG)]: (): void => null,
262
+ },
263
+ null,
264
+ ),
265
+ error: handleActions(
266
+ {
267
+ [combineActions(Actions.CONFIG_JSON_MODAL_CLOSE, Actions.SELECT_CONFIG, Actions.SET_CONFIG_JSON)]: () => null,
268
+ [Actions.SET_CONFIG_JSON]: (_state: IJsonState, action: Action & any) => {
269
+ try {
270
+ const parsed: ICanaryConfig = JSON.parse(action.payload.json);
271
+ parsed.metrics.forEach((m, index) => {
272
+ if (!m.groups || !m.groups.length) {
273
+ throw new Error(`metric #${index + 1}: 'groups' is a required field`);
274
+ }
275
+ });
276
+ return null;
277
+ } catch (e) {
278
+ return e.message;
279
+ }
280
+ },
281
+ },
282
+ null,
283
+ ),
284
+ });
285
+
286
+ const judge = combineReducers<IJudgeState>({
287
+ judgeConfig: handleActions(
288
+ {
289
+ [Actions.SELECT_JUDGE_NAME]: (state: IJudge, action: Action & any) => ({
290
+ ...state,
291
+ name: action.payload.judge.name,
292
+ }),
293
+ },
294
+ null,
295
+ ),
296
+ renderState: handleActions({}, JudgeSelectRenderState.None),
297
+ });
298
+
299
+ const changeMetricGroup = combineReducers<IChangeMetricGroupState>({
300
+ toGroup: handleActions(
301
+ {
302
+ [Actions.CHANGE_METRIC_GROUP_SELECT]: (_state: string, action: Action & any) => action.payload.group,
303
+ [Actions.CHANGE_METRIC_GROUP]: () => null,
304
+ },
305
+ null,
306
+ ),
307
+ metric: handleActions(
308
+ {
309
+ [Actions.CHANGE_METRIC_GROUP]: (_state: string, action: Action & any) => action.payload.id,
310
+ [Actions.CHANGE_METRIC_GROUP_CONFIRM]: () => null,
311
+ },
312
+ null,
313
+ ),
314
+ });
315
+
316
+ const isInSyncWithServer = handleActions({}, null);
317
+
318
+ // This reducer needs to be able to access both metricList and editingMetric so it won't fit the combineReducers paradigm.
319
+ function editingMetricReducer(state: ISelectedConfigState = null, action: Action & any): ISelectedConfigState {
320
+ switch (action.type) {
321
+ case Actions.ADD_METRIC:
322
+ return {
323
+ ...state,
324
+ editingMetric: state.metricList[state.metricList.length - 1],
325
+ };
326
+
327
+ case Actions.EDIT_METRIC_BEGIN:
328
+ return {
329
+ ...state,
330
+ editingMetric: state.metricList.find((metric) => metric.id === action.payload.id),
331
+ };
332
+
333
+ case Actions.EDIT_METRIC_CONFIRM: {
334
+ const editing: ICanaryMetricConfig = omit(state.editingMetric, 'isNew');
335
+ return {
336
+ ...state,
337
+ metricList: state.metricList.map((metric) => (metric.id === editing.id ? editing : metric)),
338
+ editingMetric: null,
339
+ };
340
+ }
341
+
342
+ case Actions.EDIT_METRIC_CANCEL:
343
+ return {
344
+ ...state,
345
+ metricList: state.metricList.filter((metric) => !metric.isNew),
346
+ editingMetric: null,
347
+ };
348
+
349
+ default:
350
+ return state;
351
+ }
352
+ }
353
+
354
+ function selectedJudgeReducer(state: ISelectedConfigState = null, action: Action & any): ISelectedConfigState {
355
+ switch (action.type) {
356
+ case Actions.SELECT_CONFIG:
357
+ if (has(action, 'payload.config.judge')) {
358
+ return { ...state, judge: { ...state.judge, judgeConfig: { ...action.payload.config.judge } } };
359
+ } else {
360
+ return {
361
+ ...state,
362
+ judge: {
363
+ ...state.judge,
364
+ judgeConfig: { name: CanarySettings.defaultJudge || 'NetflixACAJudge-v1.0', judgeConfigurations: {} },
365
+ },
366
+ };
367
+ }
368
+
369
+ default:
370
+ return state;
371
+ }
372
+ }
373
+
374
+ export function editGroupConfirmReducer(
375
+ state: ISelectedConfigState = null,
376
+ action: Action & any,
377
+ ): ISelectedConfigState {
378
+ if (action.type !== Actions.EDIT_GROUP_CONFIRM) {
379
+ return state;
380
+ }
381
+
382
+ const { payload } = action;
383
+ const allGroups = flatMap(state.metricList, (metric) => metric.groups);
384
+ if (!payload.edit || payload.edit === ALL || allGroups.includes(payload.edit)) {
385
+ return state;
386
+ }
387
+
388
+ const metricUpdater = (c: ICanaryMetricConfig): ICanaryMetricConfig => ({
389
+ ...c,
390
+ groups: (c.groups || []).includes(payload.group)
391
+ ? [payload.edit].concat((c.groups || []).filter((g) => g !== payload.group))
392
+ : c.groups,
393
+ });
394
+
395
+ const weightsUpdater = (weights: IGroupWeights): IGroupWeights => {
396
+ const weight = weights[payload.group];
397
+ weights = omit(weights, payload.group);
398
+ return {
399
+ ...weights,
400
+ [payload.edit]: weight,
401
+ };
402
+ };
403
+
404
+ const listUpdater = (groupList: string[]): string[] =>
405
+ [payload.edit].concat((groupList || []).filter((g) => g !== payload.group));
406
+ return {
407
+ ...state,
408
+ metricList: state.metricList.map(metricUpdater),
409
+ group: {
410
+ ...state.group,
411
+ selected: payload.edit,
412
+ groupWeights: weightsUpdater(state.group.groupWeights),
413
+ list: listUpdater(state.group.list),
414
+ },
415
+ };
416
+ }
417
+
418
+ export function changeMetricGroupConfirmReducer(
419
+ state: ISelectedConfigState,
420
+ action: Action & any,
421
+ ): ISelectedConfigState {
422
+ if (action.type !== Actions.CHANGE_METRIC_GROUP_CONFIRM) {
423
+ return state;
424
+ }
425
+
426
+ const {
427
+ changeMetricGroup: { toGroup },
428
+ } = state;
429
+ const {
430
+ payload: { metricId },
431
+ } = action;
432
+ if (!metricId) {
433
+ return state;
434
+ }
435
+
436
+ const metricUpdater = (m: ICanaryMetricConfig): ICanaryMetricConfig => ({
437
+ ...m,
438
+ groups: m.id === metricId ? [toGroup] : m.groups,
439
+ });
440
+
441
+ return {
442
+ ...state,
443
+ metricList: state.metricList.map(metricUpdater),
444
+ };
445
+ }
446
+
447
+ export function updateGroupWeightsReducer(state: ISelectedConfigState, action: Action & any): ISelectedConfigState {
448
+ if (
449
+ ![Actions.SELECT_CONFIG, Actions.CHANGE_METRIC_GROUP_CONFIRM, Actions.ADD_METRIC, Actions.REMOVE_METRIC].includes(
450
+ action.type,
451
+ )
452
+ ) {
453
+ return state;
454
+ }
455
+
456
+ const groups = chain(state.metricList)
457
+ .flatMap((metric) => metric.groups)
458
+ .uniq()
459
+ .value();
460
+
461
+ // Prune weights for groups that no longer exist.
462
+ let groupWeights: IGroupWeights = pick(state.group.groupWeights, groups);
463
+
464
+ // Initialize weights for new groups.
465
+ groupWeights = {
466
+ ...fromPairs(groups.map((g) => [g, 0])),
467
+ ...groupWeights,
468
+ };
469
+
470
+ return {
471
+ ...state,
472
+ group: {
473
+ ...state.group,
474
+ groupWeights,
475
+ },
476
+ };
477
+ }
478
+
479
+ const editingTemplateConfirmReducer = (state: ISelectedConfigState, action: Action & any): ISelectedConfigState => {
480
+ if (action.type !== Actions.EDIT_TEMPLATE_CONFIRM) {
481
+ return state;
482
+ }
483
+
484
+ const { name, editedName, editedValue, isNew } = state.editingTemplate;
485
+ const templates = {
486
+ ...(name ? omit(state.config.templates, name) : state.config.templates),
487
+ [editedName]: editedValue,
488
+ };
489
+
490
+ const metricUpdater = (metric: ICanaryMetricConfig) => {
491
+ if (get(metric, 'query.customFilterTemplate') !== name) {
492
+ return metric;
493
+ }
494
+ return {
495
+ ...metric,
496
+ query: {
497
+ ...metric.query,
498
+ customFilterTemplate: editedName,
499
+ },
500
+ };
501
+ };
502
+
503
+ // Select new template for editingMetric
504
+ const editingMetricUpdater = (metric: ICanaryMetricConfig) => {
505
+ if (isNew) {
506
+ return {
507
+ ...metric,
508
+ query: {
509
+ ...metric.query,
510
+ customFilterTemplate: editedName,
511
+ },
512
+ };
513
+ }
514
+ return metricUpdater(metric);
515
+ };
516
+
517
+ return {
518
+ ...state,
519
+ editingTemplate: {
520
+ name: null,
521
+ editedName: null,
522
+ editedValue: null,
523
+ isNew: false,
524
+ },
525
+ config: {
526
+ ...state.config,
527
+ templates,
528
+ },
529
+ metricList: (state.metricList || []).map(metricUpdater),
530
+ editingMetric: editingMetricUpdater(state.editingMetric),
531
+ };
532
+ };
533
+
534
+ const combined = combineReducers<ISelectedConfigState>({
535
+ config,
536
+ load,
537
+ save,
538
+ destroy,
539
+ json,
540
+ judge,
541
+ metricList,
542
+ editingMetric: (metric, action) =>
543
+ [editingMetric, prometheusMetricConfigReducer, signalFxMetricConfigReducer, stackdriverMetricConfigReducer].reduce(
544
+ (s, reducer) => reducer(s, action),
545
+ metric,
546
+ ),
547
+ group,
548
+ changeMetricGroup,
549
+ isInSyncWithServer,
550
+ validationErrors: () => null,
551
+ editingTemplate,
552
+ selectedStore: handleActions<string>({}, null),
553
+ });
554
+
555
+ // First combine all simple reducers, then apply more complex ones as needed.
556
+ export const selectedConfig = (state: ISelectedConfigState, action: Action & any): ISelectedConfigState => {
557
+ return [
558
+ combined,
559
+ editingMetricReducer,
560
+ selectedJudgeReducer,
561
+ editGroupConfirmReducer,
562
+ changeMetricGroupConfirmReducer,
563
+ updateGroupWeightsReducer,
564
+ editingTemplateConfirmReducer,
565
+ ].reduce((s, reducer) => reducer(s, action), state);
566
+ };
@@ -0,0 +1,101 @@
1
+ import * as Actions from 'kayenta/actions';
2
+ import { ICanaryExecutionStatusResult, IMetricSetPair, MetricClassificationLabel } from 'kayenta/domain';
3
+ import { GraphType } from 'kayenta/report/detail/graph/metricSetPairGraph.service';
4
+ import { Action, combineReducers, Reducer } from 'redux';
5
+ import { handleActions } from 'redux-actions';
6
+
7
+ import { AsyncRequestState } from './asyncRequest';
8
+
9
+ interface IMetricSetPairState {
10
+ pair: IMetricSetPair;
11
+ load: AsyncRequestState;
12
+ }
13
+
14
+ export interface ISelectedRunState {
15
+ run: ICanaryExecutionStatusResult;
16
+ load: AsyncRequestState;
17
+ selectedGroup: string;
18
+ selectedMetric: string;
19
+ metricSetPair: IMetricSetPairState;
20
+ graphType: GraphType;
21
+ metricFilters: MetricClassificationLabel[];
22
+ }
23
+
24
+ const metricFilters = handleActions(
25
+ {
26
+ [Actions.TOGGLE_METRIC_CLASSIFICATION_FILTER]: (_state: MetricClassificationLabel[], action: Action & any) => {
27
+ const { classification } = action.payload;
28
+ if (_state.includes(classification)) {
29
+ return _state.filter((s) => s !== classification);
30
+ }
31
+ return _state.concat([classification]);
32
+ },
33
+ },
34
+ [],
35
+ );
36
+
37
+ const run = handleActions(
38
+ {
39
+ [Actions.LOAD_RUN_SUCCESS]: (_state: ICanaryExecutionStatusResult, action: Action & any) => action.payload.run,
40
+ },
41
+ null,
42
+ );
43
+
44
+ const load = handleActions(
45
+ {
46
+ [Actions.LOAD_RUN_REQUEST]: () => AsyncRequestState.Requesting,
47
+ [Actions.LOAD_RUN_SUCCESS]: () => AsyncRequestState.Fulfilled,
48
+ [Actions.LOAD_RUN_FAILURE]: () => AsyncRequestState.Failed,
49
+ },
50
+ AsyncRequestState.Requesting,
51
+ );
52
+
53
+ const selectedGroup = handleActions(
54
+ {
55
+ [Actions.SELECT_REPORT_METRIC_GROUP]: (_state: string, action: Action & any) => action.payload.group,
56
+ },
57
+ null,
58
+ );
59
+
60
+ const selectedMetric = handleActions(
61
+ {
62
+ [Actions.SELECT_REPORT_METRIC_GROUP]: () => null,
63
+ },
64
+ null,
65
+ );
66
+
67
+ const metricSetPair = combineReducers<IMetricSetPairState>({
68
+ pair: handleActions(
69
+ {
70
+ [Actions.LOAD_METRIC_SET_PAIR_REQUEST]: () => null,
71
+ [Actions.LOAD_METRIC_SET_PAIR_SUCCESS]: (_state: IMetricSetPair, action: Action & any) =>
72
+ action.payload.metricSetPair,
73
+ },
74
+ null,
75
+ ),
76
+ load: handleActions(
77
+ {
78
+ [Actions.LOAD_METRIC_SET_PAIR_REQUEST]: () => AsyncRequestState.Requesting,
79
+ [Actions.LOAD_METRIC_SET_PAIR_SUCCESS]: () => AsyncRequestState.Fulfilled,
80
+ [Actions.LOAD_METRIC_SET_PAIR_FAILURE]: () => AsyncRequestState.Failed,
81
+ },
82
+ AsyncRequestState.Fulfilled,
83
+ ),
84
+ });
85
+
86
+ const graphType = handleActions<GraphType>(
87
+ {
88
+ [Actions.SELECT_GRAPH_TYPE]: (_state: GraphType, action: Action & any) => action.payload.type,
89
+ },
90
+ GraphType.TimeSeries,
91
+ );
92
+
93
+ export const selectedRun: Reducer<ISelectedRunState> = combineReducers<ISelectedRunState>({
94
+ run,
95
+ load,
96
+ selectedGroup,
97
+ selectedMetric,
98
+ metricSetPair,
99
+ graphType,
100
+ metricFilters,
101
+ });
@@ -0,0 +1,36 @@
1
+ import * as Actions from 'kayenta/actions';
2
+ import { ISignalFxCanaryMetricSetQueryConfig } from 'kayenta/metricStore/signalfx/domain/ISignalFxCanaryMetricSetQueryConfig';
3
+ import { Action } from 'redux';
4
+ import { handleActions } from 'redux-actions';
5
+
6
+ import { IKayentaAction } from '../actions/creators';
7
+ import { ICanaryMetricConfig } from '../domain';
8
+ import { IUpdateKeyValueListPayload, updateListReducer } from '../layout/keyValueList';
9
+
10
+ const updateQueryPairsReducer = updateListReducer();
11
+
12
+ type ISignalFxMetricConfig = ICanaryMetricConfig<ISignalFxCanaryMetricSetQueryConfig>;
13
+
14
+ export const signalFxMetricConfigReducer = handleActions(
15
+ {
16
+ [Actions.UPDATE_SIGNAL_FX_QUERY_PAIRS]: (
17
+ state: ISignalFxMetricConfig,
18
+ action: IKayentaAction<IUpdateKeyValueListPayload>,
19
+ ) => ({
20
+ ...state,
21
+ query: {
22
+ ...state.query,
23
+ queryPairs: updateQueryPairsReducer(state.query.queryPairs || [], action),
24
+ },
25
+ }),
26
+ [Actions.UPDATE_SIGNAL_FX_METRIC_NAME]: (state: ISignalFxMetricConfig, action: Action & any) => ({
27
+ ...state,
28
+ query: { ...state.query, metricName: action.payload.metricName },
29
+ }),
30
+ [Actions.UPDATE_SIGNAL_FX_AGGREGATION_METHOD]: (state: ISignalFxMetricConfig, action: Action & any) => ({
31
+ ...state,
32
+ query: { ...state.query, aggregationMethod: action.payload.aggregationMethod },
33
+ }),
34
+ },
35
+ null,
36
+ );