@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.
- package/.editorconfig +9 -0
- package/.eslintrc.js +1 -0
- package/.huskyrc +5 -0
- package/.lintstagedrc.json +4 -0
- package/.prettierignore +4 -0
- package/.prettierrc.js +1 -0
- package/LICENSE.txt +203 -0
- package/README.md +81 -0
- package/__mocks__/styleMock.js +1 -0
- package/__mocks__/version.json +4 -0
- package/babel.config.js +3 -0
- package/build.gradle +67 -0
- package/build_scripts/checkLicenses.js +79 -0
- package/gradle.properties +0 -0
- package/jest.config.js +204 -0
- package/jest.setup.js +5 -0
- package/package.json +166 -0
- package/rollup-plugin-angularjs-template-loader.js +82 -0
- package/rollup.config.js +30 -0
- package/src/index.ts +2 -0
- package/src/kayenta/actions/creators.ts +163 -0
- package/src/kayenta/actions/index.ts +98 -0
- package/src/kayenta/canary.dataSource.bridge.ts +53 -0
- package/src/kayenta/canary.dataSource.stub.ts +64 -0
- package/src/kayenta/canary.help.ts +136 -0
- package/src/kayenta/canary.less +168 -0
- package/src/kayenta/canary.settings.ts +26 -0
- package/src/kayenta/canary.tsx +67 -0
- package/src/kayenta/components/canaryScore.component.less +77 -0
- package/src/kayenta/components/canaryScore.component.ts +12 -0
- package/src/kayenta/components/canaryScore.tsx +63 -0
- package/src/kayenta/components/canaryScores.component.ts +20 -0
- package/src/kayenta/components/canaryScores.less +22 -0
- package/src/kayenta/components/canaryScores.tsx +163 -0
- package/src/kayenta/components/loadStates.tsx +52 -0
- package/src/kayenta/domain/ICanaryConfig.ts +57 -0
- package/src/kayenta/domain/ICanaryConfigSummary.ts +7 -0
- package/src/kayenta/domain/ICanaryConfigUpdateResponse.ts +3 -0
- package/src/kayenta/domain/ICanaryExecutionStatusResult.ts +72 -0
- package/src/kayenta/domain/ICanaryJudgeResult.ts +51 -0
- package/src/kayenta/domain/ICanaryJudgeResultSummary.ts +5 -0
- package/src/kayenta/domain/ICanaryScoreThresholds.ts +4 -0
- package/src/kayenta/domain/IJudge.ts +5 -0
- package/src/kayenta/domain/IKayentaAccount.ts +14 -0
- package/src/kayenta/domain/IKayentaStageConfig.ts +58 -0
- package/src/kayenta/domain/IMetricSetPair.ts +17 -0
- package/src/kayenta/domain/IMetricsServiceMetadata.ts +2 -0
- package/src/kayenta/domain/ISetupCanaryStage.ts +11 -0
- package/src/kayenta/domain/MetricClassificationLabel.ts +8 -0
- package/src/kayenta/domain/ScoreClassificationLabel.ts +7 -0
- package/src/kayenta/domain/index.ts +15 -0
- package/src/kayenta/edit/changeMetricGroupModal.tsx +107 -0
- package/src/kayenta/edit/configDetail.tsx +31 -0
- package/src/kayenta/edit/configDetailActionButtons.tsx +24 -0
- package/src/kayenta/edit/configDetailHeader.tsx +104 -0
- package/src/kayenta/edit/configDetailLoadStates.tsx +36 -0
- package/src/kayenta/edit/configDetailLoader.tsx +60 -0
- package/src/kayenta/edit/configJson.less +42 -0
- package/src/kayenta/edit/configJsonModal.tsx +158 -0
- package/src/kayenta/edit/configList.less +7 -0
- package/src/kayenta/edit/configList.tsx +57 -0
- package/src/kayenta/edit/copyConfigButton.tsx +34 -0
- package/src/kayenta/edit/createConfigButton.tsx +34 -0
- package/src/kayenta/edit/deleteModal.tsx +87 -0
- package/src/kayenta/edit/edit.tsx +24 -0
- package/src/kayenta/edit/editMetricEffectSizes.tsx +186 -0
- package/src/kayenta/edit/editMetricModal.less +9 -0
- package/src/kayenta/edit/editMetricModal.spec.tsx +129 -0
- package/src/kayenta/edit/editMetricModal.tsx +294 -0
- package/src/kayenta/edit/editMetricValidation.spec.ts +63 -0
- package/src/kayenta/edit/editMetricValidation.ts +50 -0
- package/src/kayenta/edit/filterTemplateSelector.less +15 -0
- package/src/kayenta/edit/filterTemplateSelector.spec.tsx +106 -0
- package/src/kayenta/edit/filterTemplateSelector.tsx +194 -0
- package/src/kayenta/edit/filterTemplatesValidation.spec.ts +108 -0
- package/src/kayenta/edit/filterTemplatesValidation.ts +95 -0
- package/src/kayenta/edit/footer.less +30 -0
- package/src/kayenta/edit/footer.tsx +12 -0
- package/src/kayenta/edit/groupName.tsx +80 -0
- package/src/kayenta/edit/groupTabs.tsx +106 -0
- package/src/kayenta/edit/groupWeight.tsx +80 -0
- package/src/kayenta/edit/groupWeights.tsx +38 -0
- package/src/kayenta/edit/inlineTemplateEditor.spec.tsx +42 -0
- package/src/kayenta/edit/inlineTemplateEditor.tsx +61 -0
- package/src/kayenta/edit/judgeSelect.tsx +82 -0
- package/src/kayenta/edit/metricConfigurerDelegator.tsx +30 -0
- package/src/kayenta/edit/metricList.less +21 -0
- package/src/kayenta/edit/metricList.tsx +215 -0
- package/src/kayenta/edit/metricStoreSelector.tsx +66 -0
- package/src/kayenta/edit/nameAndDescription.tsx +90 -0
- package/src/kayenta/edit/openConfigJsonModalButton.tsx +33 -0
- package/src/kayenta/edit/openDeleteModalButton.tsx +50 -0
- package/src/kayenta/edit/ownedBy.tsx +34 -0
- package/src/kayenta/edit/save.tsx +19 -0
- package/src/kayenta/edit/saveConfigButton.tsx +65 -0
- package/src/kayenta/edit/saveConfigError.tsx +59 -0
- package/src/kayenta/edit/scoring.tsx +35 -0
- package/src/kayenta/edit/selectConfig.tsx +10 -0
- package/src/kayenta/edit/validationErrors.tsx +39 -0
- package/src/kayenta/index.ts +6 -0
- package/src/kayenta/layout/addNewButton.tsx +20 -0
- package/src/kayenta/layout/centeredDetail.tsx +13 -0
- package/src/kayenta/layout/deleteButton.tsx +11 -0
- package/src/kayenta/layout/disableable.tsx +87 -0
- package/src/kayenta/layout/formList.tsx +26 -0
- package/src/kayenta/layout/formRow.tsx +36 -0
- package/src/kayenta/layout/formattedDate.tsx +14 -0
- package/src/kayenta/layout/index.ts +2 -0
- package/src/kayenta/layout/keyValueList.less +20 -0
- package/src/kayenta/layout/keyValueList.tsx +114 -0
- package/src/kayenta/layout/list.less +9 -0
- package/src/kayenta/layout/list.spec.tsx +83 -0
- package/src/kayenta/layout/list.tsx +73 -0
- package/src/kayenta/layout/listDetail.tsx +33 -0
- package/src/kayenta/layout/radioChoice.tsx +29 -0
- package/src/kayenta/layout/styleguide.tsx +16 -0
- package/src/kayenta/layout/table/index.ts +5 -0
- package/src/kayenta/layout/table/nativeTable.tsx +51 -0
- package/src/kayenta/layout/table/nativeTableHeader.tsx +26 -0
- package/src/kayenta/layout/table/table.tsx +56 -0
- package/src/kayenta/layout/table/tableColumn.ts +7 -0
- package/src/kayenta/layout/table/tableHeader.tsx +23 -0
- package/src/kayenta/layout/tabs.tsx +26 -0
- package/src/kayenta/layout/titledSection.less +16 -0
- package/src/kayenta/layout/titledSection.tsx +20 -0
- package/src/kayenta/layout/titledSubsection.less +11 -0
- package/src/kayenta/layout/titledSubsection.tsx +22 -0
- package/src/kayenta/manualAnalysis/ManualAnalysisModal.tsx +716 -0
- package/src/kayenta/metricStore/atlas/atlasMetricConfigurer.tsx +130 -0
- package/src/kayenta/metricStore/atlas/index.ts +8 -0
- package/src/kayenta/metricStore/datadog/domain/IDatadogMetricDescriptor.ts +5 -0
- package/src/kayenta/metricStore/datadog/index.ts +9 -0
- package/src/kayenta/metricStore/datadog/metricConfigurer.tsx +90 -0
- package/src/kayenta/metricStore/datadog/metricTypeSelector.spec.tsx +59 -0
- package/src/kayenta/metricStore/datadog/metricTypeSelector.tsx +73 -0
- package/src/kayenta/metricStore/graphite/domain/IGraphiteMetricDescriptor.ts +5 -0
- package/src/kayenta/metricStore/graphite/index.ts +8 -0
- package/src/kayenta/metricStore/graphite/metricConfigurer.tsx +54 -0
- package/src/kayenta/metricStore/graphite/metricTypeSelector.tsx +80 -0
- package/src/kayenta/metricStore/graphite/typeahead.less +3 -0
- package/src/kayenta/metricStore/index.ts +8 -0
- package/src/kayenta/metricStore/metricStoreConfig.service.ts +12 -0
- package/src/kayenta/metricStore/newrelic/domain/INewRelicMetricDescriptor.ts +5 -0
- package/src/kayenta/metricStore/newrelic/index.ts +8 -0
- package/src/kayenta/metricStore/newrelic/metricConfigurer.tsx +58 -0
- package/src/kayenta/metricStore/prometheus/domain/IPrometheusCanaryMetricSetQueryConfig.ts +14 -0
- package/src/kayenta/metricStore/prometheus/domain/IPrometheusMetricDescriptor.ts +5 -0
- package/src/kayenta/metricStore/prometheus/index.ts +12 -0
- package/src/kayenta/metricStore/prometheus/metricConfigurer.tsx +157 -0
- package/src/kayenta/metricStore/prometheus/metricTypeSelector.less +5 -0
- package/src/kayenta/metricStore/prometheus/metricTypeSelector.spec.tsx +62 -0
- package/src/kayenta/metricStore/prometheus/metricTypeSelector.tsx +144 -0
- package/src/kayenta/metricStore/prometheus/queryTypeSelectors.spec.ts +61 -0
- package/src/kayenta/metricStore/prometheus/queryTypeSelectors.ts +38 -0
- package/src/kayenta/metricStore/signalfx/domain/ISignalFxCanaryMetricSetQueryConfig.ts +7 -0
- package/src/kayenta/metricStore/signalfx/index.ts +8 -0
- package/src/kayenta/metricStore/signalfx/metricConfigurer.less +10 -0
- package/src/kayenta/metricStore/signalfx/metricConfigurer.tsx +187 -0
- package/src/kayenta/metricStore/stackdriver/domain/IStackdriverCanaryMetricSetQueryConfig.ts +9 -0
- package/src/kayenta/metricStore/stackdriver/domain/IStackdriverMetricDescriptor.ts +17 -0
- package/src/kayenta/metricStore/stackdriver/index.ts +12 -0
- package/src/kayenta/metricStore/stackdriver/metricConfigurer.tsx +144 -0
- package/src/kayenta/metricStore/stackdriver/metricTypeSelector.spec.tsx +92 -0
- package/src/kayenta/metricStore/stackdriver/metricTypeSelector.tsx +113 -0
- package/src/kayenta/middleware/actionInterceptor.ts +29 -0
- package/src/kayenta/middleware/asyncDispatch.ts +37 -0
- package/src/kayenta/middleware/epics.ts +211 -0
- package/src/kayenta/middleware/index.ts +3 -0
- package/src/kayenta/navigation/canary.states.stub.ts +28 -0
- package/src/kayenta/navigation/canary.states.ts +182 -0
- package/src/kayenta/reducers/app.ts +56 -0
- package/src/kayenta/reducers/asyncRequest.ts +5 -0
- package/src/kayenta/reducers/data.ts +169 -0
- package/src/kayenta/reducers/editingTemplate.ts +54 -0
- package/src/kayenta/reducers/group.ts +82 -0
- package/src/kayenta/reducers/index.ts +245 -0
- package/src/kayenta/reducers/prometheusMetricConfig.spec.ts +33 -0
- package/src/kayenta/reducers/prometheusMetricConfig.ts +56 -0
- package/src/kayenta/reducers/selectedConfig.spec.ts +190 -0
- package/src/kayenta/reducers/selectedConfig.ts +566 -0
- package/src/kayenta/reducers/selectedRun.ts +101 -0
- package/src/kayenta/reducers/signalFxMetricConfig.ts +36 -0
- package/src/kayenta/reducers/stackdriverMetricConfig.spec.ts +33 -0
- package/src/kayenta/reducers/stackdriverMetricConfig.ts +41 -0
- package/src/kayenta/reducers/templates.spec.ts +192 -0
- package/src/kayenta/reducers/validators.ts +118 -0
- package/src/kayenta/report/detail/allMetricResultsHeader.tsx +32 -0
- package/src/kayenta/report/detail/clickableHeader.tsx +21 -0
- package/src/kayenta/report/detail/colors.ts +47 -0
- package/src/kayenta/report/detail/detail.less +16 -0
- package/src/kayenta/report/detail/detail.tsx +48 -0
- package/src/kayenta/report/detail/detailLoader.tsx +55 -0
- package/src/kayenta/report/detail/graph/graph.tsx +37 -0
- package/src/kayenta/report/detail/graph/metricSetPairGraph.service.ts +35 -0
- package/src/kayenta/report/detail/graph/semiotic/boxplot.less +45 -0
- package/src/kayenta/report/detail/graph/semiotic/boxplot.tsx +283 -0
- package/src/kayenta/report/detail/graph/semiotic/chartHeader.tsx +19 -0
- package/src/kayenta/report/detail/graph/semiotic/chartLegend.less +26 -0
- package/src/kayenta/report/detail/graph/semiotic/chartLegend.tsx +42 -0
- package/src/kayenta/report/detail/graph/semiotic/circleIcon.tsx +16 -0
- package/src/kayenta/report/detail/graph/semiotic/config.less +5 -0
- package/src/kayenta/report/detail/graph/semiotic/config.ts +38 -0
- package/src/kayenta/report/detail/graph/semiotic/customAxisTickLabel.tsx +17 -0
- package/src/kayenta/report/detail/graph/semiotic/declarations/labella.d.ts +16 -0
- package/src/kayenta/report/detail/graph/semiotic/declarations/react-container-dimensions.d.ts +3 -0
- package/src/kayenta/report/detail/graph/semiotic/declarations/semiotic.d.ts +160 -0
- package/src/kayenta/report/detail/graph/semiotic/differenceArea.less +17 -0
- package/src/kayenta/report/detail/graph/semiotic/differenceArea.tsx +186 -0
- package/src/kayenta/report/detail/graph/semiotic/histogram.less +22 -0
- package/src/kayenta/report/detail/graph/semiotic/histogram.tsx +251 -0
- package/src/kayenta/report/detail/graph/semiotic/index.tsx +19 -0
- package/src/kayenta/report/detail/graph/semiotic/noValidDataSign.less +5 -0
- package/src/kayenta/report/detail/graph/semiotic/noValidDataSign.tsx +10 -0
- package/src/kayenta/report/detail/graph/semiotic/secondaryTSXAxis.less +6 -0
- package/src/kayenta/report/detail/graph/semiotic/secondaryTSXAxis.tsx +58 -0
- package/src/kayenta/report/detail/graph/semiotic/semiotic.service.ts +32 -0
- package/src/kayenta/report/detail/graph/semiotic/semioticGraph.less +53 -0
- package/src/kayenta/report/detail/graph/semiotic/semioticGraph.tsx +49 -0
- package/src/kayenta/report/detail/graph/semiotic/timeSeries.less +42 -0
- package/src/kayenta/report/detail/graph/semiotic/timeSeries.tsx +473 -0
- package/src/kayenta/report/detail/graph/semiotic/tooltip.tsx +55 -0
- package/src/kayenta/report/detail/graph/semiotic/utils.ts +90 -0
- package/src/kayenta/report/detail/graphTypeSelector.less +4 -0
- package/src/kayenta/report/detail/graphTypeSelector.tsx +50 -0
- package/src/kayenta/report/detail/groupScores.tsx +68 -0
- package/src/kayenta/report/detail/header.less +70 -0
- package/src/kayenta/report/detail/header.tsx +39 -0
- package/src/kayenta/report/detail/headerArrow.tsx +13 -0
- package/src/kayenta/report/detail/loadStates.tsx +31 -0
- package/src/kayenta/report/detail/metricResultActions.less +29 -0
- package/src/kayenta/report/detail/metricResultActions.tsx +87 -0
- package/src/kayenta/report/detail/metricResultClassification.tsx +22 -0
- package/src/kayenta/report/detail/metricResultDetail.tsx +20 -0
- package/src/kayenta/report/detail/metricResultDetailLayout.tsx +19 -0
- package/src/kayenta/report/detail/metricResultDeviation.tsx +25 -0
- package/src/kayenta/report/detail/metricResultStats.less +9 -0
- package/src/kayenta/report/detail/metricResultStats.tsx +120 -0
- package/src/kayenta/report/detail/metricResults.less +12 -0
- package/src/kayenta/report/detail/metricResults.tsx +52 -0
- package/src/kayenta/report/detail/metricResultsClassificationFilters.tsx +65 -0
- package/src/kayenta/report/detail/metricResultsColumns.tsx +27 -0
- package/src/kayenta/report/detail/metricResultsList.less +44 -0
- package/src/kayenta/report/detail/metricResultsList.tsx +120 -0
- package/src/kayenta/report/detail/metricSetPairLoadStates.tsx +22 -0
- package/src/kayenta/report/detail/multipleResultsTable.tsx +81 -0
- package/src/kayenta/report/detail/reportException.tsx +57 -0
- package/src/kayenta/report/detail/reportExplanation.less +12 -0
- package/src/kayenta/report/detail/reportExplanation.tsx +32 -0
- package/src/kayenta/report/detail/reportMetadata.tsx +167 -0
- package/src/kayenta/report/detail/reportScores.less +47 -0
- package/src/kayenta/report/detail/reportScores.tsx +80 -0
- package/src/kayenta/report/detail/score.tsx +33 -0
- package/src/kayenta/report/detail/sourceLinks.tsx +69 -0
- package/src/kayenta/report/list/configLink.tsx +32 -0
- package/src/kayenta/report/list/executionList.less +7 -0
- package/src/kayenta/report/list/loadStates.tsx +32 -0
- package/src/kayenta/report/list/pipelineLink.tsx +15 -0
- package/src/kayenta/report/list/reportLink.tsx +33 -0
- package/src/kayenta/report/list/table.tsx +309 -0
- package/src/kayenta/report/report.tsx +11 -0
- package/src/kayenta/selectors/filterTemplatesSelectors.ts +87 -0
- package/src/kayenta/selectors/index.ts +62 -0
- package/src/kayenta/service/canaryConfig.service.ts +122 -0
- package/src/kayenta/service/canaryRun.service.ts +60 -0
- package/src/kayenta/service/delegateFactory.ts +24 -0
- package/src/kayenta/service/metricsServiceMetadata.service.ts +9 -0
- package/src/kayenta/stages/kayentaStage/AnalysisType.spec.tsx +47 -0
- package/src/kayenta/stages/kayentaStage/AnalysisType.tsx +49 -0
- package/src/kayenta/stages/kayentaStage/CanaryExecutionLabel.tsx +26 -0
- package/src/kayenta/stages/kayentaStage/analysisType.component.ts +12 -0
- package/src/kayenta/stages/kayentaStage/canaryRunSummaries.component.ts +12 -0
- package/src/kayenta/stages/kayentaStage/canaryRunSummaries.less +5 -0
- package/src/kayenta/stages/kayentaStage/canaryRunSummaries.tsx +136 -0
- package/src/kayenta/stages/kayentaStage/forAnalysisType.component.ts +45 -0
- package/src/kayenta/stages/kayentaStage/kayentaStage.controller.ts +789 -0
- package/src/kayenta/stages/kayentaStage/kayentaStage.html +528 -0
- package/src/kayenta/stages/kayentaStage/kayentaStage.less +5 -0
- package/src/kayenta/stages/kayentaStage/kayentaStage.transformer.ts +179 -0
- package/src/kayenta/stages/kayentaStage/kayentaStage.ts +221 -0
- package/src/kayenta/stages/kayentaStage/kayentaStageConfigSection.component.ts +21 -0
- package/src/kayenta/stages/kayentaStage/kayentaStageExecutionDetails.controller.ts +88 -0
- package/src/kayenta/stages/kayentaStage/kayentaStageExecutionDetails.html +114 -0
- package/src/kayenta/stages/kayentaStage/kayentaStageExecutionDetails.less +6 -0
- package/src/kayenta/stages/kayentaStage/stageTypes.ts +5 -0
- package/src/kayenta/utils/duration.spec.ts +69 -0
- package/src/kayenta/utils/duration.ts +48 -0
- package/src/lazy.ts +29 -0
- package/src/stub.ts +60 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import * as Creators from 'kayenta/actions/creators';
|
|
2
|
+
import { CanarySettings } from 'kayenta/canary.settings';
|
|
3
|
+
import { ICanaryFilterTemplateValidationMessages } from 'kayenta/edit/filterTemplatesValidation';
|
|
4
|
+
import {
|
|
5
|
+
DISABLE_EDIT_CONFIG,
|
|
6
|
+
DisableableInput,
|
|
7
|
+
DisableableReactSelect,
|
|
8
|
+
DisableableTextarea,
|
|
9
|
+
} from 'kayenta/layout/disableable';
|
|
10
|
+
import FormRow from 'kayenta/layout/formRow';
|
|
11
|
+
import { ICanaryState } from 'kayenta/reducers';
|
|
12
|
+
import { configTemplatesSelector, editingTemplateSelector } from 'kayenta/selectors';
|
|
13
|
+
import {
|
|
14
|
+
editingTemplateValidationSelector,
|
|
15
|
+
selectedTemplateNameSelector,
|
|
16
|
+
} from 'kayenta/selectors/filterTemplatesSelectors';
|
|
17
|
+
import { get, isString } from 'lodash';
|
|
18
|
+
import * as React from 'react';
|
|
19
|
+
import { connect } from 'react-redux';
|
|
20
|
+
import { Option } from 'react-select';
|
|
21
|
+
import { Dispatch } from 'redux';
|
|
22
|
+
|
|
23
|
+
import './filterTemplateSelector.less';
|
|
24
|
+
|
|
25
|
+
interface IFilterTemplateSelectorStateProps {
|
|
26
|
+
editedTemplateName: string;
|
|
27
|
+
editedTemplateValue: string;
|
|
28
|
+
selectedTemplateName: string;
|
|
29
|
+
templates: { [key: string]: string };
|
|
30
|
+
validation: ICanaryFilterTemplateValidationMessages;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface IFilterTemplateSelectorDispatchProps {
|
|
34
|
+
deleteTemplate: (e: any, name: string) => void;
|
|
35
|
+
editTemplateBegin: (e: any, name: string, value: string) => void;
|
|
36
|
+
editTemplateCancel: () => void;
|
|
37
|
+
editTemplateConfirm: () => void;
|
|
38
|
+
editTemplateName: (event: any) => void;
|
|
39
|
+
editTemplateValue: (event: any) => void;
|
|
40
|
+
selectTemplate: (option: Option) => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type IFilterTemplateSelectorProps = IFilterTemplateSelectorStateProps & IFilterTemplateSelectorDispatchProps;
|
|
44
|
+
|
|
45
|
+
export class FilterTemplateSelector extends React.Component<IFilterTemplateSelectorProps> {
|
|
46
|
+
private getOptions = (): Option[] => {
|
|
47
|
+
const templateOptions = Object.keys(this.props.templates).map((t) => ({
|
|
48
|
+
value: t,
|
|
49
|
+
label: t,
|
|
50
|
+
requestingNew: false,
|
|
51
|
+
}));
|
|
52
|
+
templateOptions.push({ value: null, label: null, requestingNew: true });
|
|
53
|
+
return templateOptions;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
private optionRenderer = (option: Option<string>): JSX.Element => {
|
|
57
|
+
if (option.requestingNew) {
|
|
58
|
+
return <span>Create new...</span>;
|
|
59
|
+
}
|
|
60
|
+
return (
|
|
61
|
+
<span className="filter-template-option">
|
|
62
|
+
<span>{option.label}</span>
|
|
63
|
+
<span>
|
|
64
|
+
<button className="link" onMouseDown={(e) => this.props.deleteTemplate(e, option.value)}>
|
|
65
|
+
Delete
|
|
66
|
+
</button>
|
|
67
|
+
<button
|
|
68
|
+
className="link"
|
|
69
|
+
onMouseDown={(e) => this.props.editTemplateBegin(e, option.value, this.props.templates[option.value])}
|
|
70
|
+
>
|
|
71
|
+
Edit
|
|
72
|
+
</button>
|
|
73
|
+
</span>
|
|
74
|
+
</span>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
public render() {
|
|
79
|
+
const {
|
|
80
|
+
editedTemplateName,
|
|
81
|
+
editedTemplateValue,
|
|
82
|
+
editTemplateCancel,
|
|
83
|
+
editTemplateConfirm,
|
|
84
|
+
editTemplateName,
|
|
85
|
+
editTemplateValue,
|
|
86
|
+
selectTemplate,
|
|
87
|
+
selectedTemplateName,
|
|
88
|
+
templates,
|
|
89
|
+
validation,
|
|
90
|
+
} = this.props;
|
|
91
|
+
const isEditing = isString(editedTemplateName) && isString(editedTemplateValue);
|
|
92
|
+
return (
|
|
93
|
+
<>
|
|
94
|
+
<FormRow label="Filter Template" helpId="canary.config.filterTemplate" inputOnly={true}>
|
|
95
|
+
{!isEditing && (
|
|
96
|
+
<DisableableReactSelect
|
|
97
|
+
value={selectedTemplateName}
|
|
98
|
+
disabledStateKeys={[DISABLE_EDIT_CONFIG]}
|
|
99
|
+
disabled={CanarySettings.disableConfigEdit}
|
|
100
|
+
onChange={selectTemplate}
|
|
101
|
+
options={this.getOptions()}
|
|
102
|
+
optionRenderer={this.optionRenderer}
|
|
103
|
+
/>
|
|
104
|
+
)}
|
|
105
|
+
</FormRow>
|
|
106
|
+
{isEditing && (
|
|
107
|
+
<>
|
|
108
|
+
<FormRow label="Name" error={get(validation, 'errors.templateName.message')} inputOnly={true}>
|
|
109
|
+
<DisableableInput
|
|
110
|
+
disabledStateKeys={[DISABLE_EDIT_CONFIG]}
|
|
111
|
+
disabled={CanarySettings.disableConfigEdit}
|
|
112
|
+
onChange={editTemplateName}
|
|
113
|
+
value={editedTemplateName}
|
|
114
|
+
/>
|
|
115
|
+
</FormRow>
|
|
116
|
+
<FormRow
|
|
117
|
+
label="Template"
|
|
118
|
+
inputOnly={true}
|
|
119
|
+
error={get(validation, 'errors.templateValue.message')}
|
|
120
|
+
warning={get(validation, 'warnings.template.message')}
|
|
121
|
+
>
|
|
122
|
+
<DisableableTextarea
|
|
123
|
+
className="template-editor-textarea"
|
|
124
|
+
disabledStateKeys={[DISABLE_EDIT_CONFIG]}
|
|
125
|
+
disabled={CanarySettings.disableConfigEdit}
|
|
126
|
+
onChange={editTemplateValue}
|
|
127
|
+
value={editedTemplateValue}
|
|
128
|
+
/>
|
|
129
|
+
</FormRow>
|
|
130
|
+
<FormRow>
|
|
131
|
+
<div className="horizontal pull-right">
|
|
132
|
+
<button className="link" onClick={editTemplateCancel}>
|
|
133
|
+
Cancel
|
|
134
|
+
</button>
|
|
135
|
+
<button
|
|
136
|
+
className="link"
|
|
137
|
+
disabled={[validation.errors.templateName, validation.errors.templateValue].some((e) => e != null)}
|
|
138
|
+
onClick={editTemplateConfirm}
|
|
139
|
+
>
|
|
140
|
+
Save
|
|
141
|
+
</button>
|
|
142
|
+
</div>
|
|
143
|
+
</FormRow>
|
|
144
|
+
</>
|
|
145
|
+
)}
|
|
146
|
+
{!isEditing && selectedTemplateName && (
|
|
147
|
+
<FormRow>
|
|
148
|
+
<pre className="template-editor-value-formatted">{templates[selectedTemplateName]}</pre>
|
|
149
|
+
</FormRow>
|
|
150
|
+
)}
|
|
151
|
+
</>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const mapStateToProps = (state: ICanaryState): IFilterTemplateSelectorStateProps => ({
|
|
157
|
+
editedTemplateName: get(editingTemplateSelector(state), 'editedName'),
|
|
158
|
+
editedTemplateValue: get(editingTemplateSelector(state), 'editedValue'),
|
|
159
|
+
selectedTemplateName: selectedTemplateNameSelector(state),
|
|
160
|
+
templates: configTemplatesSelector(state),
|
|
161
|
+
validation: editingTemplateValidationSelector(state),
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const mapDispatchToProps = (dispatch: Dispatch<ICanaryState>): IFilterTemplateSelectorDispatchProps => ({
|
|
165
|
+
deleteTemplate: (e: any, name: string) => {
|
|
166
|
+
e.stopPropagation();
|
|
167
|
+
dispatch(Creators.selectTemplate({ name: null }));
|
|
168
|
+
dispatch(Creators.deleteTemplate({ name }));
|
|
169
|
+
},
|
|
170
|
+
editTemplateBegin: (e: any, name: string, value: string) => {
|
|
171
|
+
e.stopPropagation();
|
|
172
|
+
dispatch(Creators.selectTemplate({ name }));
|
|
173
|
+
dispatch(
|
|
174
|
+
Creators.editTemplateBegin({
|
|
175
|
+
name,
|
|
176
|
+
value,
|
|
177
|
+
}),
|
|
178
|
+
);
|
|
179
|
+
},
|
|
180
|
+
editTemplateCancel: () => dispatch(Creators.editTemplateCancel()),
|
|
181
|
+
editTemplateConfirm: () => dispatch(Creators.editTemplateConfirm()),
|
|
182
|
+
editTemplateName: (event: any) => dispatch(Creators.editTemplateName({ name: event.target.value })),
|
|
183
|
+
editTemplateValue: (event: any) => dispatch(Creators.editTemplateValue({ value: event.target.value })),
|
|
184
|
+
selectTemplate: (option: Option<string>) => {
|
|
185
|
+
if (option && option.requestingNew === true) {
|
|
186
|
+
dispatch(Creators.selectTemplate({ name: null }));
|
|
187
|
+
dispatch(Creators.addTemplate());
|
|
188
|
+
} else {
|
|
189
|
+
dispatch(Creators.selectTemplate({ name: option ? option.value : null }));
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
export default connect(mapStateToProps, mapDispatchToProps)(FilterTemplateSelector);
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ITemplateValidationInput,
|
|
3
|
+
validateTemplateInUseWarning,
|
|
4
|
+
validateTemplateName,
|
|
5
|
+
validateTemplateValue,
|
|
6
|
+
} from './filterTemplatesValidation';
|
|
7
|
+
import { PrometheusQueryType } from '../metricStore/prometheus/domain/IPrometheusCanaryMetricSetQueryConfig';
|
|
8
|
+
|
|
9
|
+
describe('Filter template validation', () => {
|
|
10
|
+
let validationInput: ITemplateValidationInput;
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
validationInput = getTestValidationInput();
|
|
13
|
+
});
|
|
14
|
+
describe('validateTemplateName', () => {
|
|
15
|
+
it('handles valid name', () => {
|
|
16
|
+
expect(validateTemplateName({ errors: {}, warnings: {} }, validationInput)).toEqual({ errors: {}, warnings: {} });
|
|
17
|
+
});
|
|
18
|
+
it('handles missing template name', () => {
|
|
19
|
+
validationInput.editingTemplate.editedName = '';
|
|
20
|
+
expect(validateTemplateName({ errors: {}, warnings: {} }, validationInput).errors.templateName.message).toEqual(
|
|
21
|
+
'Name is required',
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
it('handles duplicate template name', () => {
|
|
25
|
+
validationInput.editingTemplate.editedName = 'my-other-filter-template';
|
|
26
|
+
expect(validateTemplateName({ errors: {}, warnings: {} }, validationInput).errors.templateName.message).toEqual(
|
|
27
|
+
"Filter template named 'my-other-filter-template' already exists",
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe('validateTemplateValue', () => {
|
|
32
|
+
it('handles valid template value', () => {
|
|
33
|
+
expect(validateTemplateValue({ errors: {}, warnings: {} }, validationInput)).toEqual({
|
|
34
|
+
errors: {},
|
|
35
|
+
warnings: {},
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
it('handles missing template value', () => {
|
|
39
|
+
validationInput.editingTemplate.editedValue = '';
|
|
40
|
+
expect(validateTemplateValue({ errors: {}, warnings: {} }, validationInput).errors.templateValue.message).toEqual(
|
|
41
|
+
'Value is required',
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
describe('validateTemplateInUseWarning', () => {
|
|
46
|
+
it('handles template not in use by other metrics', () => {
|
|
47
|
+
expect(validateTemplateInUseWarning({ errors: {}, warnings: {} }, validationInput)).toEqual({
|
|
48
|
+
errors: {},
|
|
49
|
+
warnings: {},
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
it('warns if other metrics are using selected template', () => {
|
|
53
|
+
validationInput.metricList.push({
|
|
54
|
+
id: '#1',
|
|
55
|
+
name: 'my other metric',
|
|
56
|
+
groups: ['group-1'],
|
|
57
|
+
analysisConfigurations: null,
|
|
58
|
+
scopeName: 'default',
|
|
59
|
+
query: {
|
|
60
|
+
customFilterTemplate: 'my-filter-template',
|
|
61
|
+
queryType: PrometheusQueryType.DEFAULT,
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
expect(
|
|
65
|
+
validateTemplateInUseWarning({ errors: {}, warnings: {} }, validationInput).warnings.template.message,
|
|
66
|
+
).toEqual('Warning: editing or deleting this template will affect the following metrics: my other metric');
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
function getTestValidationInput(): ITemplateValidationInput {
|
|
72
|
+
return {
|
|
73
|
+
editingTemplate: {
|
|
74
|
+
name: 'my-filter-template',
|
|
75
|
+
editedName: 'my-filter-template-edited',
|
|
76
|
+
editedValue: 'metadata.user_labels."app"="${scope}"',
|
|
77
|
+
isNew: false,
|
|
78
|
+
},
|
|
79
|
+
configTemplates: {
|
|
80
|
+
'my-filter-template': 'metadata.user_labels."app"="${scope}"',
|
|
81
|
+
'my-other-filter-template': 'metadata.user_labels."app"="${location}"',
|
|
82
|
+
},
|
|
83
|
+
metricList: [
|
|
84
|
+
{
|
|
85
|
+
id: '#0',
|
|
86
|
+
name: 'my metric',
|
|
87
|
+
groups: ['group-1'],
|
|
88
|
+
analysisConfigurations: null,
|
|
89
|
+
scopeName: 'default',
|
|
90
|
+
query: {
|
|
91
|
+
customFilterTemplate: 'my-filter-template',
|
|
92
|
+
queryType: PrometheusQueryType.DEFAULT,
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
editingMetric: {
|
|
97
|
+
id: '#0',
|
|
98
|
+
name: 'my metric',
|
|
99
|
+
groups: ['group-1'],
|
|
100
|
+
analysisConfigurations: null,
|
|
101
|
+
scopeName: 'default',
|
|
102
|
+
query: {
|
|
103
|
+
customFilterTemplate: 'my-filter-template',
|
|
104
|
+
queryType: PrometheusQueryType.DEFAULT,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { get, isEmpty } from 'lodash';
|
|
2
|
+
|
|
3
|
+
import { ICanaryMetricConfig } from '../domain';
|
|
4
|
+
import { IEditingTemplateState } from '../reducers/editingTemplate';
|
|
5
|
+
|
|
6
|
+
export interface ICanaryFilterTemplateValidationMessage {
|
|
7
|
+
message: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type ICanaryFilterTemplateValidationErrorKeys = 'templateName' | 'templateValue';
|
|
11
|
+
|
|
12
|
+
type ICanaryFilterTemplateValidationWarningKeys = 'template';
|
|
13
|
+
|
|
14
|
+
export interface ICanaryFilterTemplateValidationMessages {
|
|
15
|
+
errors: { [K in ICanaryFilterTemplateValidationErrorKeys]?: ICanaryFilterTemplateValidationMessage };
|
|
16
|
+
warnings: { [K in ICanaryFilterTemplateValidationWarningKeys]?: ICanaryFilterTemplateValidationMessage };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ITemplateValidationInput {
|
|
20
|
+
editingTemplate: IEditingTemplateState;
|
|
21
|
+
configTemplates: { [name: string]: string };
|
|
22
|
+
metricList: ICanaryMetricConfig[];
|
|
23
|
+
editingMetric: ICanaryMetricConfig;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function validateTemplateName(
|
|
27
|
+
validation: ICanaryFilterTemplateValidationMessages,
|
|
28
|
+
validationInput: ITemplateValidationInput,
|
|
29
|
+
): ICanaryFilterTemplateValidationMessages {
|
|
30
|
+
const { editingTemplate, configTemplates } = validationInput;
|
|
31
|
+
|
|
32
|
+
if (editingTemplate.editedName === '') {
|
|
33
|
+
validation.errors.templateName = {
|
|
34
|
+
message: 'Name is required',
|
|
35
|
+
};
|
|
36
|
+
return validation;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const isNameEdited = editingTemplate && editingTemplate.editedName !== editingTemplate.name;
|
|
40
|
+
const savedTemplateNames = Object.keys(configTemplates || {});
|
|
41
|
+
const isNameDuplicate = isNameEdited && savedTemplateNames.some((name) => editingTemplate.editedName === name);
|
|
42
|
+
if (isNameDuplicate) {
|
|
43
|
+
validation.errors.templateName = {
|
|
44
|
+
message: `Filter template named '${editingTemplate.editedName}' already exists`,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return validation;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function validateTemplateValue(
|
|
52
|
+
validation: ICanaryFilterTemplateValidationMessages,
|
|
53
|
+
validationInput: ITemplateValidationInput,
|
|
54
|
+
): ICanaryFilterTemplateValidationMessages {
|
|
55
|
+
const { editingTemplate } = validationInput;
|
|
56
|
+
|
|
57
|
+
if (editingTemplate.editedValue === '') {
|
|
58
|
+
validation.errors.templateValue = {
|
|
59
|
+
message: 'Value is required',
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return validation;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function validateTemplateInUseWarning(
|
|
67
|
+
validation: ICanaryFilterTemplateValidationMessages,
|
|
68
|
+
validationInput: ITemplateValidationInput,
|
|
69
|
+
): ICanaryFilterTemplateValidationMessages {
|
|
70
|
+
const { metricList, editingMetric } = validationInput;
|
|
71
|
+
const filterTemplate = get(editingMetric, 'query.customFilterTemplate');
|
|
72
|
+
|
|
73
|
+
const otherMetricsUsingTemplate =
|
|
74
|
+
editingMetric != null &&
|
|
75
|
+
filterTemplate != null &&
|
|
76
|
+
metricList.filter((m) => m.name !== editingMetric.name && filterTemplate === get(m, 'query.customFilterTemplate'));
|
|
77
|
+
|
|
78
|
+
if (!isEmpty(otherMetricsUsingTemplate)) {
|
|
79
|
+
validation.warnings.template = {
|
|
80
|
+
message: `Warning: editing or deleting this template will affect the following metrics: ${otherMetricsUsingTemplate
|
|
81
|
+
.map((m) => m.name)
|
|
82
|
+
.join(', ')}`,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return validation;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function validateTemplate(
|
|
89
|
+
templateValidationInput: ITemplateValidationInput,
|
|
90
|
+
): ICanaryFilterTemplateValidationMessages {
|
|
91
|
+
return [validateTemplateName, validateTemplateValue, validateTemplateInUseWarning].reduce(
|
|
92
|
+
(reducedValidation, validator) => validator(reducedValidation, templateValidationInput),
|
|
93
|
+
{ errors: {}, warnings: {} },
|
|
94
|
+
);
|
|
95
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Copied from deck/core .pipeline-footer. Not clear at this point if they should converge.
|
|
2
|
+
.canary-footer {
|
|
3
|
+
position: fixed;
|
|
4
|
+
z-index: 4;
|
|
5
|
+
bottom: 0;
|
|
6
|
+
left: 0;
|
|
7
|
+
right: 0;
|
|
8
|
+
background-color: #ffffff;
|
|
9
|
+
margin: 0;
|
|
10
|
+
border-top: 1px solid #d9d9d9;
|
|
11
|
+
.col-sm-12 {
|
|
12
|
+
padding: 5px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.alert {
|
|
16
|
+
display: inline-block;
|
|
17
|
+
margin-bottom: 0;
|
|
18
|
+
margin-right: 5px;
|
|
19
|
+
padding: 6px 12px;
|
|
20
|
+
vertical-align: middle;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.fa.fa-exclamation-triangle {
|
|
24
|
+
font-size: 125%;
|
|
25
|
+
color: var(--color-danger);
|
|
26
|
+
opacity: 1;
|
|
27
|
+
margin-left: 5px;
|
|
28
|
+
padding: 0 2px;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
|
|
4
|
+
import './footer.less';
|
|
5
|
+
|
|
6
|
+
export interface IFooterProps {
|
|
7
|
+
children?: JSX.Element;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default function Footer({ children }: IFooterProps) {
|
|
11
|
+
return <div className={classNames('row', 'canary-footer')}>{children}</div>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as Creators from 'kayenta/actions/creators';
|
|
2
|
+
import { CanarySettings } from 'kayenta/canary.settings';
|
|
3
|
+
import { DISABLE_EDIT_CONFIG, DisableableInput } from 'kayenta/layout/disableable';
|
|
4
|
+
import { ICanaryState } from 'kayenta/reducers';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import { connect } from 'react-redux';
|
|
7
|
+
import { Action } from 'redux';
|
|
8
|
+
|
|
9
|
+
interface IGroupNameStateProps {
|
|
10
|
+
group: string;
|
|
11
|
+
edit: string;
|
|
12
|
+
editing: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface IGroupNameDispatchProps {
|
|
16
|
+
handleSubmit: (event: any) => void;
|
|
17
|
+
handleUpdate: (event: any) => void;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface IGroupNameOwnProps {
|
|
21
|
+
group: string;
|
|
22
|
+
editing: boolean;
|
|
23
|
+
onClick: (event: React.SyntheticEvent<HTMLAnchorElement>) => void;
|
|
24
|
+
defaultGroup: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/*
|
|
28
|
+
* Configures a group name.
|
|
29
|
+
*/
|
|
30
|
+
function GroupName({
|
|
31
|
+
editing,
|
|
32
|
+
edit,
|
|
33
|
+
group,
|
|
34
|
+
onClick,
|
|
35
|
+
handleUpdate,
|
|
36
|
+
handleSubmit,
|
|
37
|
+
defaultGroup,
|
|
38
|
+
}: IGroupNameStateProps & IGroupNameDispatchProps & IGroupNameOwnProps) {
|
|
39
|
+
if (editing) {
|
|
40
|
+
return (
|
|
41
|
+
<form onSubmit={handleSubmit} onBlur={handleSubmit} data-group={group} data-edit={edit}>
|
|
42
|
+
<DisableableInput
|
|
43
|
+
autoFocus={true}
|
|
44
|
+
value={edit}
|
|
45
|
+
onChange={handleUpdate}
|
|
46
|
+
disabled={CanarySettings.disableConfigEdit}
|
|
47
|
+
disabledStateKeys={[DISABLE_EDIT_CONFIG]}
|
|
48
|
+
/>
|
|
49
|
+
</form>
|
|
50
|
+
);
|
|
51
|
+
} else {
|
|
52
|
+
return (
|
|
53
|
+
<a data-group={group} onClick={onClick}>
|
|
54
|
+
{group || defaultGroup}
|
|
55
|
+
</a>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function mapStateToProps(state: ICanaryState, ownProps: IGroupNameOwnProps): IGroupNameStateProps & IGroupNameOwnProps {
|
|
61
|
+
return {
|
|
62
|
+
edit: state.selectedConfig.group.edit,
|
|
63
|
+
...ownProps,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function mapDispatchToProps(dispatch: (action: Action & any) => void): IGroupNameDispatchProps {
|
|
68
|
+
return {
|
|
69
|
+
handleUpdate: (event: any) => {
|
|
70
|
+
dispatch(Creators.editGroupUpdate({ edit: event.target.value }));
|
|
71
|
+
},
|
|
72
|
+
handleSubmit: (event: any) => {
|
|
73
|
+
dispatch(Creators.editGroupConfirm({ ...event.currentTarget.dataset }));
|
|
74
|
+
event.stopPropagation();
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export default connect(mapStateToProps, mapDispatchToProps)(GroupName);
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import * as Creators from 'kayenta/actions/creators';
|
|
3
|
+
import { CanarySettings } from 'kayenta/canary.settings';
|
|
4
|
+
import { DISABLE_EDIT_CONFIG, DisableableButton } from 'kayenta/layout/disableable';
|
|
5
|
+
import { Tab, Tabs } from 'kayenta/layout/tabs';
|
|
6
|
+
import { ICanaryState } from 'kayenta/reducers';
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import { connect } from 'react-redux';
|
|
9
|
+
import { Action } from 'redux';
|
|
10
|
+
|
|
11
|
+
import { noop } from '@spinnaker/core';
|
|
12
|
+
|
|
13
|
+
import GroupName from './groupName';
|
|
14
|
+
|
|
15
|
+
export const ALL = 'all';
|
|
16
|
+
|
|
17
|
+
interface IGroupTabsStateProps {
|
|
18
|
+
groupList: string[];
|
|
19
|
+
selectedGroup: string;
|
|
20
|
+
editing: boolean;
|
|
21
|
+
disableConfigEdit: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface IGroupTabsDispatchProps {
|
|
25
|
+
selectGroup: (event: any) => void;
|
|
26
|
+
addGroup: (event: any) => void;
|
|
27
|
+
editGroupBegin: (event: any) => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
* Configures an entire list of metrics.
|
|
32
|
+
*/
|
|
33
|
+
function GroupTabs({
|
|
34
|
+
groupList,
|
|
35
|
+
selectedGroup,
|
|
36
|
+
selectGroup,
|
|
37
|
+
addGroup,
|
|
38
|
+
editing,
|
|
39
|
+
editGroupBegin,
|
|
40
|
+
disableConfigEdit,
|
|
41
|
+
}: IGroupTabsStateProps & IGroupTabsDispatchProps) {
|
|
42
|
+
const GroupTab = ({ group, editable = false }: { group: string; editable?: boolean }) => {
|
|
43
|
+
const selected = selectedGroup === group;
|
|
44
|
+
return (
|
|
45
|
+
<Tab selected={selected}>
|
|
46
|
+
<GroupName group={group} editing={selected && editing} onClick={selectGroup} defaultGroup={ALL} />
|
|
47
|
+
{selected && editable && !editing && (
|
|
48
|
+
<i
|
|
49
|
+
data-group={group}
|
|
50
|
+
onClick={disableConfigEdit || CanarySettings.disableConfigEdit ? noop : editGroupBegin}
|
|
51
|
+
className={classNames('fas', 'fa-pencil-alt', {
|
|
52
|
+
disabled: disableConfigEdit || CanarySettings.disableConfigEdit,
|
|
53
|
+
})}
|
|
54
|
+
/>
|
|
55
|
+
)}
|
|
56
|
+
</Tab>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
59
|
+
return (
|
|
60
|
+
<section className="group-tabs">
|
|
61
|
+
<Tabs style={{ marginBottom: '0' }}>
|
|
62
|
+
<GroupTab group="" />
|
|
63
|
+
{groupList.map((group) => (
|
|
64
|
+
<GroupTab key={group} group={group} editable={true} />
|
|
65
|
+
))}
|
|
66
|
+
<DisableableButton
|
|
67
|
+
className="passive float-right"
|
|
68
|
+
onClick={addGroup}
|
|
69
|
+
disabled={CanarySettings.disableConfigEdit}
|
|
70
|
+
disabledStateKeys={[DISABLE_EDIT_CONFIG]}
|
|
71
|
+
>
|
|
72
|
+
Add Group
|
|
73
|
+
</DisableableButton>
|
|
74
|
+
</Tabs>
|
|
75
|
+
</section>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function mapStateToProps(state: ICanaryState): IGroupTabsStateProps {
|
|
80
|
+
return {
|
|
81
|
+
groupList: state.selectedConfig.group.list,
|
|
82
|
+
selectedGroup: state.selectedConfig.group.selected,
|
|
83
|
+
editing: !!state.selectedConfig.group.edit || state.selectedConfig.group.edit === '',
|
|
84
|
+
disableConfigEdit: state.app.disableConfigEdit || CanarySettings.disableConfigEdit,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function mapDispatchToProps(dispatch: (action: Action & any) => void): IGroupTabsDispatchProps {
|
|
89
|
+
return {
|
|
90
|
+
selectGroup: (event: any) => {
|
|
91
|
+
dispatch(Creators.selectGroup({ name: event.target.dataset.group }));
|
|
92
|
+
event.preventDefault();
|
|
93
|
+
event.stopPropagation();
|
|
94
|
+
},
|
|
95
|
+
addGroup: (event: any) => {
|
|
96
|
+
dispatch(Creators.addGroup());
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
event.stopPropagation();
|
|
99
|
+
},
|
|
100
|
+
editGroupBegin: (event: any) => {
|
|
101
|
+
dispatch(Creators.editGroupBegin({ group: event.target.dataset.group }));
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export default connect(mapStateToProps, mapDispatchToProps)(GroupTabs);
|