Commit 0b26bfef authored by Simon Knox's avatar Simon Knox Committed by Mike Greiling

Add incident_management license

- Add a license check for incident management.
- Also refactor specs a bit.
parent 3a6d7c92
...@@ -23,7 +23,10 @@ ...@@ -23,7 +23,10 @@
} }
.settings { .settings {
border-bottom: 1px solid $gray-darker; // border-top for each item except the top one
+ .settings {
border-top: 1px solid $border-color;
}
&:first-of-type { &:first-of-type {
margin-top: 10px; margin-top: 10px;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
- setting = error_tracking_setting - setting = error_tracking_setting
%section.settings.expanded.border-0.no-animate %section.settings.expanded.no-animate
.settings-header .settings-header
%h4 %h4
= _('Error Tracking') = _('Error Tracking')
......
...@@ -2,5 +2,6 @@ ...@@ -2,5 +2,6 @@
- page_title _('Operations Settings') - page_title _('Operations Settings')
- breadcrumb_title _('Operations Settings') - breadcrumb_title _('Operations Settings')
= render_if_exists 'projects/settings/operations/incidents'
= render 'projects/settings/operations/error_tracking', expanded: true = render 'projects/settings/operations/error_tracking', expanded: true
= render_if_exists 'projects/settings/operations/tracing' = render_if_exists 'projects/settings/operations/tracing'
...@@ -6,6 +6,10 @@ module IncidentManagement ...@@ -6,6 +6,10 @@ module IncidentManagement
validate :issue_template_exists, if: :create_issue? validate :issue_template_exists, if: :create_issue?
def available_issue_templates
Gitlab::Template::IssueTemplate.all(project)
end
private private
def issue_template_exists def issue_template_exists
......
- return unless incident_management_available?
- templates = []
- setting = project_incident_management_setting
- templates = setting.available_issue_templates.map { |t| [t.name, t.key] }
%section.settings.expanded.no-animate
.settings-header
%h4= _('Incidents')
%p
= _('Action to take when receiving an alert.')
= link_to help_page_path('user/project/integrations/prometheus', anchor: 'taking-action-on-an-alert-ultimate') do
= _('More information')
.settings-content
= form_for @project, url: project_settings_operations_path(@project), method: :patch do |f|
= form_errors(@project.incident_management_setting)
.form-group
= f.fields_for :incident_management_setting_attributes, setting do |form|
.form-group
= form.check_box :create_issue
= form.label :create_issue, _('Create an issue. Issues are created for each alert triggered.'), class: 'form-check-label'
.form-group.col-sm-8
= form.label :issue_template_key, class: 'label-bold' do
= _('Issue template (optional)')
= link_to icon('question-circle'), help_page_path('user/project/description_templates', anchor: 'creating-issue-templates'), target: '_blank', rel: 'noopener noreferrer'
.select-wrapper
= form.select :issue_template_key, templates, {include_blank: 'No template selected'}, class: "form-control select-control"
= icon('chevron-down')
.form-group
= form.check_box :send_email
= form.label :send_email, _('Send an email notification to Developers.'), class: 'form-check-label'
= f.submit _('Save changes'), class: 'btn btn-success'
# frozen_string_literal: true
require 'spec_helper'
describe 'Projects > Settings' do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, create_templates: :issue) }
let(:role) { :maintainer }
let(:create_issue) { 'Create an issue. Issues are created for each alert triggered.' }
let(:send_email) { 'Send an email notification to Developers.' }
before do
create(:project_incident_management_setting, send_email: true, project: project)
sign_in(user)
project.add_role(user, role)
end
describe 'Incidents' do
context 'with license' do
before do
stub_licensed_features(incident_management: true)
visit project_settings_operations_path(project)
end
it 'renders form for incident management' do
expect(page).to have_selector('h4', text: 'Incidents')
end
it 'sets correct default values' do
expect(find_field(create_issue)).not_to be_checked
expect(find_field(send_email)).to be_checked
end
it 'updates form values' do
check(create_issue)
template_select = find_field('Issue template')
template_select.find(:xpath, 'option[2]').select_option
uncheck(send_email)
save_form
expect(find_field(create_issue)).to be_checked
expect(page).to have_select('Issue template', selected: 'bug')
expect(find_field(send_email)).not_to be_checked
end
def save_form
page.within "#edit_project_#{project.id}" do
click_on 'Save changes'
end
end
end
context 'without license' do
before do
stub_licensed_features(incident_management: false)
visit project_settings_operations_path(project)
end
it 'renders form for incident management' do
expect(page).not_to have_selector('h4', text: 'Incidents')
end
end
end
end
...@@ -11,7 +11,7 @@ describe 'projects/settings/operations/show' do ...@@ -11,7 +11,7 @@ describe 'projects/settings/operations/show' do
assign(:repository, project.repository) assign(:repository, project.repository)
allow(view).to receive(:current_ref).and_return('master') allow(view).to receive(:current_ref).and_return('master')
allow(view).to receive(:error_tracking_setting).and_return(error_tracking_setting) allow(view).to receive(:error_tracking_setting).and_return(error_tracking_setting)
allow(view).to receive(:incident_management_available?) { false }
stub_licensed_features(tracing: true) stub_licensed_features(tracing: true)
end end
......
...@@ -473,6 +473,9 @@ msgstr "" ...@@ -473,6 +473,9 @@ msgstr ""
msgid "Account and limit" msgid "Account and limit"
msgstr "" msgstr ""
msgid "Action to take when receiving an alert."
msgstr ""
msgid "Active" msgid "Active"
msgstr "" msgstr ""
...@@ -2966,6 +2969,9 @@ msgstr "" ...@@ -2966,6 +2969,9 @@ msgstr ""
msgid "Create a personal access token on your account to pull or push via %{protocol}." msgid "Create a personal access token on your account to pull or push via %{protocol}."
msgstr "" msgstr ""
msgid "Create an issue. Issues are created for each alert triggered."
msgstr ""
msgid "Create branch" msgid "Create branch"
msgstr "" msgstr ""
...@@ -5486,6 +5492,9 @@ msgstr "" ...@@ -5486,6 +5492,9 @@ msgstr ""
msgid "In the next step, you'll be able to select the projects you want to import." msgid "In the next step, you'll be able to select the projects you want to import."
msgstr "" msgstr ""
msgid "Incidents"
msgstr ""
msgid "Include a Terms of Service agreement and Privacy Policy that all users must accept." msgid "Include a Terms of Service agreement and Privacy Policy that all users must accept."
msgstr "" msgstr ""
...@@ -5620,6 +5629,9 @@ msgstr "" ...@@ -5620,6 +5629,9 @@ msgstr ""
msgid "Issue settings" msgid "Issue settings"
msgstr "" msgstr ""
msgid "Issue template (optional)"
msgstr ""
msgid "IssueBoards|Board" msgid "IssueBoards|Board"
msgstr "" msgstr ""
...@@ -8906,6 +8918,9 @@ msgstr "" ...@@ -8906,6 +8918,9 @@ msgstr ""
msgid "Selecting a GitLab user will add a link to the GitLab user in the descriptions of issues and comments (e.g. \"By <a href=\"#\">@johnsmith</a>\"). It will also associate and/or assign these issues and comments with the selected user." msgid "Selecting a GitLab user will add a link to the GitLab user in the descriptions of issues and comments (e.g. \"By <a href=\"#\">@johnsmith</a>\"). It will also associate and/or assign these issues and comments with the selected user."
msgstr "" msgstr ""
msgid "Send an email notification to Developers."
msgstr ""
msgid "Send email" msgid "Send email"
msgstr "" msgstr ""
......
...@@ -18,6 +18,7 @@ describe 'projects/settings/operations/show' do ...@@ -18,6 +18,7 @@ describe 'projects/settings/operations/show' do
allow(view).to receive(:error_tracking_setting) allow(view).to receive(:error_tracking_setting)
.and_return(error_tracking_setting) .and_return(error_tracking_setting)
allow(view).to receive(:current_user).and_return(user) allow(view).to receive(:current_user).and_return(user)
allow(view).to receive(:incident_management_available?) { false }
end end
let!(:error_tracking_setting) do let!(:error_tracking_setting) do
......
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