summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Greiling <mike@pixelcog.com>2017-01-20 15:35:39 -0600
committerMike Greiling <mike@pixelcog.com>2017-01-20 15:35:39 -0600
commit7b9aa79ddc8795779bf5b6ceeffd2ee4e51813e1 (patch)
treee823faafdfd3875282a20c405c31675767cf6e05
parent41b6cfcf03d3320ca7d4439a4e067a14299b7513 (diff)
downloadgitlab-ce-26955-handle-legacy-issue-filter-params.tar.gz
pass username and id associations needed in the frontend26955-handle-legacy-issue-filter-params
-rw-r--r--app/assets/javascripts/filtered_search/filtered_search_manager.js.es624
-rw-r--r--app/controllers/projects/issues_controller.rb30
-rw-r--r--app/views/shared/issuable/_search_bar.html.haml2
3 files changed, 37 insertions, 19 deletions
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 ffd0d7e9cba..4e8a7cfc940 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 8b2e9cfdee5..8472ceca329 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 8d7b1d616f4..8b9f43e7041 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')