Commit e16b41d9 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '225254-auto-incident-close' into 'master'

Add auto close incidents

See merge request gitlab-org/gitlab!39967
parents 36376ab2 0afb8833
......@@ -9,6 +9,7 @@ import {
GlNewDropdown,
GlNewDropdownItem,
} from '@gitlab/ui';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import {
I18N_ALERT_SETTINGS_FORM,
NO_ISSUE_TEMPLATE_SELECTED,
......@@ -27,6 +28,7 @@ export default {
GlNewDropdown,
GlNewDropdownItem,
},
mixins: [glFeatureFlagsMixin()],
inject: ['service', 'alertSettings'],
data() {
return {
......@@ -34,6 +36,7 @@ export default {
createIssueEnabled: this.alertSettings.createIssue,
issueTemplate: this.alertSettings.issueTemplateKey,
sendEmailEnabled: this.alertSettings.sendEmail,
autoCloseIncident: this.alertSettings.autoCloseIncident,
loading: false,
};
},
......@@ -49,6 +52,7 @@ export default {
create_issue: this.createIssueEnabled,
issue_template_key: this.issueTemplate,
send_email: this.sendEmailEnabled,
auto_close_incident: this.autoCloseIncident,
};
},
},
......@@ -123,6 +127,11 @@ export default {
<span>{{ $options.i18n.sendEmail.label }}</span>
</gl-form-checkbox>
</gl-form-group>
<gl-form-group v-if="glFeatures.autoCloseIncident" class="gl-pl-0 gl-mb-5">
<gl-form-checkbox v-model="autoCloseIncident">
<span>{{ $options.i18n.autoCloseIncidents.label }}</span>
</gl-form-checkbox>
</gl-form-group>
<div class="gl-display-flex gl-justify-content-end">
<gl-button
ref="submitBtn"
......
......@@ -42,6 +42,9 @@ export const I18N_ALERT_SETTINGS_FORM = {
sendEmail: {
label: __('Send a separate email notification to Developers.'),
},
autoCloseIncidents: {
label: __('Automatically close incident issues when the associated Prometheus alert resolves.'),
},
};
export const NO_ISSUE_TEMPLATE_SELECTED = { key: '', name: __('No template selected') };
......
......@@ -20,6 +20,7 @@ export default () => {
pagerdutyActive,
pagerdutyWebhookUrl,
pagerdutyResetKeyPath,
autoCloseIncident,
},
} = el;
......@@ -33,6 +34,7 @@ export default () => {
createIssue: parseBoolean(createIssue),
issueTemplateKey,
sendEmail: parseBoolean(sendEmail),
autoCloseIncident: parseBoolean(autoCloseIncident),
},
pagerDutySettings: {
active: parseBoolean(pagerdutyActive),
......
......@@ -6,6 +6,10 @@ module Projects
before_action :authorize_admin_operations!
before_action :authorize_read_prometheus_alerts!, only: [:reset_alerting_token]
before_action do
push_frontend_feature_flag(:auto_close_incident)
end
respond_to :json, only: [:reset_alerting_token, :reset_pagerduty_token]
helper_method :error_tracking_setting
......
......@@ -43,6 +43,7 @@ module OperationsHelper
create_issue: setting.create_issue.to_s,
issue_template_key: setting.issue_template_key.to_s,
send_email: setting.send_email.to_s,
auto_close_incident: 'true',
pagerduty_active: setting.pagerduty_active.to_s,
pagerduty_token: setting.pagerduty_token.to_s,
pagerduty_webhook_url: project_incidents_integrations_pagerduty_url(@project, token: setting.pagerduty_token),
......
......@@ -3641,6 +3641,9 @@ msgstr ""
msgid "Automatic certificate management using Let's Encrypt"
msgstr ""
msgid "Automatically close incident issues when the associated Prometheus alert resolves."
msgstr ""
msgid "Automatically create merge requests for vulnerabilities that have fixes available."
msgstr ""
......
......@@ -81,6 +81,18 @@ exports[`Alert integration settings form default state should match the default
</gl-form-checkbox-stub>
</gl-form-group-stub>
<gl-form-group-stub
class="gl-pl-0 gl-mb-5"
>
<gl-form-checkbox-stub
checked="true"
>
<span>
Automatically close incident issues when the associated Prometheus alert resolves.
</span>
</gl-form-checkbox-stub>
</gl-form-group-stub>
<div
class="gl-display-flex gl-justify-content-end"
>
......
......@@ -10,12 +10,14 @@ describe('Alert integration settings form', () => {
beforeEach(() => {
wrapper = shallowMount(AlertsSettingsForm, {
provide: {
glFeatures: { autoCloseIncident: true },
service,
alertSettings: {
issueTemplateKey: 'selecte_tmpl',
createIssue: true,
sendEmail: false,
templates: [],
autoCloseIncident: true,
},
},
});
......@@ -42,6 +44,7 @@ describe('Alert integration settings form', () => {
create_issue: wrapper.vm.createIssueEnabled,
issue_template_key: wrapper.vm.issueTemplate,
send_email: wrapper.vm.sendEmailEnabled,
auto_close_incident: wrapper.vm.autoCloseIncident,
}),
);
});
......
......@@ -150,6 +150,7 @@ RSpec.describe OperationsHelper do
create_issue: 'false',
issue_template_key: 'template-key',
send_email: 'false',
auto_close_incident: 'true',
pagerduty_active: 'true',
pagerduty_token: operations_settings.pagerduty_token,
pagerduty_webhook_url: project_incidents_integrations_pagerduty_url(project, token: operations_settings.pagerduty_token),
......
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