Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2024-01-16 13:42:19 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2024-01-16 13:42:19 +0300
commit84d1bd786125c1c14a3ba5f63e38a4cc736a9027 (patch)
treef550fa965f507077e20dbb6d61a8269a99ef7107 /lib/gitlab/quick_actions
parent3a105e36e689f7b75482236712f1a47fd5a76814 (diff)
Add latest changes from gitlab-org/gitlab@16-8-stable-eev16.8.0-rc42
Diffstat (limited to 'lib/gitlab/quick_actions')
-rw-r--r--lib/gitlab/quick_actions/extractor.rb8
-rw-r--r--lib/gitlab/quick_actions/issuable_actions.rb8
-rw-r--r--lib/gitlab/quick_actions/issue_actions.rb20
-rw-r--r--lib/gitlab/quick_actions/merge_request_actions.rb18
4 files changed, 42 insertions, 12 deletions
diff --git a/lib/gitlab/quick_actions/extractor.rb b/lib/gitlab/quick_actions/extractor.rb
index c6a7a39a943..72f4a101809 100644
--- a/lib/gitlab/quick_actions/extractor.rb
+++ b/lib/gitlab/quick_actions/extractor.rb
@@ -142,9 +142,11 @@ module Gitlab
output = "`/#{matched_text[:cmd]}#{" " + matched_text[:arg] if matched_text[:arg]}`"
output += "\n" if matched_text[0].include?("\n")
elsif keep_actions
- # requires an additional newline so that when rendered, it appears
- # on its own line, rather than all on the same line
- output = "\n#{matched_text[0]}\n"
+ # put the command in a new paragraph, but without introducing newlines
+ # so that each command is in its own line, while also preserving sourcemaps
+ # of the content that follows.
+ output = ActionController::Base.helpers.simple_format(matched_text[0].chomp)
+ output += "\n" if matched_text[0].ends_with?("\n")
end
end
diff --git a/lib/gitlab/quick_actions/issuable_actions.rb b/lib/gitlab/quick_actions/issuable_actions.rb
index 2f7fa89019e..e4b195767ea 100644
--- a/lib/gitlab/quick_actions/issuable_actions.rb
+++ b/lib/gitlab/quick_actions/issuable_actions.rb
@@ -197,12 +197,12 @@ module Gitlab
@updates[:subscription_event] = 'unsubscribe'
end
- desc { _('Toggle emoji award') }
+ desc { _('Toggle emoji reaction') }
explanation do |name|
- _("Toggles :%{name}: emoji award.") % { name: name } if name
+ _("Toggles :%{name}: emoji reaction.") % { name: name } if name
end
execution_message do |name|
- _("Toggled :%{name}: emoji award.") % { name: name } if name
+ _("Toggled :%{name}: emoji reaction.") % { name: name } if name
end
params ':emoji:'
types ::Issuable
@@ -213,7 +213,7 @@ module Gitlab
match = emoji_param.match(Banzai::Filter::EmojiFilter.emoji_pattern)
match[1] if match
end
- command :award, :react do |name|
+ command :react, :award do |name|
if name && quick_action_target.user_can_award?(current_user)
@updates[:emoji_award] = name
end
diff --git a/lib/gitlab/quick_actions/issue_actions.rb b/lib/gitlab/quick_actions/issue_actions.rb
index c79432f36cc..b3f56e8590a 100644
--- a/lib/gitlab/quick_actions/issue_actions.rb
+++ b/lib/gitlab/quick_actions/issue_actions.rb
@@ -240,6 +240,26 @@ module Gitlab
@execution_message[:invite_email] = response.message
end
+ desc { _('Remove email participant(s)') }
+ explanation { _('Removes email participant(s).') }
+ params 'email1@example.com email2@example.com (up to 6 emails)'
+ types Issue
+ condition do
+ quick_action_target.persisted? &&
+ Feature.enabled?(:issue_email_participants, parent) &&
+ current_user.can?(:"admin_#{quick_action_target.to_ability_name}", quick_action_target) &&
+ quick_action_target.issue_email_participants.any?
+ end
+ command :remove_email do |emails = ""|
+ response = ::IssueEmailParticipants::DestroyService.new(
+ target: quick_action_target,
+ current_user: current_user,
+ emails: emails.split(' ')
+ ).execute
+
+ @execution_message[:remove_email] = response.message
+ end
+
desc { _('Promote issue to incident') }
explanation { _('Promotes issue to incident') }
execution_message { _('Issue has been promoted to incident') }
diff --git a/lib/gitlab/quick_actions/merge_request_actions.rb b/lib/gitlab/quick_actions/merge_request_actions.rb
index fe18bc8e133..4276091251a 100644
--- a/lib/gitlab/quick_actions/merge_request_actions.rb
+++ b/lib/gitlab/quick_actions/merge_request_actions.rb
@@ -6,6 +6,10 @@ module Gitlab
extend ActiveSupport::Concern
include Gitlab::QuickActions::Dsl
+ REBASE_FAILURE_UNMERGEABLE = 'This merge request is currently in an unmergeable state, and cannot be rebased.'
+ REBASE_FAILURE_PROTECTED_BRANCH = 'This merge request branch is protected from force push.'
+ REBASE_FAILURE_REBASE_IN_PROGRESS = 'A rebase is already in progress.'
+
included do
# MergeRequest only quick actions definitions
desc do
@@ -46,6 +50,10 @@ module Gitlab
@updates[:merge] = params[:merge_request_diff_head_sha]
end
+ ########################################################################
+ #
+ # /rebase
+ #
types MergeRequest
desc do
_('Rebase source branch')
@@ -66,17 +74,17 @@ module Gitlab
end
command :rebase do
unless quick_action_target.permits_force_push?
- @execution_message[:rebase] = _('This merge request branch is protected from force push.')
+ @execution_message[:rebase] = _(REBASE_FAILURE_PROTECTED_BRANCH)
next
end
if quick_action_target.cannot_be_merged?
- @execution_message[:rebase] = _('This merge request cannot be rebased while there are conflicts.')
+ @execution_message[:rebase] = _(REBASE_FAILURE_UNMERGEABLE)
next
end
if quick_action_target.rebase_in_progress?
- @execution_message[:rebase] = _('A rebase is already in progress.')
+ @execution_message[:rebase] = _(REBASE_FAILURE_REBASE_IN_PROGRESS)
next
end
@@ -210,7 +218,7 @@ module Gitlab
explanation { _('Approve the current merge request.') }
types MergeRequest
condition do
- quick_action_target.persisted? && quick_action_target.eligible_for_approval_by?(current_user)
+ quick_action_target.persisted? && quick_action_target.eligible_for_approval_by?(current_user) && !quick_action_target.merged?
end
command :approve do
success = ::MergeRequests::ApprovalService.new(project: quick_action_target.project, current_user: current_user).execute(quick_action_target)
@@ -224,7 +232,7 @@ module Gitlab
explanation { _('Unapprove the current merge request.') }
types MergeRequest
condition do
- quick_action_target.persisted? && quick_action_target.eligible_for_unapproval_by?(current_user)
+ quick_action_target.persisted? && quick_action_target.eligible_for_unapproval_by?(current_user) && !quick_action_target.merged?
end
command :unapprove do
success = ::MergeRequests::RemoveApprovalService.new(project: quick_action_target.project, current_user: current_user).execute(quick_action_target)