Commit 6e1cca98 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Include assigned users in /reassign autocomplete

Already assigned users can sometimes be passed to /reassign as a way to
signify that this assignee is meant to be kept while unassigning the
rest.
parent 2771d5e1
...@@ -276,11 +276,13 @@ class GfmAutoComplete { ...@@ -276,11 +276,13 @@ class GfmAutoComplete {
return $.fn.atwho.default.callbacks.filter(query, data, searchKey); return $.fn.atwho.default.callbacks.filter(query, data, searchKey);
} }
if (command === MEMBER_COMMAND.ASSIGN || command === MEMBER_COMMAND.REASSIGN) { if (command === MEMBER_COMMAND.ASSIGN) {
// Only include members which are not assigned to Issuable currently // Only include members which are not assigned to Issuable currently
return data.filter( return data.filter(
member => member.type === 'User' && !assignees.includes(member.search), member => member.type === 'User' && !assignees.includes(member.search),
); );
} else if (command === MEMBER_COMMAND.REASSIGN) {
return data.filter(member => member.type === 'User');
} else if (command === MEMBER_COMMAND.UNASSIGN) { } else if (command === MEMBER_COMMAND.UNASSIGN) {
// Only include members which are assigned to Issuable currently // Only include members which are assigned to Issuable currently
return data.filter(member => assignees.includes(member.search)); return data.filter(member => assignees.includes(member.search));
......
...@@ -65,16 +65,13 @@ const autoCompleteMap = { ...@@ -65,16 +65,13 @@ const autoCompleteMap = {
SidebarMediator.singleton?.store?.assignees?.map(assignee => assignee.username) || []; SidebarMediator.singleton?.store?.assignees?.map(assignee => assignee.username) || [];
} }
if ( if (doesCurrentLineStartWith('/assign', fullText, selectionStart)) {
doesCurrentLineStartWith('/assign', fullText, selectionStart) ||
doesCurrentLineStartWith('/reassign', fullText, selectionStart)
) {
return this.members.filter( return this.members.filter(
member => member.type === 'User' && !this.assignees.includes(member.username), member => member.type === 'User' && !this.assignees.includes(member.username),
); );
} } else if (doesCurrentLineStartWith('/reassign', fullText, selectionStart)) {
return this.members.filter(member => member.type === 'User');
if (doesCurrentLineStartWith('/unassign', fullText, selectionStart)) { } else if (doesCurrentLineStartWith('/unassign', fullText, selectionStart)) {
return this.members.filter(member => this.assignees.includes(member.username)); return this.members.filter(member => this.assignees.includes(member.username));
} }
......
...@@ -30,7 +30,7 @@ RSpec.describe 'GFM autocomplete EE', :js do ...@@ -30,7 +30,7 @@ RSpec.describe 'GFM autocomplete EE', :js do
wait_for_requests wait_for_requests
end end
it 'lists users who are currently not assigned to the issue when using /reassign' do it 'excludes groups when using /reassign' do
note = find('#note-body') note = find('#note-body')
page.within '.timeline-content-form' do page.within '.timeline-content-form' do
note.native.send_keys('/reas') note.native.send_keys('/reas')
...@@ -41,8 +41,8 @@ RSpec.describe 'GFM autocomplete EE', :js do ...@@ -41,8 +41,8 @@ RSpec.describe 'GFM autocomplete EE', :js do
wait_for_requests wait_for_requests
expect(find('#at-view-users .atwho-view-ul')).not_to have_content(user.username)
expect(find('#at-view-users .atwho-view-ul')).not_to have_content(group.name) expect(find('#at-view-users .atwho-view-ul')).not_to have_content(group.name)
expect(find('#at-view-users .atwho-view-ul')).to have_content(user.username)
expect(find('#at-view-users .atwho-view-ul')).to have_content(another_user.username) expect(find('#at-view-users .atwho-view-ul')).to have_content(another_user.username)
end end
...@@ -73,7 +73,7 @@ RSpec.describe 'GFM autocomplete EE', :js do ...@@ -73,7 +73,7 @@ RSpec.describe 'GFM autocomplete EE', :js do
wait_for_requests wait_for_requests
end end
it 'lists users who are currently not assigned to the issue when using /reassign' do it 'excludes groups when using /reassign' do
note = find('#note-body') note = find('#note-body')
page.within '.timeline-content-form' do page.within '.timeline-content-form' do
note.native.send_keys('/reas') note.native.send_keys('/reas')
...@@ -85,8 +85,8 @@ RSpec.describe 'GFM autocomplete EE', :js do ...@@ -85,8 +85,8 @@ RSpec.describe 'GFM autocomplete EE', :js do
wait_for_requests wait_for_requests
expect(find('.tribute-container ul', visible: true)).not_to have_content(user.username)
expect(find('.tribute-container ul', visible: true)).not_to have_content(group.name) expect(find('.tribute-container ul', visible: true)).not_to have_content(group.name)
expect(find('.tribute-container ul', visible: true)).to have_content(user.username)
expect(find('.tribute-container ul', visible: true)).to have_content(another_user.username) expect(find('.tribute-container ul', visible: true)).to have_content(another_user.username)
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