diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 16:16:36 +0300 |
commit | 311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch) | |
tree | 07e7870bca8aed6d61fdcc810731c50d2c40af47 /lib/gitlab/quick_actions | |
parent | 27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff) |
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'lib/gitlab/quick_actions')
-rw-r--r-- | lib/gitlab/quick_actions/issuable_actions.rb | 7 | ||||
-rw-r--r-- | lib/gitlab/quick_actions/issue_actions.rb | 31 | ||||
-rw-r--r-- | lib/gitlab/quick_actions/issue_and_merge_request_actions.rb | 14 |
3 files changed, 36 insertions, 16 deletions
diff --git a/lib/gitlab/quick_actions/issuable_actions.rb b/lib/gitlab/quick_actions/issuable_actions.rb index cf5c9296d8c..4bac0643a91 100644 --- a/lib/gitlab/quick_actions/issuable_actions.rb +++ b/lib/gitlab/quick_actions/issuable_actions.rb @@ -84,8 +84,7 @@ module Gitlab params '~label1 ~"label 2"' types Issuable condition do - parent && - current_user.can?(:"admin_#{quick_action_target.to_ability_name}", parent) && + current_user.can?(:"set_#{quick_action_target.to_ability_name}_metadata", quick_action_target) && find_labels.any? end command :label do |labels_param| @@ -107,7 +106,7 @@ module Gitlab condition do quick_action_target.persisted? && quick_action_target.labels.any? && - current_user.can?(:"admin_#{quick_action_target.to_ability_name}", parent) + current_user.can?(:"set_#{quick_action_target.to_ability_name}_metadata", quick_action_target) end command :unlabel, :remove_label do |labels_param = nil| if labels_param.present? @@ -139,7 +138,7 @@ module Gitlab condition do quick_action_target.persisted? && quick_action_target.labels.any? && - current_user.can?(:"admin_#{quick_action_target.to_ability_name}", parent) + current_user.can?(:"set_#{quick_action_target.to_ability_name}_metadata", quick_action_target) end command :relabel do |labels_param| run_label_command(labels: find_labels(labels_param), command: :relabel, updates_key: :label_ids) diff --git a/lib/gitlab/quick_actions/issue_actions.rb b/lib/gitlab/quick_actions/issue_actions.rb index c5cf3262039..a55ead519e2 100644 --- a/lib/gitlab/quick_actions/issue_actions.rb +++ b/lib/gitlab/quick_actions/issue_actions.rb @@ -19,7 +19,7 @@ module Gitlab types Issue condition do quick_action_target.respond_to?(:due_date) && - current_user.can?(:"admin_#{quick_action_target.to_ability_name}", project) + current_user.can?(:"set_#{quick_action_target.to_ability_name}_metadata", quick_action_target) end parse_params do |due_date_param| Chronic.parse(due_date_param).try(:to_date) @@ -40,7 +40,7 @@ module Gitlab quick_action_target.persisted? && quick_action_target.respond_to?(:due_date) && quick_action_target.due_date? && - current_user.can?(:"admin_#{quick_action_target.to_ability_name}", project) + current_user.can?(:"set_#{quick_action_target.to_ability_name}_metadata", quick_action_target) end command :remove_due_date do @updates[:due_date] = nil @@ -54,7 +54,7 @@ module Gitlab params '~"Target column"' types Issue condition do - current_user.can?(:"update_#{quick_action_target.to_ability_name}", quick_action_target) && + current_user.can?(:"set_#{quick_action_target.to_ability_name}_metadata", quick_action_target) && quick_action_target.project.boards.count == 1 end command :board_move do |target_list_name| @@ -86,7 +86,7 @@ module Gitlab types Issue condition do quick_action_target.persisted? && - current_user.can?(:"update_#{quick_action_target.to_ability_name}", quick_action_target) + current_user.can?(:"set_#{quick_action_target.to_ability_name}_metadata", quick_action_target) end command :duplicate do |duplicate_param| canonical_issue = extract_references(duplicate_param, :issue).first @@ -172,7 +172,7 @@ module Gitlab condition do quick_action_target.issue_type_supports?(:confidentiality) && !quick_action_target.confidential? && - current_user.can?(:"admin_#{quick_action_target.to_ability_name}", quick_action_target) + current_user.can?(:set_confidentiality, quick_action_target) end command :confidential do @updates[:confidential] = true @@ -264,6 +264,27 @@ module Gitlab 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 def zoom_link_service diff --git a/lib/gitlab/quick_actions/issue_and_merge_request_actions.rb b/lib/gitlab/quick_actions/issue_and_merge_request_actions.rb index b53fdd60606..4a75fa0a571 100644 --- a/lib/gitlab/quick_actions/issue_and_merge_request_actions.rb +++ b/lib/gitlab/quick_actions/issue_and_merge_request_actions.rb @@ -26,7 +26,7 @@ module Gitlab end types Issue, MergeRequest condition do - quick_action_target.supports_assignee? && current_user.can?(:"admin_#{quick_action_target.to_ability_name}", project) + quick_action_target.supports_assignee? && current_user.can?(:"set_#{quick_action_target.to_ability_name}_metadata", quick_action_target) end parse_params do |assignee_param| extract_users(assignee_param) @@ -66,7 +66,7 @@ module Gitlab condition do quick_action_target.persisted? && quick_action_target.assignees.any? && - current_user.can?(:"admin_#{quick_action_target.to_ability_name}", project) + current_user.can?(:"set_#{quick_action_target.to_ability_name}_metadata", quick_action_target) end parse_params do |unassign_param| # When multiple users are assigned, all will be unassigned if multiple assignees are no longer allowed @@ -92,7 +92,7 @@ module Gitlab types Issue, MergeRequest condition do quick_action_target.supports_milestone? && - current_user.can?(:"admin_#{quick_action_target.to_ability_name}", project) && + current_user.can?(:"set_#{quick_action_target.to_ability_name}_metadata", quick_action_target) && find_milestones(project, state: 'active').any? end parse_params do |milestone_param| @@ -115,7 +115,7 @@ module Gitlab quick_action_target.persisted? && quick_action_target.milestone_id? && quick_action_target.supports_milestone? && - current_user.can?(:"admin_#{quick_action_target.to_ability_name}", project) + current_user.can?(:"set_#{quick_action_target.to_ability_name}_metadata", quick_action_target) end command :remove_milestone do @updates[:milestone_id] = nil @@ -128,7 +128,7 @@ module Gitlab params '#issue | !merge_request' types Issue, MergeRequest condition do - current_user.can?(:"admin_#{quick_action_target.to_ability_name}", quick_action_target) + current_user.can?(:"set_#{quick_action_target.to_ability_name}_metadata", quick_action_target) end parse_params do |issuable_param| extract_references(issuable_param, :issue).first || @@ -225,7 +225,7 @@ module Gitlab condition do quick_action_target.persisted? && !quick_action_target.discussion_locked? && - current_user.can?(:"admin_#{quick_action_target.to_ability_name}", quick_action_target) + current_user.can?(:"set_#{quick_action_target.to_ability_name}_metadata", quick_action_target) end command :lock do @updates[:discussion_locked] = true @@ -238,7 +238,7 @@ module Gitlab condition do quick_action_target.persisted? && quick_action_target.discussion_locked? && - current_user.can?(:"admin_#{quick_action_target.to_ability_name}", quick_action_target) + current_user.can?(:"set_#{quick_action_target.to_ability_name}_metadata", quick_action_target) end command :unlock do @updates[:discussion_locked] = false |