summaryrefslogtreecommitdiff
path: root/app/assets
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 /app/assets
parent41b6cfcf03d3320ca7d4439a4e067a14299b7513 (diff)
downloadgitlab-ce-7b9aa79ddc8795779bf5b6ceeffd2ee4e51813e1.tar.gz
pass username and id associations needed in the frontend26955-handle-legacy-issue-filter-params
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/filtered_search/filtered_search_manager.js.es624
1 files changed, 24 insertions, 0 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 || {};