fix(ui): use new style alertmanager input values

This commit is contained in:
Łukasz Mierzwa
2019-01-01 21:54:17 +00:00
parent 09d1196df0
commit 62db6859ea
2 changed files with 18 additions and 16 deletions

View File

@@ -7,16 +7,13 @@ import { observer } from "mobx-react";
import ReactSelect from "react-select";
import { AlertStore } from "Stores/AlertStore";
import { SilenceFormStore } from "Stores/SilenceFormStore";
import {
SilenceFormStore,
AlertmanagerClustersToOption
} from "Stores/SilenceFormStore";
import { MultiSelect, ReactSelectStyles } from "Components/MultiSelect";
import { ValidationError } from "Components/MultiSelect/ValidationError";
const AlertmanagerClustersToOption = clusterDict =>
Object.entries(clusterDict).map(([clusterID, clusterMembers]) => ({
label: clusterMembers.join(" | "),
value: clusterMembers
}));
const AlertManagerInput = observer(
class AlertManagerInput extends MultiSelect {
static propTypes = {

View File

@@ -19,6 +19,12 @@ const NewEmptyMatcher = () => {
const MatcherValueToObject = value => ({ label: value, value: value });
const AlertmanagerClustersToOption = clusterDict =>
Object.entries(clusterDict).map(([clusterID, clusterMembers]) => ({
label: clusterMembers.join(" | "),
value: clusterMembers
}));
const SilenceFormStage = Object.freeze({
UserInput: "form",
Preview: "preview",
@@ -155,12 +161,10 @@ class SilenceFormStore {
fillFormFromSilence(alertmanager, silence) {
this.silenceID = silence.id;
this.alertmanagers = [
{
label: alertmanager.name,
value: alertmanager.publicURI
}
];
this.alertmanagers = AlertmanagerClustersToOption({
[alertmanager.cluster]: alertmanager.clusterMembers
});
const matchers = [];
for (const m of silence.matchers) {
@@ -214,8 +218,8 @@ class SilenceFormStore {
m.values.length > 1
? `(${m.values.map(v => v.value).join("|")})`
: m.values.length === 1
? m.values[0].value
: "",
? m.values[0].value
: "",
isRegex: m.isRegex
})),
startsAt: this.startsAt
@@ -270,5 +274,6 @@ export {
SilenceFormStore,
SilenceFormStage,
NewEmptyMatcher,
MatcherValueToObject
MatcherValueToObject,
AlertmanagerClustersToOption
};