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 {
const ignored = ['utf8', 'state'];
const params = omit(this.filters, ignored);
historyPushState(setUrlParams(params, window.location.href, true));
historyPushState(setUrlParams(params, window.location.href, true, true));
this.fetchIssuables();
},
handleFilter(filters) {
......
......@@ -346,7 +346,12 @@ export function objectToQuery(obj) {
* @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
*/
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 queryString = urlObj.search;
const searchParams = clearParams ? new URLSearchParams('') : new URLSearchParams(queryString);
......@@ -355,11 +360,12 @@ export const setUrlParams = (params, url = window.location.href, clearParams = f
if (params[key] === null || params[key] === undefined) {
searchParams.delete(key);
} else if (Array.isArray(params[key])) {
const keyName = railsArraySyntax ? `${key}[]` : key;
params[key].forEach((val, idx) => {
if (idx === 0) {
searchParams.set(key, val);
searchParams.set(keyName, val);
} else {
searchParams.append(key, val);
searchParams.append(keyName, val);
}
});
} 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