@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,20 @@
1
+ .kv-pair-item {
2
+ display: flex;
3
+ align-items: center;
4
+
5
+ .kv-pair-item-section {
6
+ display: flex;
7
+ margin-right: 5px;
8
+ margin-bottom: 7px;
9
+
10
+ .kv-pair-item-section-label-wrapper {
11
+ display: flex;
12
+ flex-flow: column;
13
+ justify-content: center;
14
+ }
15
+
16
+ .kv-pair-item-section-input {
17
+ margin-left: 5px;
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,114 @@
1
+ import classNames from 'classnames';
2
+ import * as React from 'react';
3
+
4
+ import { IKayentaAction } from '../actions/creators';
5
+ import AddNewButton from './addNewButton';
6
+ import DeleteButton from './deleteButton';
7
+ import { DISABLE_EDIT_CONFIG, DisableableInput } from './disableable';
8
+
9
+ import './keyValueList.less';
10
+
11
+ export enum KeyValueListAction {
12
+ ADD,
13
+ DELETE,
14
+ KEY_EDIT,
15
+ VALUE_EDIT,
16
+ }
17
+
18
+ export interface IKeyValuePair {
19
+ key: string;
20
+ value: string;
21
+ }
22
+
23
+ export interface IUpdateKeyValueListPayload {
24
+ type: KeyValueListAction;
25
+ index?: number;
26
+ key?: string;
27
+ value?: string;
28
+ }
29
+
30
+ export const updateListReducer = (defaultValue = { key: '', value: '' }) => (
31
+ state: IKeyValuePair[],
32
+ action: IKayentaAction<IUpdateKeyValueListPayload>,
33
+ ) => {
34
+ const { index, value, type } = action.payload;
35
+ switch (type) {
36
+ case KeyValueListAction.ADD:
37
+ return state.concat(defaultValue);
38
+ case KeyValueListAction.DELETE:
39
+ return [...state.slice(0, index), ...state.slice(index + 1)];
40
+ case KeyValueListAction.KEY_EDIT:
41
+ return [...state.slice(0, index), { ...state[index], key: value }, ...state.slice(index + 1)];
42
+ case KeyValueListAction.VALUE_EDIT:
43
+ return [...state.slice(0, index), { ...state[index], value }, ...state.slice(index + 1)];
44
+ }
45
+ };
46
+
47
+ export interface IKeyValueListProps {
48
+ list: IKeyValuePair[];
49
+ className?: string;
50
+ actionCreator: (action: IUpdateKeyValueListPayload) => void;
51
+ }
52
+
53
+ export default function KeyValueList({ list, className, actionCreator }: IKeyValueListProps) {
54
+ const onKeyChange = (i: number) => (event: any) =>
55
+ actionCreator({
56
+ type: KeyValueListAction.KEY_EDIT,
57
+ index: i,
58
+ value: event.target.value,
59
+ });
60
+
61
+ const onValueChange = (i: number) => (event: any) =>
62
+ actionCreator({
63
+ type: KeyValueListAction.VALUE_EDIT,
64
+ index: i,
65
+ value: event.target.value,
66
+ });
67
+
68
+ const deleteValue = (i: number) => () =>
69
+ actionCreator({
70
+ type: KeyValueListAction.DELETE,
71
+ index: i,
72
+ });
73
+
74
+ const addValue = () =>
75
+ actionCreator({
76
+ type: KeyValueListAction.ADD,
77
+ });
78
+
79
+ return (
80
+ <section className={classNames('kv-pair-list', className)}>
81
+ {list.map((kvPair, index) => {
82
+ const { key, value } = kvPair;
83
+ return (
84
+ <div key={index} className="kv-pair-item">
85
+ <div className="kv-pair-item-section">
86
+ <div className="kv-pair-item-section-label-wrapper">
87
+ <div className="kv-pair-item-section-label">Key</div>
88
+ </div>
89
+ <div className="kv-pair-item-section-input">
90
+ <DisableableInput value={key} onChange={onKeyChange(index)} disabledStateKeys={[DISABLE_EDIT_CONFIG]} />
91
+ </div>
92
+ </div>
93
+ <div className="kv-pair-item-section">
94
+ <div className="kv-pair-item-section-label-wrapper">
95
+ <div className="kv-pair-item-section-label">Value</div>
96
+ </div>
97
+ <div className="kv-pair-item-section-input">
98
+ <DisableableInput
99
+ value={value}
100
+ onChange={onValueChange(index)}
101
+ disabledStateKeys={[DISABLE_EDIT_CONFIG]}
102
+ />
103
+ </div>
104
+ </div>
105
+ <div className="kv-pair-item-section">
106
+ <DeleteButton onClick={deleteValue(index)} />
107
+ </div>
108
+ </div>
109
+ );
110
+ })}
111
+ <AddNewButton onClick={addValue} />
112
+ </section>
113
+ );
114
+ }
@@ -0,0 +1,9 @@
1
+ .kayenta-list {
2
+ a.clickable {
3
+ margin: 5px 0 0 10px;
4
+ }
5
+
6
+ input.input-sm {
7
+ width: 93%;
8
+ }
9
+ }
@@ -0,0 +1,83 @@
1
+ import { mount } from 'enzyme';
2
+ import { IKayentaAction } from 'kayenta/actions/creators';
3
+ import * as React from 'react';
4
+ import { Provider } from 'react-redux';
5
+ import { createStore } from 'redux';
6
+
7
+ import { IUpdateListPayload, List, ListAction, updateListReducer } from './list';
8
+ import { rootReducer } from '../reducers';
9
+
10
+ describe('Reducer: updateListReducer', () => {
11
+ const createAction = (payload: IUpdateListPayload): IKayentaAction<IUpdateListPayload> => ({
12
+ type: 'update_list',
13
+ payload,
14
+ });
15
+
16
+ const reducer = updateListReducer('defaultValue');
17
+
18
+ it('adds', () => {
19
+ expect(
20
+ reducer(
21
+ [],
22
+ createAction({
23
+ type: ListAction.Add,
24
+ }),
25
+ ),
26
+ ).toEqual(['defaultValue']);
27
+ });
28
+
29
+ it('deletes', () => {
30
+ expect(
31
+ reducer(
32
+ ['toRemain', 'toRemove'],
33
+ createAction({
34
+ type: ListAction.Delete,
35
+ index: 1,
36
+ }),
37
+ ),
38
+ ).toEqual(['toRemain']);
39
+ });
40
+
41
+ it('edits', () => {
42
+ expect(
43
+ reducer(
44
+ ['unedited', 'beforeEdit'],
45
+ createAction({
46
+ type: ListAction.Edit,
47
+ index: 1,
48
+ value: 'afterEdit',
49
+ }),
50
+ ),
51
+ ).toEqual(['unedited', 'afterEdit']);
52
+ });
53
+ });
54
+
55
+ describe('Component: List', () => {
56
+ it('renders a list', () => {
57
+ const component = mount(
58
+ <Provider store={createStore(rootReducer)}>
59
+ <List list={['a', 'b', 'c']} actionCreator={() => null} />
60
+ </Provider>,
61
+ );
62
+
63
+ expect(component.find('input').length).toEqual(3);
64
+ });
65
+
66
+ it('emits the correct value and index on update', () => {
67
+ const spy = jest.fn();
68
+ const component = mount(
69
+ <Provider store={createStore(rootReducer)}>
70
+ <List list={['a', 'b', 'c']} actionCreator={spy} />
71
+ </Provider>,
72
+ );
73
+
74
+ const input = component.find('input').at(1);
75
+ input.simulate('change', { target: { value: 'newValue' } });
76
+
77
+ expect(spy).toHaveBeenCalledWith({
78
+ type: ListAction.Edit,
79
+ index: 1,
80
+ value: 'newValue',
81
+ });
82
+ });
83
+ });
@@ -0,0 +1,73 @@
1
+ import { IKayentaAction } from 'kayenta/actions/creators';
2
+ import * as React from 'react';
3
+
4
+ import AddNewButton from './addNewButton';
5
+ import DeleteButton from './deleteButton';
6
+ import { DISABLE_EDIT_CONFIG, DisableableInput } from './disableable';
7
+
8
+ import './list.less';
9
+
10
+ export enum ListAction {
11
+ Add,
12
+ Edit,
13
+ Delete,
14
+ }
15
+
16
+ export interface IUpdateListPayload {
17
+ type: ListAction;
18
+ index?: number;
19
+ value?: string;
20
+ }
21
+
22
+ export const updateListReducer = (defaultValue = '') => (
23
+ state: string[],
24
+ action: IKayentaAction<IUpdateListPayload>,
25
+ ) => {
26
+ const { index, value } = action.payload;
27
+ switch (action.payload.type) {
28
+ case ListAction.Add:
29
+ return state.concat(defaultValue);
30
+ case ListAction.Delete:
31
+ return [...state.slice(0, index), ...state.slice(index + 1)];
32
+ case ListAction.Edit:
33
+ return [...state.slice(0, index), value, ...state.slice(index + 1)];
34
+ }
35
+ };
36
+
37
+ interface IListProps {
38
+ list: string[];
39
+ valueKey?: (value: string) => string;
40
+ actionCreator: (action: IUpdateListPayload) => void;
41
+ }
42
+
43
+ export const List = ({ list, valueKey, actionCreator }: IListProps) => {
44
+ const onChange = (i: number) => (event: any) =>
45
+ actionCreator({
46
+ type: ListAction.Edit,
47
+ index: i,
48
+ value: event.target.value,
49
+ });
50
+
51
+ const deleteValue = (i: number) => () =>
52
+ actionCreator({
53
+ type: ListAction.Delete,
54
+ index: i,
55
+ });
56
+
57
+ const addValue = () =>
58
+ actionCreator({
59
+ type: ListAction.Add,
60
+ });
61
+
62
+ return (
63
+ <section>
64
+ {list.map((value, i) => (
65
+ <div key={valueKey ? valueKey(value) : i} className="horizontal form-group kayenta-list">
66
+ <DisableableInput value={value} onChange={onChange(i)} disabledStateKeys={[DISABLE_EDIT_CONFIG]} />
67
+ <DeleteButton onClick={deleteValue(i)} />
68
+ </div>
69
+ ))}
70
+ <AddNewButton onClick={addValue} />
71
+ </section>
72
+ );
73
+ };
@@ -0,0 +1,33 @@
1
+ import classNames from 'classnames';
2
+ import * as React from 'react';
3
+
4
+ export interface IListDetailProps {
5
+ className?: string;
6
+ list: JSX.Element;
7
+ listClass?: string;
8
+ listWidth?: number;
9
+ detail: JSX.Element;
10
+ detailWidth?: number;
11
+ detailClass?: string;
12
+ }
13
+
14
+ /*
15
+ * A composite view that combines a list view in one panel and a detail view in another.
16
+ * The contents of the detail view are dependent on the user's selection in the list view.
17
+ */
18
+ export default function ListDetail({
19
+ className,
20
+ list,
21
+ listWidth = 2,
22
+ detail,
23
+ detailWidth = 10,
24
+ listClass,
25
+ detailClass,
26
+ }: IListDetailProps) {
27
+ return (
28
+ <div className={classNames('list-detail', 'horizontal', className)}>
29
+ <div className={classNames(`col-md-${listWidth}`, listClass)}>{list}</div>
30
+ <div className={classNames(`col-md-${detailWidth}`, detailClass)}>{detail}</div>
31
+ </div>
32
+ );
33
+ }
@@ -0,0 +1,29 @@
1
+ import * as React from 'react';
2
+
3
+ import { DISABLE_EDIT_CONFIG, DisableableInput } from './disableable';
4
+
5
+ export interface IRadioChoiceProps {
6
+ value: string;
7
+ label: string | JSX.Element;
8
+ name: string;
9
+ current: string;
10
+ action: (event: any) => void;
11
+ }
12
+
13
+ export default function RadioChoice({ value, label, name, current, action }: IRadioChoiceProps) {
14
+ return (
15
+ <div className="radio-inline">
16
+ <label style={{ fontWeight: 'normal', marginRight: '1em' }}>
17
+ <DisableableInput
18
+ type="radio"
19
+ name={name}
20
+ value={value}
21
+ onChange={action}
22
+ checked={value === current}
23
+ disabledStateKeys={[DISABLE_EDIT_CONFIG]}
24
+ />{' '}
25
+ {label}
26
+ </label>
27
+ </div>
28
+ );
29
+ }
@@ -0,0 +1,16 @@
1
+ import classNames from 'classnames';
2
+ import * as React from 'react';
3
+
4
+ import '../canary.less';
5
+
6
+ export const STYLEGUIDE_CLASS = 'styleguide';
7
+ export const KAYENTA_CLASS = 'kayenta';
8
+
9
+ export interface IStyleguideProps {
10
+ children: JSX.Element | JSX.Element[];
11
+ className?: string;
12
+ }
13
+
14
+ export default function Styleguide({ children, className }: IStyleguideProps) {
15
+ return <div className={classNames(STYLEGUIDE_CLASS, KAYENTA_CLASS, className)}>{children}</div>;
16
+ }
@@ -0,0 +1,5 @@
1
+ export * from './table';
2
+ export * from './tableColumn';
3
+ export * from './tableHeader';
4
+ export * from './nativeTable';
5
+ export * from './nativeTableHeader';
@@ -0,0 +1,51 @@
1
+ import classNames from 'classnames';
2
+ import * as React from 'react';
3
+
4
+ import { NativeTableHeader } from './nativeTableHeader';
5
+ import { ITableColumn } from './tableColumn';
6
+
7
+ export interface INativeTableProps<T> {
8
+ rows: T[];
9
+ columns: Array<ITableColumn<T>>;
10
+ rowKey: (row: T) => string;
11
+ tableBodyClassName?: string;
12
+ headerClassName?: string;
13
+ rowClassName?: (row: T) => string;
14
+ onRowClick?: (row: T) => void;
15
+ customRow?: (row: T) => JSX.Element;
16
+ className?: string;
17
+ }
18
+
19
+ export function NativeTable<T>({
20
+ rows,
21
+ columns,
22
+ rowKey,
23
+ tableBodyClassName,
24
+ rowClassName,
25
+ onRowClick,
26
+ customRow,
27
+ className,
28
+ headerClassName,
29
+ }: INativeTableProps<T>) {
30
+ const TableRow = ({ row }: { row: T }) => (
31
+ <tr
32
+ onClick={onRowClick ? () => onRowClick(row) : null}
33
+ className={classNames({ 'table-row': !rowClassName }, rowClassName && rowClassName(row))}
34
+ >
35
+ {columns.map(({ label, hide, getContent }, i) => (
36
+ <td key={label || i}>{(!hide || !hide(row)) && getContent(row)}</td>
37
+ ))}
38
+ </tr>
39
+ );
40
+
41
+ return (
42
+ <table className={className}>
43
+ <NativeTableHeader rows={rows} columns={columns} className={classNames('table-header', headerClassName)} />
44
+ <tbody className={tableBodyClassName}>
45
+ {rows.map((r) =>
46
+ customRow && customRow(r) ? <td key={rowKey(r)}>{customRow(r)}</td> : <TableRow key={rowKey(r)} row={r} />,
47
+ )}
48
+ </tbody>
49
+ </table>
50
+ );
51
+ }
@@ -0,0 +1,26 @@
1
+ import classNames from 'classnames';
2
+ import * as React from 'react';
3
+
4
+ import { ITableColumn } from './tableColumn';
5
+
6
+ export interface INativeTableHeaderProps<T = any> {
7
+ rows: T[];
8
+ columns: Array<ITableColumn<T>>;
9
+ className: string;
10
+ }
11
+
12
+ export const NativeTableHeader = ({ rows = [], columns, className }: INativeTableHeaderProps) => {
13
+ return (
14
+ <thead className={className}>
15
+ <tr>
16
+ {columns.map(({ label, labelClassName, hide }, i) => (
17
+ <th key={label || i} className="native-table-header">
18
+ {(!hide || !rows.every(hide)) && (
19
+ <h6 className={classNames('heading-6', 'uppercase', 'color-text-primary', labelClassName)}>{label}</h6>
20
+ )}
21
+ </th>
22
+ ))}
23
+ </tr>
24
+ </thead>
25
+ );
26
+ };
@@ -0,0 +1,56 @@
1
+ import classNames from 'classnames';
2
+ import * as React from 'react';
3
+
4
+ import { ITableColumn } from './tableColumn';
5
+ import { TableHeader } from './tableHeader';
6
+
7
+ export interface ITableProps<T> {
8
+ rows: T[];
9
+ columns: Array<ITableColumn<T>>;
10
+ rowKey: (row: T) => string;
11
+ tableBodyClassName?: string;
12
+ headerClassName?: string;
13
+ rowClassName?: (row: T) => string;
14
+ onRowClick?: (row: T) => void;
15
+ customRow?: (row: T) => JSX.Element;
16
+ className?: string;
17
+ }
18
+
19
+ export function Table<T>({
20
+ rows,
21
+ columns,
22
+ rowKey,
23
+ tableBodyClassName,
24
+ rowClassName,
25
+ onRowClick,
26
+ customRow,
27
+ className,
28
+ headerClassName,
29
+ }: ITableProps<T>) {
30
+ const TableRow = ({ row }: { row: T }) => (
31
+ <li
32
+ onClick={onRowClick ? () => onRowClick(row) : null}
33
+ className={classNames(
34
+ { horizontal: !rowClassName, 'table-row': !rowClassName },
35
+ rowClassName && rowClassName(row),
36
+ )}
37
+ >
38
+ {columns.map((c, i) => (
39
+ <div key={c.label || i} className={`flex-${c.width}`}>
40
+ {!c.hide && c.getContent(row)}
41
+ </div>
42
+ ))}
43
+ </li>
44
+ );
45
+
46
+ return (
47
+ <div className={className}>
48
+ <ul className={classNames(tableBodyClassName, 'list-group')}>
49
+ <TableHeader columns={columns} className={classNames('table-header', 'sticky-header', headerClassName)} />
50
+ {rows.map((r) =>
51
+ customRow && customRow(r) ? <div key={rowKey(r)}>{customRow(r)}</div> : <TableRow key={rowKey(r)} row={r} />,
52
+ )}
53
+ </ul>
54
+ </div>
55
+ );
56
+ }
@@ -0,0 +1,7 @@
1
+ export interface ITableColumn<T> {
2
+ label?: string;
3
+ labelClassName?: string;
4
+ hide?: (data: T) => boolean;
5
+ width?: number;
6
+ getContent: (data: T) => JSX.Element;
7
+ }
@@ -0,0 +1,23 @@
1
+ import classNames from 'classnames';
2
+ import * as React from 'react';
3
+
4
+ import { ITableColumn } from './tableColumn';
5
+
6
+ export interface ITableHeaderProps {
7
+ columns: Array<ITableColumn<any>>;
8
+ className: string;
9
+ }
10
+
11
+ export const TableHeader = ({ columns, className }: ITableHeaderProps) => {
12
+ return (
13
+ <div className={classNames('horizontal', className)}>
14
+ {columns.map((c, i) => (
15
+ <div key={c.label || i} className={`flex-${c.width}`}>
16
+ {!c.hide && (
17
+ <h6 className={classNames('heading-6', 'uppercase', 'color-text-primary', c.labelClassName)}>{c.label}</h6>
18
+ )}
19
+ </div>
20
+ ))}
21
+ </div>
22
+ );
23
+ };
@@ -0,0 +1,26 @@
1
+ import classNames from 'classnames';
2
+ import * as React from 'react';
3
+
4
+ export interface ITabsProps {
5
+ children: any;
6
+ className?: string;
7
+ style?: React.CSSProperties;
8
+ }
9
+
10
+ export function Tabs({ children, className, style }: ITabsProps) {
11
+ return (
12
+ <ul className={classNames('tabs-basic', 'list-unstyled', className)} style={style}>
13
+ {children}
14
+ </ul>
15
+ );
16
+ }
17
+
18
+ export interface ITabProps {
19
+ selected: boolean;
20
+ children: JSX.Element | JSX.Element[];
21
+ className?: string;
22
+ }
23
+
24
+ export function Tab({ selected = false, children, className }: ITabProps) {
25
+ return <li className={classNames(selected ? 'selected' : '', className)}>{children}</li>;
26
+ }
@@ -0,0 +1,16 @@
1
+ .kayenta {
2
+ .titled-section {
3
+ margin-bottom: 1em;
4
+
5
+ .contents {
6
+ margin: 10px 10px 0 10px;
7
+ background-color: var(--color-white);
8
+ border: 1px solid var(--color-cirrus);
9
+ padding: 15px;
10
+
11
+ .list-group {
12
+ margin-bottom: 5px;
13
+ }
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,20 @@
1
+ import * as React from 'react';
2
+
3
+ import './titledSection.less';
4
+
5
+ export interface ISectionProps {
6
+ title: string;
7
+ children?: any;
8
+ }
9
+
10
+ // TODO: implemented the mocks using a modified open pod, but the styleguide should add something more directly appropriate
11
+ export default function TitledSection({ title, children }: ISectionProps) {
12
+ return (
13
+ <section className="pod open titled-section">
14
+ <div className="header horizontal middle">
15
+ <div className="flex-1 heading-2 uppercase">{title}</div>
16
+ </div>
17
+ <div className="contents vertical">{children}</div>
18
+ </section>
19
+ );
20
+ }
@@ -0,0 +1,11 @@
1
+ .kayenta {
2
+ .titled-subsection {
3
+ h5 {
4
+ font-weight: 600;
5
+ }
6
+
7
+ hr {
8
+ margin-top: 0;
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,22 @@
1
+ import * as React from 'react';
2
+ import { HelpField } from '@spinnaker/core';
3
+
4
+ import './titledSubsection.less';
5
+
6
+ export interface ITitledSubsectionProps {
7
+ children: any;
8
+ title: string;
9
+ helpKey?: string;
10
+ }
11
+
12
+ export default function TitledSubsection({ title, children, helpKey }: ITitledSubsectionProps) {
13
+ return (
14
+ <section className="titled-subsection">
15
+ <h5 className="heading-5">
16
+ {title} {helpKey && <HelpField id={helpKey} />}
17
+ </h5>
18
+ <hr />
19
+ {children}
20
+ </section>
21
+ );
22
+ }