Commit 6987fd4f authored by Pavel Shutsin's avatar Pavel Shutsin

Merge branch '296787-slash-command-to-promote-issue-to-incident' into 'master'

Add slash command to promote issue to incident

See merge request gitlab-org/gitlab!73992
parents 7d6a17dd 9a27a599
---
key_path: redis_hll_counters.quickactions.i_quickactions_promote_to_incident_monthly
description: Count of MAU using the `/promote_to_incident` quick action
product_section: ops
product_stage: monitor
product_group: group::monitor
product_category: incident_management
value_type: number
status: active
milestone: "14.5"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/73992
time_frame: 28d
data_source: redis_hll
instrumentation_class: RedisHLLMetric
options:
events:
- i_quickactions_promote_to_incident
data_category: optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
---
key_path: redis_hll_counters.quickactions.i_quickactions_promote_to_incident_weekly
description: Count of WAU using the `/severity` quick action
product_section: ops
product_stage: monitor
product_group: group::monitor
product_category: incident_management
value_type: number
status: active
milestone: "14.5"
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/73992
time_frame: 7d
data_source: redis_hll
instrumentation_class: RedisHLLMetric
options:
events:
- i_quickactions_promote_to_incident
data_category: optional
distribution:
- ce
- ee
tier:
- free
- premium
- ultimate
...@@ -78,6 +78,7 @@ threads. Some quick actions might not be available to all subscription tiers. ...@@ -78,6 +78,7 @@ threads. Some quick actions might not be available to all subscription tiers.
| `/move <path/to/project>` | **{check-circle}** Yes | **{dotted-circle}** No | **{dotted-circle}** No | Move this issue to another project. | | `/move <path/to/project>` | **{check-circle}** Yes | **{dotted-circle}** No | **{dotted-circle}** No | Move this issue to another project. |
| `/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)). |
| `/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. |
| `/rebase` | **{dotted-circle}** No | **{check-circle}** Yes | **{dotted-circle}** No | Rebase source branch. This schedules a background task that attempts to rebase the changes in the source branch on the latest commit of the target branch. If `/rebase` is used, `/merge` is ignored to avoid a race condition where the source branch is merged or deleted before it is rebased. If there are merge conflicts, GitLab displays a message that a rebase cannot be scheduled. Rebase failures are displayed with the merge request status. | | `/rebase` | **{dotted-circle}** No | **{check-circle}** Yes | **{dotted-circle}** No | Rebase source branch. This schedules a background task that attempts to rebase the changes in the source branch on the latest commit of the target branch. If `/rebase` is used, `/merge` is ignored to avoid a race condition where the source branch is merged or deleted before it is rebased. If there are merge conflicts, GitLab displays a message that a rebase cannot be scheduled. Rebase failures are displayed with the merge request status. |
......
...@@ -264,6 +264,27 @@ module Gitlab ...@@ -264,6 +264,27 @@ module Gitlab
end end
end end
desc _('Promote issue to incident')
explanation _('Promotes issue to incident')
types Issue
condition do
quick_action_target.persisted? &&
!quick_action_target.incident? &&
current_user.can?(:update_issue, quick_action_target)
end
command :promote_to_incident do
issue = ::Issues::UpdateService
.new(project: quick_action_target.project, current_user: current_user, params: { issue_type: 'incident' })
.execute(quick_action_target)
@execution_message[:promote_to_incident] =
if issue.incident?
_('Issue has been promoted to incident')
else
_('Failed to promote issue to incident')
end
end
private private
def zoom_link_service def zoom_link_service
......
...@@ -119,6 +119,10 @@ ...@@ -119,6 +119,10 @@
category: quickactions category: quickactions
redis_slot: quickactions redis_slot: quickactions
aggregation: weekly aggregation: weekly
- name: i_quickactions_promote_to_incident
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
......
...@@ -14358,6 +14358,9 @@ msgstr "" ...@@ -14358,6 +14358,9 @@ msgstr ""
msgid "Failed to move this issue because target project doesn't exist." msgid "Failed to move this issue because target project doesn't exist."
msgstr "" msgstr ""
msgid "Failed to promote issue to incident"
msgstr ""
msgid "Failed to promote label due to internal error. Please contact administrators." msgid "Failed to promote label due to internal error. Please contact administrators."
msgstr "" msgstr ""
...@@ -19219,6 +19222,9 @@ msgstr "" ...@@ -19219,6 +19222,9 @@ msgstr ""
msgid "Issue first deployed to production" msgid "Issue first deployed to production"
msgstr "" msgstr ""
msgid "Issue has been promoted to incident"
msgstr ""
msgid "Issue label" msgid "Issue label"
msgstr "" msgstr ""
...@@ -27768,6 +27774,9 @@ msgstr "" ...@@ -27768,6 +27774,9 @@ msgstr ""
msgid "Promote issue to an epic" msgid "Promote issue to an epic"
msgstr "" msgstr ""
msgid "Promote issue to incident"
msgstr ""
msgid "Promote to epic" msgid "Promote to epic"
msgstr "" msgstr ""
...@@ -27786,6 +27795,9 @@ msgstr "" ...@@ -27786,6 +27795,9 @@ msgstr ""
msgid "Promoted issue to an epic." msgid "Promoted issue to an epic."
msgstr "" msgstr ""
msgid "Promotes issue to incident"
msgstr ""
msgid "Promotion is not supported." msgid "Promotion is not supported."
msgstr "" msgstr ""
......
...@@ -44,5 +44,6 @@ RSpec.describe 'Issues > User uses quick actions', :js do ...@@ -44,5 +44,6 @@ RSpec.describe 'Issues > User uses quick actions', :js do
it_behaves_like 'move quick action' it_behaves_like 'move quick action'
it_behaves_like 'zoom quick actions' it_behaves_like 'zoom quick actions'
it_behaves_like 'clone quick action' it_behaves_like 'clone quick action'
it_behaves_like 'promote_to_incident quick action'
end end
end end
# frozen_string_literal: true
RSpec.shared_examples 'promote_to_incident quick action' do
describe '/promote_to_incident' do
context 'when issue can be promoted' do
it 'promotes issue to incident' do
add_note('/promote_to_incident')
expect(issue.reload.issue_type).to eq('incident')
expect(page).to have_content('Issue has been promoted to incident')
end
end
context 'when issue is already an incident' do
let(:issue) { create(:incident, project: project) }
it 'does not promote the issue' do
add_note('/promote_to_incident')
expect(page).to have_content('Could not apply promote_to_incident command')
end
end
context 'when user does not have permissions' do
let(:guest) { create(:user) }
before do
sign_in(guest)
visit project_issue_path(project, issue)
wait_for_all_requests
end
it 'does not promote the issue' do
add_note('/promote_to_incident')
expect(page).to have_content('Could not apply promote_to_incident command')
end
end
end
end
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