Commit 0a3507e1 authored by Valery Sizov's avatar Valery Sizov

Address review comments

parent a9dc6d28
...@@ -92,18 +92,11 @@ module SlashCommands ...@@ -92,18 +92,11 @@ module SlashCommands
desc 'Assign' desc 'Assign'
explanation do |users| explanation do |users|
if issuable.is_a?(Issue) users = issuable.is_a?(Issue) ? users : users.take(1)
"Assigns #{users.map(&:to_reference).to_sentence}." if users.any? "Assigns #{users.map(&:to_reference).to_sentence}."
else
"Assigns #{users.last.to_reference}." if users.any?
end
end end
params do params do
if issuable.is_a?(Issue) issuable.is_a?(Issue) ? '@user1 @user2' : '@user'
['@user1 @user2']
else
['@user']
end
end end
condition do condition do
current_user.can?(:"admin_#{issuable.to_ability_name}", project) current_user.can?(:"admin_#{issuable.to_ability_name}", project)
...@@ -122,17 +115,19 @@ module SlashCommands ...@@ -122,17 +115,19 @@ module SlashCommands
end end
end end
desc 'Remove all or specific assignee(s)' desc do
explanation do
'Removes assignee(s)'
end
params do
if issuable.is_a?(Issue) if issuable.is_a?(Issue)
['@user1 @user2'] 'Remove all or specific assignee(s)'
else else
[] 'Remove assignee'
end end
end end
explanation do
"Removes #{'assignee'.pluralize(issuable.assignees.size)} #{issuable.assignees.map(&:to_reference).to_sentence}"
end
params do
issuable.is_a?(Issue) ? '@user1 @user2' : ''
end
condition do condition do
issuable.persisted? && issuable.persisted? &&
issuable.assignees.any? && issuable.assignees.any? &&
...@@ -142,11 +137,12 @@ module SlashCommands ...@@ -142,11 +137,12 @@ module SlashCommands
users = extract_users(unassign_param) users = extract_users(unassign_param)
if issuable.is_a?(Issue) if issuable.is_a?(Issue)
if users.any? @updates[:assignee_ids] =
@updates[:assignee_ids] = issuable.assignees.pluck(:id) - users.map(&:id) if users.any?
else issuable.assignees.pluck(:id) - users.map(&:id)
@updates[:assignee_ids] = [] else
end []
end
else else
@updates[:assignee_id] = nil @updates[:assignee_id] = nil
end end
......
...@@ -16,8 +16,9 @@ do. ...@@ -16,8 +16,9 @@ do.
| `/reopen` | Reopen the issue or merge request | | `/reopen` | Reopen the issue or merge request |
| `/merge` | Merge (when pipeline succeeds) | | `/merge` | Merge (when pipeline succeeds) |
| `/title <New title>` | Change title | | `/title <New title>` | Change title |
| `/assign @username` | Assign | | `/assign @user1 @user2 ` | Add assignee(s) |
| `/unassign @user1 @user2` | Remove all the assignees or specified ones | | `/reassign @user1 @user2 ` | Change assignee(s) |
| `/unassign @user1 @user2` | Remove all or specific assignee(s) |
| `/milestone %milestone` | Set milestone | | `/milestone %milestone` | Set milestone |
| `/remove_milestone` | Remove milestone | | `/remove_milestone` | Remove milestone |
| `/label ~foo ~"bar baz"` | Add label(s) | | `/label ~foo ~"bar baz"` | Add label(s) |
...@@ -39,3 +40,6 @@ do. ...@@ -39,3 +40,6 @@ do.
| `/weight <1-9>` | Set the weight of the issue | | `/weight <1-9>` | Set the weight of the issue |
| `/clear_weight` | Clears the issue weight | | `/clear_weight` | Clears the issue weight |
| `/board_move ~column` | Move issue to column on the board | | `/board_move ~column` | Move issue to column on the board |
Note: In GitLab EES every issue can have more than one assignee, so commands `/assign`, `/unassign` and `/reassign`
support multiple assignees.
...@@ -57,7 +57,7 @@ module Gitlab ...@@ -57,7 +57,7 @@ module Gitlab
prms = params prms = params
if prms.respond_to?(:call) if prms.respond_to?(:call)
prms = context.instance_exec(&prms) rescue '' prms = Array(context.instance_exec(&prms)) rescue params
end end
{ {
......
...@@ -947,7 +947,7 @@ describe SlashCommands::InterpretService, services: true do ...@@ -947,7 +947,7 @@ describe SlashCommands::InterpretService, services: true do
it 'includes current assignee reference' do it 'includes current assignee reference' do
_, explanations = service.explain(content, issue) _, explanations = service.explain(content, issue)
expect(explanations).to eq(['Removes assignee(s)']) expect(explanations).to eq(["Removes assignee #{developer.to_reference}"])
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