Commit 4254608d authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch 'alert-opsgenie-intergration-error' into 'master'

Alert Opsgenie integration errors

See merge request gitlab-org/gitlab!36648
parents 63ba19d7 1aab8ba1
...@@ -91,6 +91,7 @@ export default { ...@@ -91,6 +91,7 @@ export default {
feedbackMessage: null, feedbackMessage: null,
isFeedbackDismissed: false, isFeedbackDismissed: false,
}, },
serverError: null,
testAlert: { testAlert: {
json: null, json: null,
error: null, error: null,
...@@ -196,6 +197,10 @@ export default { ...@@ -196,6 +197,10 @@ export default {
} }
}, },
methods: { methods: {
createUserErrorMessage(errors) {
// eslint-disable-next-line prefer-destructuring
this.serverError = Object.values(errors)[0][0];
},
setOpsgenieAsDefault() { setOpsgenieAsDefault() {
this.options = this.options.map(el => { this.options = this.options.map(el => {
if (el.value !== 'opsgenie') { if (el.value !== 'opsgenie') {
...@@ -221,6 +226,7 @@ export default { ...@@ -221,6 +226,7 @@ export default {
this.targetUrl = this.selectedService.targetUrl; this.targetUrl = this.selectedService.targetUrl;
}, },
dismissFeedback() { dismissFeedback() {
this.serverError = null;
this.feedback = { ...this.feedback, feedbackMessage: null }; this.feedback = { ...this.feedback, feedbackMessage: null };
this.isFeedbackDismissed = false; this.isFeedbackDismissed = false;
}, },
...@@ -285,9 +291,10 @@ export default { ...@@ -285,9 +291,10 @@ export default {
// eslint-disable-next-line no-return-assign // eslint-disable-next-line no-return-assign
return (this.options = serviceOptions); return (this.options = serviceOptions);
}) })
.catch(() => { .catch(({ response: { data: { errors } = {} } = {} }) => {
this.createUserErrorMessage(errors);
this.setFeedback({ this.setFeedback({
feedbackMessage: this.$options.i18n.errorMsg, feedbackMessage: `${this.$options.i18n.errorMsg}.`,
variant: 'danger', variant: 'danger',
}); });
}) })
...@@ -313,9 +320,10 @@ export default { ...@@ -313,9 +320,10 @@ export default {
this.toggleSuccess(value); this.toggleSuccess(value);
this.removeOpsGenieOption(); this.removeOpsGenieOption();
}) })
.catch(() => { .catch(({ response: { data: { errors } = {} } = {} }) => {
this.createUserErrorMessage(errors);
this.setFeedback({ this.setFeedback({
feedbackMessage: this.$options.i18n.errorApiUrlMsg, feedbackMessage: `${this.$options.i18n.errorMsg}.`,
variant: 'danger', variant: 'danger',
}); });
}) })
...@@ -394,6 +402,8 @@ export default { ...@@ -394,6 +402,8 @@ export default {
<div> <div>
<gl-alert v-if="showFeedbackMsg" :variant="feedback.variant" @dismiss="dismissFeedback"> <gl-alert v-if="showFeedbackMsg" :variant="feedback.variant" @dismiss="dismissFeedback">
{{ feedback.feedbackMessage }} {{ feedback.feedbackMessage }}
<br />
<i v-if="serverError">{{ __('Error message:') }} {{ serverError }}</i>
<gl-button <gl-button
v-if="showAlertSave" v-if="showAlertSave"
variant="danger" variant="danger"
......
...@@ -7,15 +7,10 @@ export const i18n = { ...@@ -7,15 +7,10 @@ export const i18n = {
setupSection: s__( setupSection: s__(
"AlertSettings|Review your external service's documentation to learn where to provide this information to your external service, and the %{linkStart}GitLab documentation%{linkEnd} to learn more about configuring your endpoint.", "AlertSettings|Review your external service's documentation to learn where to provide this information to your external service, and the %{linkStart}GitLab documentation%{linkEnd} to learn more about configuring your endpoint.",
), ),
errorMsg: s__( errorMsg: s__('AlertSettings|There was an error updating the alert settings'),
'AlertSettings|There was an error updating the the alert settings. Please refresh the page to try again.',
),
errorKeyMsg: s__( errorKeyMsg: s__(
'AlertSettings|There was an error while trying to reset the key. Please refresh the page to try again.', 'AlertSettings|There was an error while trying to reset the key. Please refresh the page to try again.',
), ),
errorApiUrlMsg: s__(
'AlertSettings|There was an error while trying to enable the alert settings. Please ensure you are using a valid URL.',
),
restKeyInfo: s__( restKeyInfo: s__(
'AlertSettings|Resetting the authorization key for this project will require updating the authorization key in every alert source it is enabled in.', 'AlertSettings|Resetting the authorization key for this project will require updating the authorization key in every alert source it is enabled in.',
), ),
......
---
title: Alert Opsgenie integration errors
merge_request: 36648
author:
type: other
...@@ -2205,10 +2205,7 @@ msgstr "" ...@@ -2205,10 +2205,7 @@ msgstr ""
msgid "AlertSettings|Test failed. Do you still want to save your changes anyway?" msgid "AlertSettings|Test failed. Do you still want to save your changes anyway?"
msgstr "" msgstr ""
msgid "AlertSettings|There was an error updating the the alert settings. Please refresh the page to try again." msgid "AlertSettings|There was an error updating the alert settings"
msgstr ""
msgid "AlertSettings|There was an error while trying to enable the alert settings. Please ensure you are using a valid URL."
msgstr "" msgstr ""
msgid "AlertSettings|There was an error while trying to reset the key. Please refresh the page to try again." msgid "AlertSettings|There was an error while trying to reset the key. Please refresh the page to try again."
...@@ -9412,6 +9409,9 @@ msgstr "" ...@@ -9412,6 +9409,9 @@ msgstr ""
msgid "Error loading viewer" msgid "Error loading viewer"
msgstr "" msgstr ""
msgid "Error message:"
msgstr ""
msgid "Error occurred when fetching sidebar data" msgid "Error occurred when fetching sidebar data"
msgstr "" msgstr ""
......
...@@ -218,7 +218,9 @@ describe('AlertsSettingsForm', () => { ...@@ -218,7 +218,9 @@ describe('AlertsSettingsForm', () => {
it('should show a error alert if failed', () => { it('should show a error alert if failed', () => {
const formPath = 'some/path'; const formPath = 'some/path';
const toggleService = true; const toggleService = true;
mockAxios.onPut(formPath).replyOnce(404); mockAxios.onPut(formPath).replyOnce(422, {
errors: 'Error message to display',
});
createComponent({ generic: { ...defaultProps.generic, formPath } }); createComponent({ generic: { ...defaultProps.generic, formPath } });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment