diff options
author | Mike Greiling <mike@pixelcog.com> | 2017-01-20 15:35:39 -0600 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2017-01-20 15:35:39 -0600 |
commit | 7b9aa79ddc8795779bf5b6ceeffd2ee4e51813e1 (patch) | |
tree | e823faafdfd3875282a20c405c31675767cf6e05 /app/assets | |
parent | 41b6cfcf03d3320ca7d4439a4e067a14299b7513 (diff) | |
download | gitlab-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.es6 | 24 |
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 || {}; |