diff --git a/app/assets/javascripts/filtered_search/filtered_search_manager.js.es6 b/app/assets/javascripts/filtered_search/filtered_search_manager.js.es6 index ffd0d7e9cba086f9f4ea58840b7321a4182aface..4e8a7cfc940c87b12db7183f949a333b76b4349e 100644 --- a/app/assets/javascripts/filtered_search/filtered_search_manager.js.es6 +++ b/app/assets/javascripts/filtered_search/filtered_search_manager.js.es6 @@ -85,6 +85,7 @@ loadSearchParamsFromURL() { const params = gl.utils.getUrlParamsArray(); + const usernameParams = this.getUsernameParams(); const inputValues = []; params.forEach((p) => { @@ -115,6 +116,16 @@ } inputValues.push(`${sanitizedKey}:${symbol}${quotationsToUse}${sanitizedValue}${quotationsToUse}`); + } else if (!match && keyParam === 'assignee_id') { + const id = parseInt(value, 10); + if (usernameParams[id]) { + inputValues.push(`assignee:@${usernameParams[id]}`); + } + } else if (!match && keyParam === 'author_id') { + const id = parseInt(value, 10); + if (usernameParams[id]) { + inputValues.push(`author:@${usernameParams[id]}`); + } } else if (!match && keyParam === 'search') { inputValues.push(sanitizedValue); } @@ -164,6 +175,19 @@ Turbolinks.visit(`?scope=all&utf8=✓&${paths.join('&')}`); } + + getUsernameParams() { + const usernamesById = {}; + try { + const attribute = this.filteredSearchInput.getAttribute('data-username-params'); + JSON.parse(attribute).forEach((user) => { + usernamesById[user.id] = user.username; + }); + } catch (e) { + // do nothing + } + return usernamesById; + } } window.gl = window.gl || {}; diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index 8b2e9cfdee5b38c4bc900b3966f338a3db090ffc..8472ceca3297e3adba4162b5c14414b0d6a0c250 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -23,8 +23,6 @@ class Projects::IssuesController < Projects::ApplicationController respond_to :html def index - return redirect_to_fixed_params if params[:assignee_id].present? || params[:author_id].present? - @issues = issues_collection @issues = @issues.page(params[:page]) if @issues.out_of_range? && @issues.total_pages != 0 @@ -35,6 +33,18 @@ class Projects::IssuesController < Projects::ApplicationController @labels = LabelsFinder.new(current_user, project_id: @project.id, title: params[:label_name]).execute end + @users = [] + + if params[:assignee_id].present? + assignee = User.find_by_id(params[:assignee_id]) + @users.push(assignee) if assignee + end + + if params[:author_id].present? + author = User.find_by_id(params[:author_id]) + @users.push(author) if author + end + respond_to do |format| format.html format.atom { render layout: false } @@ -213,22 +223,6 @@ class Projects::IssuesController < Projects::ApplicationController end end - def redirect_to_fixed_params - fixed_params = params.except(:assignee_id, :author_id) - - if params[:assignee_id].present? - assignee = User.find_by_id(params[:assignee_id]) - fixed_params.merge!(assignee_username: assignee.username) if assignee - end - - if params[:author_id].present? - author = User.find_by_id(params[:author_id]) - fixed_params.merge!(author_username: author.username) if author - end - - redirect_to url_for(fixed_params) - end - # Since iids are implemented only in 6.1 # user may navigate to issue page using old global ids. # diff --git a/app/views/shared/issuable/_search_bar.html.haml b/app/views/shared/issuable/_search_bar.html.haml index 8d7b1d616f476b21f13cf2a807ea783943dd4d2b..8b9f43e70416f65e5d5f33a26da92fc6e3b0286b 100644 --- a/app/views/shared/issuable/_search_bar.html.haml +++ b/app/views/shared/issuable/_search_bar.html.haml @@ -11,7 +11,7 @@ class: "check_all_issues left" .issues-other-filters.filtered-search-container .filtered-search-input-container - %input.form-control.filtered-search{ placeholder: 'Search or filter results...', 'data-id' => 'filtered-search', 'data-project-id' => @project.id } + %input.form-control.filtered-search{ placeholder: 'Search or filter results...', 'data-id' => 'filtered-search', 'data-project-id' => @project.id, 'data-username-params' => @users.to_json(only: [:id, :username]) } = icon('filter') %button.clear-search.hidden{ type: 'button' } = icon('times')