Commit b9041ef0 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch '330282-slash-command-for-escalation' into 'master'

Add slash command to page incident

See merge request gitlab-org/gitlab!79977
parents 8229c22a f0a8c6f5
...@@ -82,6 +82,7 @@ threads. Some quick actions might not be available to all subscription tiers. ...@@ -82,6 +82,7 @@ threads. Some quick actions might not be available to all subscription tiers.
| `/parent_epic <epic>` | **{dotted-circle}** No | **{dotted-circle}** No | **{check-circle}** Yes | Set parent epic to `<epic>`. The `<epic>` value should be in the format of `&epic`, `group&epic`, or a URL to an epic ([introduced in GitLab 12.1](https://gitlab.com/gitlab-org/gitlab/-/issues/10556)). | | `/parent_epic <epic>` | **{dotted-circle}** No | **{dotted-circle}** No | **{check-circle}** Yes | Set parent epic to `<epic>`. The `<epic>` value should be in the format of `&epic`, `group&epic`, or a URL to an epic ([introduced in GitLab 12.1](https://gitlab.com/gitlab-org/gitlab/-/issues/10556)). |
| `/promote` | **{check-circle}** Yes | **{dotted-circle}** No | **{dotted-circle}** No | Promote issue to epic. | | `/promote` | **{check-circle}** Yes | **{dotted-circle}** No | **{dotted-circle}** No | Promote issue to epic. |
| `/promote_to_incident` | **{check-circle}** Yes | **{dotted-circle}** No | **{dotted-circle}** No | Promote issue to incident ([introduced in GitLab 14.5](https://gitlab.com/gitlab-org/gitlab/-/issues/296787)). | | `/promote_to_incident` | **{check-circle}** Yes | **{dotted-circle}** No | **{dotted-circle}** No | Promote issue to incident ([introduced in GitLab 14.5](https://gitlab.com/gitlab-org/gitlab/-/issues/296787)). |
| `/page <policy name>` | **{check-circle}** Yes | **{dotted-circle}** No | **{dotted-circle}** No | Start escalations for the incident ([introduced in GitLab 14.9](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/79977)).
| `/publish` | **{check-circle}** Yes | **{dotted-circle}** No | **{dotted-circle}** No | Publish issue to an associated [Status Page](../../operations/incident_management/status_page.md) ([Introduced in GitLab 13.0](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/30906)) | | `/publish` | **{check-circle}** Yes | **{dotted-circle}** No | **{dotted-circle}** No | Publish issue to an associated [Status Page](../../operations/incident_management/status_page.md) ([Introduced in GitLab 13.0](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/30906)) |
| `/reassign @user1 @user2` | **{check-circle}** Yes | **{check-circle}** Yes | **{dotted-circle}** No | Replace current assignees with those specified. | | `/reassign @user1 @user2` | **{check-circle}** Yes | **{check-circle}** Yes | **{dotted-circle}** No | Replace current assignees with those specified. |
| `/reassign_reviewer @user1 @user2` | **{dotted-circle}** No | **{check-circle}** Yes | **{dotted-circle}** No | Replace current reviewers with those specified. | | `/reassign_reviewer @user1 @user2` | **{dotted-circle}** No | **{check-circle}** Yes | **{dotted-circle}** No | Replace current reviewers with those specified. |
......
---
key_path: redis_hll_counters.quickactions.i_quickactions_page_monthly
name: count_i_quickactions_page_monthly
description: Count of MAU using the `/page <escalation_policy>` quick action
product_section: ops
product_stage: monitor
product_group: group::respond
product_category: incident_management
value_type: number
status: active
milestone: "14.9"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/79977
time_frame: 28d
data_source: redis_hll
data_category: optional
instrumentation_class: RedisHLLMetric
options:
events:
- i_quickactions_page
performance_indicator_type: []
distribution:
- ee
tier:
- premium
- ultimate
---
key_path: redis_hll_counters.quickactions.i_quickactions_page_weekly
name: count_i_quickactions_page_weekly
description: Count of WAU using the `/page <escalation_policy>` quick action
product_section: ops
product_stage: monitor
product_group: group::respond
product_category: incident_management
value_type: number
status: active
milestone: "14.9"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/79977
time_frame: 7d
data_source: redis_hll
data_category: optional
instrumentation_class: RedisHLLMetric
options:
events:
- i_quickactions_page
performance_indicator_type: []
distribution:
- ee
tier:
- premium
- ultimate
...@@ -171,6 +171,38 @@ module EE ...@@ -171,6 +171,38 @@ module EE
command :clear_health_status do command :clear_health_status do
@updates[:health_status] = nil @updates[:health_status] = nil
end end
desc _('Escalate this incident')
explanation _('Starts escalations for this incident')
params '<policy name>'
types Issue
condition do
current_user.can?(:update_escalation_status, quick_action_target) &&
quick_action_target.persisted? &&
quick_action_target.supports_escalation?
end
command :page do |escalation_policy_name|
policy = quick_action_target.project.incident_management_escalation_policies.find_by_name(escalation_policy_name)
if policy.nil?
@execution_message[:page] = _("Policy '%{escalation_policy_name}' does not exist.") % { escalation_policy_name: escalation_policy_name }
else
issue = ::Issues::UpdateService
.new(project: quick_action_target.project,
current_user: current_user,
params: {
escalation_status: { status: :triggered, policy: policy }
}
).execute(quick_action_target)
@execution_message[:page] =
if issue.escalation_status.saved_change_to_updated_at?
_('Started escalation for this incident.')
else
_("This incident is already escalated with '%{escalation_policy_name}'.") % { escalation_policy_name: escalation_policy_name }
end
end
end
end end
private private
......
...@@ -23,5 +23,6 @@ RSpec.describe 'Issues > User uses EE quick actions', :js do ...@@ -23,5 +23,6 @@ RSpec.describe 'Issues > User uses EE quick actions', :js do
end end
it_behaves_like 'status page quick actions' it_behaves_like 'status page quick actions'
it_behaves_like 'page quick action'
end end
end end
# frozen_string_literal: true
# This shared_example requires the following variables:
# - project (required)
# - issue (required)
# - user (required) - developer role by default
RSpec.shared_examples 'page quick action' do
describe '/page' do
let_it_be(:escalation_policy) { create(:incident_management_escalation_policy, project: project, name: 'spec policy') }
let_it_be(:incident, reload: true) { create(:incident, project: project) }
let_it_be(:escalation_status, reload: true) { create(:incident_management_issuable_escalation_status, issue: incident) }
context 'when feature flags and licenses are disabled' do
before do
stub_feature_flags(incident_escalations: false)
stub_licensed_features(oncall_schedules: false, escalation_policies: false)
visit project_issue_path(project, incident)
wait_for_all_requests
end
it 'does not escalate issue' do
add_note('/page spec policy')
expect(page).to have_content('Could not apply page command')
end
end
context 'when feature flags and licenses are enabled' do
before do
stub_feature_flags(incident_escalations: true)
stub_licensed_features(oncall_schedules: true, escalation_policies: true)
end
context 'when issue is an incident' do
before do
visit project_issue_path(project, incident)
wait_for_all_requests
end
it 'starts escalation with the policy' do
add_note('/page spec policy')
expect(page).to have_content('Started escalation for this incident.')
expect(incident.reload.escalation_status.policy).to eq(escalation_policy)
end
it 'does not escalate when policy does not exist' do
add_note('/page wrong policy')
expect(page).to have_content("Policy 'wrong policy' does not exist.")
expect(incident.reload.escalation_status.policy).to be_nil
end
context 'when issue is already escalated' do
before do
# Escalate a policy before paging again
add_note('/page spec policy')
end
it 'does not escalate again with same policy' do
add_note('/page spec policy')
expect(page).to have_content("This incident is already escalated with 'spec policy'.")
end
end
context 'when user does not have permissions' do
before do
project.add_reporter(user)
visit project_issue_path(project, incident)
wait_for_all_requests
end
it 'does not escalate incident' do
add_note('/page spec policy')
expect(page).to have_content('Could not apply page command')
end
end
end
context 'when issue is not an incident' do
it 'does not escalate issue' do
add_note('/page spec policy')
expect(page).to have_content('Could not apply page command')
end
end
end
end
end
...@@ -127,6 +127,10 @@ ...@@ -127,6 +127,10 @@
category: quickactions category: quickactions
redis_slot: quickactions redis_slot: quickactions
aggregation: weekly aggregation: weekly
- name: i_quickactions_page
category: quickactions
redis_slot: quickactions
aggregation: weekly
- name: i_quickactions_publish - name: i_quickactions_publish
category: quickactions category: quickactions
redis_slot: quickactions redis_slot: quickactions
......
...@@ -14434,6 +14434,9 @@ msgstr "" ...@@ -14434,6 +14434,9 @@ msgstr ""
msgid "Errors:" msgid "Errors:"
msgstr "" msgstr ""
msgid "Escalate this incident"
msgstr ""
msgid "Escalation Policies" msgid "Escalation Policies"
msgstr "" msgstr ""
...@@ -27481,6 +27484,9 @@ msgstr "" ...@@ -27481,6 +27484,9 @@ msgstr ""
msgid "Policies" msgid "Policies"
msgstr "" msgstr ""
msgid "Policy '%{escalation_policy_name}' does not exist."
msgstr ""
msgid "Policy management project does have any policies in %{policy_path}" msgid "Policy management project does have any policies in %{policy_path}"
msgstr "" msgstr ""
...@@ -34806,6 +34812,9 @@ msgstr "" ...@@ -34806,6 +34812,9 @@ msgstr ""
msgid "Started asynchronous removal of all repository check states." msgid "Started asynchronous removal of all repository check states."
msgstr "" msgstr ""
msgid "Started escalation for this incident."
msgstr ""
msgid "Starting..." msgid "Starting..."
msgstr "" msgstr ""
...@@ -34818,6 +34827,9 @@ msgstr "" ...@@ -34818,6 +34827,9 @@ msgstr ""
msgid "Starts at (UTC)" msgid "Starts at (UTC)"
msgstr "" msgstr ""
msgid "Starts escalations for this incident"
msgstr ""
msgid "Starts on" msgid "Starts on"
msgstr "" msgstr ""
...@@ -37375,6 +37387,9 @@ msgstr "" ...@@ -37375,6 +37387,9 @@ msgstr ""
msgid "This group, its subgroups and projects will be removed on %{date} since its parent group '%{parent_group_name}' has been scheduled for removal." msgid "This group, its subgroups and projects will be removed on %{date} since its parent group '%{parent_group_name}' has been scheduled for removal."
msgstr "" msgstr ""
msgid "This incident is already escalated with '%{escalation_policy_name}'."
msgstr ""
msgid "This invitation was sent to %{mail_to_invite_email}, but you are signed in as %{link_to_current_user} with email %{mail_to_current_user}." msgid "This invitation was sent to %{mail_to_invite_email}, but you are signed in as %{link_to_current_user} with email %{mail_to_current_user}."
msgstr "" msgstr ""
......
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