Commit 0afb8833 authored by David O'Regan's avatar David O'Regan Committed by Kushal Pandya

Add auto close incidents

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