2020-07-28 23:09:34 +05:30
|
|
|
<script>
|
|
|
|
import {
|
|
|
|
GlButton,
|
|
|
|
GlSprintf,
|
|
|
|
GlLink,
|
|
|
|
GlFormGroup,
|
|
|
|
GlFormCheckbox,
|
2020-11-24 15:15:51 +05:30
|
|
|
GlDropdown,
|
|
|
|
GlDropdownItem,
|
2020-07-28 23:09:34 +05:30
|
|
|
} from '@gitlab/ui';
|
|
|
|
import {
|
|
|
|
I18N_ALERT_SETTINGS_FORM,
|
|
|
|
NO_ISSUE_TEMPLATE_SELECTED,
|
|
|
|
TAKING_INCIDENT_ACTION_DOCS_LINK,
|
|
|
|
ISSUE_TEMPLATES_DOCS_LINK,
|
|
|
|
} from '../constants';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
GlButton,
|
|
|
|
GlSprintf,
|
|
|
|
GlLink,
|
|
|
|
GlFormGroup,
|
|
|
|
GlFormCheckbox,
|
2020-11-24 15:15:51 +05:30
|
|
|
GlDropdown,
|
|
|
|
GlDropdownItem,
|
2020-07-28 23:09:34 +05:30
|
|
|
},
|
|
|
|
inject: ['service', 'alertSettings'],
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
templates: [NO_ISSUE_TEMPLATE_SELECTED, ...this.alertSettings.templates],
|
|
|
|
createIssueEnabled: this.alertSettings.createIssue,
|
|
|
|
issueTemplate: this.alertSettings.issueTemplateKey,
|
|
|
|
sendEmailEnabled: this.alertSettings.sendEmail,
|
2020-11-24 15:15:51 +05:30
|
|
|
autoCloseIncident: this.alertSettings.autoCloseIncident,
|
2020-07-28 23:09:34 +05:30
|
|
|
loading: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
i18n: I18N_ALERT_SETTINGS_FORM,
|
|
|
|
TAKING_INCIDENT_ACTION_DOCS_LINK,
|
|
|
|
ISSUE_TEMPLATES_DOCS_LINK,
|
|
|
|
computed: {
|
|
|
|
issueTemplateHeader() {
|
|
|
|
return this.issueTemplate || NO_ISSUE_TEMPLATE_SELECTED.name;
|
|
|
|
},
|
|
|
|
formData() {
|
|
|
|
return {
|
|
|
|
create_issue: this.createIssueEnabled,
|
|
|
|
issue_template_key: this.issueTemplate,
|
|
|
|
send_email: this.sendEmailEnabled,
|
2020-11-24 15:15:51 +05:30
|
|
|
auto_close_incident: this.autoCloseIncident,
|
2020-07-28 23:09:34 +05:30
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
selectIssueTemplate(templateKey) {
|
|
|
|
this.issueTemplate = templateKey;
|
|
|
|
},
|
|
|
|
isTemplateSelected(templateKey) {
|
|
|
|
return templateKey === this.issueTemplate;
|
|
|
|
},
|
|
|
|
updateAlertsIntegrationSettings() {
|
|
|
|
this.loading = true;
|
|
|
|
|
|
|
|
this.service.updateSettings(this.formData).catch(() => {
|
|
|
|
this.loading = false;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<p>
|
|
|
|
<gl-sprintf :message="$options.i18n.introText">
|
|
|
|
<template #docsLink>
|
|
|
|
<gl-link :href="$options.TAKING_INCIDENT_ACTION_DOCS_LINK" target="_blank">
|
|
|
|
<span>{{ $options.i18n.introLinkText }}</span>
|
|
|
|
</gl-link>
|
|
|
|
</template>
|
|
|
|
</gl-sprintf>
|
|
|
|
</p>
|
|
|
|
<form ref="settingsForm" @submit.prevent="updateAlertsIntegrationSettings">
|
|
|
|
<gl-form-group class="gl-pl-0">
|
|
|
|
<gl-form-checkbox v-model="createIssueEnabled" data-qa-selector="create_issue_checkbox">
|
2021-02-22 17:27:13 +05:30
|
|
|
<span>{{ $options.i18n.createIncident.label }}</span>
|
2020-07-28 23:09:34 +05:30
|
|
|
</gl-form-checkbox>
|
|
|
|
</gl-form-group>
|
|
|
|
|
|
|
|
<gl-form-group
|
|
|
|
label-size="sm"
|
|
|
|
label-for="alert-integration-settings-issue-template"
|
|
|
|
class="col-8 col-md-9 gl-px-6"
|
|
|
|
>
|
|
|
|
<label class="gl-display-inline-flex" for="alert-integration-settings-issue-template">
|
2021-02-22 17:27:13 +05:30
|
|
|
{{ $options.i18n.incidentTemplate.label }}
|
2020-07-28 23:09:34 +05:30
|
|
|
<gl-link :href="$options.ISSUE_TEMPLATES_DOCS_LINK" target="_blank">
|
2021-09-04 01:27:46 +05:30
|
|
|
<span class="gl-font-weight-normal gl-pl-2">{{ $options.i18n.introLinkText }}</span>
|
2020-07-28 23:09:34 +05:30
|
|
|
</gl-link>
|
|
|
|
</label>
|
2020-11-24 15:15:51 +05:30
|
|
|
<gl-dropdown
|
2020-07-28 23:09:34 +05:30
|
|
|
id="alert-integration-settings-issue-template"
|
|
|
|
data-qa-selector="incident_templates_dropdown"
|
|
|
|
:text="issueTemplateHeader"
|
|
|
|
:block="true"
|
|
|
|
>
|
2020-11-24 15:15:51 +05:30
|
|
|
<gl-dropdown-item
|
2020-07-28 23:09:34 +05:30
|
|
|
v-for="template in templates"
|
|
|
|
:key="template.key"
|
|
|
|
data-qa-selector="incident_templates_item"
|
|
|
|
:is-check-item="true"
|
|
|
|
:is-checked="isTemplateSelected(template.key)"
|
|
|
|
@click="selectIssueTemplate(template.key)"
|
|
|
|
>
|
|
|
|
{{ template.name }}
|
2020-11-24 15:15:51 +05:30
|
|
|
</gl-dropdown-item>
|
|
|
|
</gl-dropdown>
|
2020-07-28 23:09:34 +05:30
|
|
|
</gl-form-group>
|
|
|
|
|
|
|
|
<gl-form-group class="gl-pl-0 gl-mb-5">
|
|
|
|
<gl-form-checkbox v-model="sendEmailEnabled">
|
|
|
|
<span>{{ $options.i18n.sendEmail.label }}</span>
|
|
|
|
</gl-form-checkbox>
|
|
|
|
</gl-form-group>
|
2020-11-24 15:15:51 +05:30
|
|
|
<gl-form-group 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>
|
2021-01-03 14:25:43 +05:30
|
|
|
<gl-button
|
|
|
|
ref="submitBtn"
|
|
|
|
data-qa-selector="save_changes_button"
|
|
|
|
:disabled="loading"
|
2021-09-04 01:27:46 +05:30
|
|
|
variant="confirm"
|
2021-01-03 14:25:43 +05:30
|
|
|
type="submit"
|
|
|
|
class="js-no-auto-disable"
|
|
|
|
>
|
|
|
|
{{ $options.i18n.saveBtnLabel }}
|
|
|
|
</gl-button>
|
2020-07-28 23:09:34 +05:30
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</template>
|