Commit 2122dbcc authored by Justin Ho's avatar Justin Ho

Fix issue with labels format

Change setting of URL params from using `labels=` to
`labels[]=` to conform to Rails standards.

This is applied only for Jira issues because this is what the
backend expects. This is slightly different from GitLab's
issues API since that takes in `labels=` in comma-separated
format.
parent ca7aa622
...@@ -296,7 +296,7 @@ export default { ...@@ -296,7 +296,7 @@ export default {
const ignored = ['utf8', 'state']; const ignored = ['utf8', 'state'];
const params = omit(this.filters, ignored); const params = omit(this.filters, ignored);
historyPushState(setUrlParams(params, window.location.href, true)); historyPushState(setUrlParams(params, window.location.href, true, true));
this.fetchIssuables(); this.fetchIssuables();
}, },
handleFilter(filters) { handleFilter(filters) {
......
...@@ -346,7 +346,12 @@ export function objectToQuery(obj) { ...@@ -346,7 +346,12 @@ export function objectToQuery(obj) {
* @param {Boolean} clearParams Indicates whether existing query params should be removed or not * @param {Boolean} clearParams Indicates whether existing query params should be removed or not
* @returns {String} A copy of the original with the updated query params * @returns {String} A copy of the original with the updated query params
*/ */
export const setUrlParams = (params, url = window.location.href, clearParams = false) => { export const setUrlParams = (
params,
url = window.location.href,
clearParams = false,
railsArraySyntax = false,
) => {
const urlObj = new URL(url); const urlObj = new URL(url);
const queryString = urlObj.search; const queryString = urlObj.search;
const searchParams = clearParams ? new URLSearchParams('') : new URLSearchParams(queryString); const searchParams = clearParams ? new URLSearchParams('') : new URLSearchParams(queryString);
...@@ -355,11 +360,12 @@ export const setUrlParams = (params, url = window.location.href, clearParams = f ...@@ -355,11 +360,12 @@ export const setUrlParams = (params, url = window.location.href, clearParams = f
if (params[key] === null || params[key] === undefined) { if (params[key] === null || params[key] === undefined) {
searchParams.delete(key); searchParams.delete(key);
} else if (Array.isArray(params[key])) { } else if (Array.isArray(params[key])) {
const keyName = railsArraySyntax ? `${key}[]` : key;
params[key].forEach((val, idx) => { params[key].forEach((val, idx) => {
if (idx === 0) { if (idx === 0) {
searchParams.set(key, val); searchParams.set(keyName, val);
} else { } else {
searchParams.append(key, val); searchParams.append(keyName, val);
} }
}); });
} else { } else {
......
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