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

Address review comments

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