diff --git a/ui/src/Components/AlertAck/index.js b/ui/src/Components/AlertAck/index.js index 0db2fb741..766395d9f 100644 --- a/ui/src/Components/AlertAck/index.js +++ b/ui/src/Components/AlertAck/index.js @@ -173,9 +173,7 @@ const AlertAck = observer( } let author = - alertStore.settings.values.silenceForm.author !== "" - ? alertStore.settings.values.silenceForm.author - : silenceFormStore.data.author !== "" + silenceFormStore.data.author !== "" ? toJS(silenceFormStore.data.author) : toJS(alertStore.settings.values.alertAcknowledgement.author); diff --git a/ui/src/Components/AlertAck/index.test.js b/ui/src/Components/AlertAck/index.test.js index 14f04daa7..d0f772c79 100644 --- a/ui/src/Components/AlertAck/index.test.js +++ b/ui/src/Components/AlertAck/index.test.js @@ -192,7 +192,6 @@ describe("", () => { it("uses author from authentication info when auth is enabled", () => { alertStore.info.authentication.enabled = true; alertStore.info.authentication.username = "auth@example.com"; - alertStore.settings.values.silenceForm.author = "john@example.com"; alertStore.settings.values.alertAcknowledgement.durationSeconds = 222; alertStore.settings.values.alertAcknowledgement.author = "me"; alertStore.settings.values.alertAcknowledgement.commentPrefix = "FOO:"; @@ -210,27 +209,9 @@ describe("", () => { }); }); - it("uses author from alertStore if present", () => { - alertStore.settings.values.silenceForm.author = "john@example.com"; - alertStore.settings.values.alertAcknowledgement.durationSeconds = 222; - alertStore.settings.values.alertAcknowledgement.author = "me"; - alertStore.settings.values.alertAcknowledgement.commentPrefix = "FOO:"; - MountAndClick(); - expect(JSON.parse(fetch.mock.calls[0][1].body)).toEqual({ - comment: - "FOO: This alert was acknowledged using karma on Tue Feb 01 2000 00:00:00 GMT+0000", - createdBy: "john@example.com", - endsAt: "2000-02-01T00:03:42.000Z", - matchers: [ - { isRegex: false, name: "alertname", value: "Fake Alert" }, - { isRegex: true, name: "foo", value: "(bar|baz)" } - ], - startsAt: "2000-02-01T00:00:00.000Z" - }); - }); - - it("uses author from silenceFormStore if alertStore is empty", () => { - alertStore.settings.values.silenceForm.author = ""; + it("uses author from silenceFormStore if authentication is disabled", () => { + alertStore.info.authentication.enabled = false; + alertStore.info.authentication.username = "wrong"; alertStore.settings.values.alertAcknowledgement.durationSeconds = 222; alertStore.settings.values.alertAcknowledgement.author = "me"; alertStore.settings.values.alertAcknowledgement.commentPrefix = "FOO:"; @@ -250,7 +231,6 @@ describe("", () => { }); it("uses default author as fallback", () => { - alertStore.settings.values.silenceForm.author = ""; alertStore.settings.values.alertAcknowledgement.durationSeconds = 222; alertStore.settings.values.alertAcknowledgement.author = "me"; alertStore.settings.values.alertAcknowledgement.commentPrefix = "FOO:"; diff --git a/ui/src/Components/SilenceModal/SilenceForm.js b/ui/src/Components/SilenceModal/SilenceForm.js index e6a72dfe3..b7aaa7e05 100644 --- a/ui/src/Components/SilenceModal/SilenceForm.js +++ b/ui/src/Components/SilenceModal/SilenceForm.js @@ -69,11 +69,6 @@ const SilenceForm = observer( populateAuthor = action(() => { const { alertStore, silenceFormStore, settingsStore } = this.props; - if (alertStore.settings.values.silenceForm.author !== "") { - settingsStore.silenceFormConfig.config.author = - alertStore.settings.values.silenceForm.author; - } - if (silenceFormStore.data.author === "") { silenceFormStore.data.author = settingsStore.silenceFormConfig.config.author; diff --git a/ui/src/Components/SilenceModal/SilenceForm.test.js b/ui/src/Components/SilenceModal/SilenceForm.test.js index 40734a056..ae8d7aa14 100644 --- a/ui/src/Components/SilenceModal/SilenceForm.test.js +++ b/ui/src/Components/SilenceModal/SilenceForm.test.js @@ -145,25 +145,6 @@ describe(" inputs", () => { expect(silenceFormStore.data.author).toBe("foo@example.com"); }); - it("default author value comes from the API response if present", () => { - alertStore.settings.values.silenceForm.author = "bar@example.com"; - settingsStore.silenceFormConfig.config.author = "foo@example.com"; - const tree = MountedSilenceForm(); - const input = tree.find("input[placeholder='Author']"); - expect(input.props().value).toBe("bar@example.com"); - }); - - it("author value from the API response is saved to the Settings store", () => { - alertStore.settings.values.silenceForm.author = "bar@example.com"; - settingsStore.silenceFormConfig.config.author = ""; - const tree = MountedSilenceForm(); - const input = tree.find("input[placeholder='Author']"); - expect(input.props().value).toBe("bar@example.com"); - expect(settingsStore.silenceFormConfig.config.author).toBe( - "bar@example.com" - ); - }); - it("default author value is empty if nothing is stored in Settings", () => { settingsStore.silenceFormConfig.config.author = ""; const tree = MountedSilenceForm(); diff --git a/ui/src/Stores/AlertStore.js b/ui/src/Stores/AlertStore.js index 9bbffedad..84c948377 100644 --- a/ui/src/Stores/AlertStore.js +++ b/ui/src/Stores/AlertStore.js @@ -258,7 +258,6 @@ class AlertStore { valueMapping: {} }, silenceForm: { - author: "", strip: { labels: [] }