Commit f28bbf94 authored by Jacob Schatz's avatar Jacob Schatz

Merge branch 'project-move-dropdown-search' into 'master'

Fixed issue with move dropdown not being searchable

## What does this MR do?

Adds the ability to search the project move dropdown.

## What are the relevant issue numbers?

Closes #18634 

## Screenshots (if relevant)

![search](/uploads/f10a9a16b608308c1b3c66f186f57f80/search.gif)

See merge request !4666
parents 3a857e0e aa35abf9
...@@ -102,6 +102,10 @@ class @IssuableForm ...@@ -102,6 +102,10 @@ class @IssuableForm
return { return {
results: data results: data
} }
data: (query) ->
{
search: query
}
formatResult: (project) -> formatResult: (project) ->
project.name_with_namespace project.name_with_namespace
formatSelection: (project) -> formatSelection: (project) ->
......
...@@ -35,6 +35,7 @@ class AutocompleteController < ApplicationController ...@@ -35,6 +35,7 @@ class AutocompleteController < ApplicationController
project = Project.find_by_id(params[:project_id]) project = Project.find_by_id(params[:project_id])
projects = current_user.authorized_projects projects = current_user.authorized_projects
projects = projects.search(params[:search]) if params[:search].present?
projects = projects.select do |project| projects = projects.select do |project|
current_user.can?(:admin_issue, project) current_user.can?(:admin_issue, project)
end end
......
...@@ -26,6 +26,7 @@ feature 'issue move to another project' do ...@@ -26,6 +26,7 @@ feature 'issue move to another project' do
context 'user has permission to move issue' do context 'user has permission to move issue' do
let!(:mr) { create(:merge_request, source_project: old_project) } let!(:mr) { create(:merge_request, source_project: old_project) }
let(:new_project) { create(:project) } let(:new_project) { create(:project) }
let(:new_project_search) { create(:project) }
let(:text) { 'Text with !1' } let(:text) { 'Text with !1' }
let(:cross_reference) { old_project.to_reference } let(:cross_reference) { old_project.to_reference }
...@@ -47,6 +48,21 @@ feature 'issue move to another project' do ...@@ -47,6 +48,21 @@ feature 'issue move to another project' do
expect(page).to have_content(issue.title) expect(page).to have_content(issue.title)
end end
scenario 'searching project dropdown', js: true do
new_project_search.team << [user, :reporter]
page.within '.js-move-dropdown' do
first('.select2-choice').click
end
fill_in('s2id_autogen2_search', with: new_project_search.name)
page.within '.select2-drop' do
expect(page).to have_content(new_project_search.name)
expect(page).not_to have_content(new_project.name)
end
end
context 'user does not have permission to move the issue to a project', js: true do context 'user does not have permission to move the issue to a project', js: true do
let!(:private_project) { create(:project, :private) } let!(:private_project) { create(:project, :private) }
let(:another_project) { create(:project) } let(:another_project) { create(:project) }
......
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