Skip to content

Commit

Permalink
feat(ui): fix query parameter issues. Fixes argoproj#1214
Browse files Browse the repository at this point in the history
Signed-off-by: Sairam Arunachalam <sair.aruna@gmail.com>
  • Loading branch information
sairam91 committed Oct 17, 2024
1 parent 46c3503 commit c254b7f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions ui/src/app/shared/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,22 @@ import * as nsUtils from './namespaces';
* Only "truthy" values are put into the query parameters. I.e. "falsey" values include null, undefined, false, "", 0.
*/
export function historyUrl(path: string, params: {[key: string]: any}) {
const queryParams: string[] = [];
let extraSearchParams: URLSearchParams;
const queryParams = new URLSearchParams();
Object.entries(params)
.filter(([, v]) => v !== null)
.forEach(([k, v]) => {
const searchValue = '{' + k + '}';
if (path.includes(searchValue)) {
path = path.replace(searchValue, v != null ? v : '');
} else if (k === 'extraSearchParams') {
extraSearchParams = v;
(v as URLSearchParams).forEach((value, key) => queryParams.set(key, value));
} else if (v) {
queryParams.push(k + '=' + v);
queryParams.set(k, v);
}
if (k === 'namespace') {
nsUtils.setCurrentNamespace(v);
}
});
const extraString = extraSearchParams ? '&' + extraSearchParams.toString() : '';
return uiUrl(path.replace(/{[^}]*}/g, '')) + '?' + queryParams.join('&') + extraString;

return uiUrl(path.replace(/{[^}]*}/g, '')) + '?' + queryParams.toString();
}

0 comments on commit c254b7f

Please sign in to comment.