Make using assign and unassign quick actions together work as expected

This commit is contained in:
Douwe Maan 2018-09-14 17:53:54 +02:00
parent 4007456808
commit 8811692c6a
No known key found for this signature in database
GPG Key ID: 5976703F65143D36
2 changed files with 18 additions and 16 deletions

View File

@ -126,18 +126,16 @@ module QuickActions
parse_params do |assignee_param| parse_params do |assignee_param|
extract_users(assignee_param) extract_users(assignee_param)
end end
# rubocop: disable CodeReuse/ActiveRecord
command :assign do |users| command :assign do |users|
next if users.empty? next if users.empty?
@updates[:assignee_ids] = if issuable.allows_multiple_assignees?
if issuable.allows_multiple_assignees? @updates[:assignee_ids] ||= issuable.assignees.map(&:id)
issuable.assignees.pluck(:id) + users.map(&:id) @updates[:assignee_ids] += users.map(&:id)
else else
[users.first.id] @updates[:assignee_ids] = [users.first.id]
end end
end end
# rubocop: enable CodeReuse/ActiveRecord
desc do desc do
if issuable.allows_multiple_assignees? if issuable.allows_multiple_assignees?
@ -164,16 +162,14 @@ module QuickActions
# When multiple users are assigned, all will be unassigned if multiple assignees are no longer allowed # When multiple users are assigned, all will be unassigned if multiple assignees are no longer allowed
extract_users(unassign_param) if issuable.allows_multiple_assignees? extract_users(unassign_param) if issuable.allows_multiple_assignees?
end end
# rubocop: disable CodeReuse/ActiveRecord
command :unassign do |users = nil| command :unassign do |users = nil|
@updates[:assignee_ids] = if issuable.allows_multiple_assignees? && users&.any?
if users&.any? @updates[:assignee_ids] ||= issuable.assignees.map(&:id)
issuable.assignees.pluck(:id) - users.map(&:id) @updates[:assignee_ids] -= users.map(&:id)
else else
[] @updates[:assignee_ids] = []
end end
end end
# rubocop: enable CodeReuse/ActiveRecord
desc 'Set milestone' desc 'Set milestone'
explanation do |milestone| explanation do |milestone|

View File

@ -0,0 +1,6 @@
---
title: Don't ignore first action when assign and unassign quick actions are used in
the same comment
merge_request: 21749
author:
type: fixed