Commit 5b932caf authored by Paul Slaughter's avatar Paul Slaughter

Merge branch 'ss/encode-url-for-boards' into 'master'

Add encoding for url for board filtered search

See merge request gitlab-org/gitlab!80006
parents 03fc5f19 4e1e934b
<script> <script>
import { pickBy, isEmpty } from 'lodash'; import { pickBy, isEmpty, mapValues } from 'lodash';
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
import { getIdFromGraphQLId, isGid } from '~/graphql_shared/utils'; import { getIdFromGraphQLId, isGid } from '~/graphql_shared/utils';
import { updateHistory, setUrlParams } from '~/lib/utils/url_utility'; import { updateHistory, setUrlParams } from '~/lib/utils/url_utility';
...@@ -251,22 +251,36 @@ export default { ...@@ -251,22 +251,36 @@ export default {
); );
} }
return { return mapValues(
...notParams, {
author_username: authorUsername, ...notParams,
'label_name[]': labelName, author_username: authorUsername,
assignee_username: assigneeUsername, 'label_name[]': labelName,
assignee_id: assigneeId, assignee_username: assigneeUsername,
milestone_title: milestoneTitle, assignee_id: assigneeId,
iteration_id: iterationId, milestone_title: milestoneTitle,
search, iteration_id: iterationId,
types, search,
weight, types,
epic_id: isGid(epicId) ? getIdFromGraphQLId(epicId) : epicId, weight,
my_reaction_emoji: myReactionEmoji, epic_id: isGid(epicId) ? getIdFromGraphQLId(epicId) : epicId,
release_tag: releaseTag, my_reaction_emoji: myReactionEmoji,
confidential, release_tag: releaseTag,
}; confidential,
},
(value) => {
if (value || value === false) {
// note: need to check array for labels.
if (Array.isArray(value)) {
return value.map((valueItem) => encodeURIComponent(valueItem));
}
return encodeURIComponent(value);
}
return value;
},
);
}, },
}, },
created() { created() {
......
...@@ -120,7 +120,7 @@ describe('BoardFilteredSearch', () => { ...@@ -120,7 +120,7 @@ describe('BoardFilteredSearch', () => {
{ type: 'author', value: { data: 'root', operator: '=' } }, { type: 'author', value: { data: 'root', operator: '=' } },
{ type: 'assignee', value: { data: 'root', operator: '=' } }, { type: 'assignee', value: { data: 'root', operator: '=' } },
{ type: 'label', value: { data: 'label', operator: '=' } }, { type: 'label', value: { data: 'label', operator: '=' } },
{ type: 'label', value: { data: 'label2', operator: '=' } }, { type: 'label', value: { data: 'label&2', operator: '=' } },
{ type: 'milestone', value: { data: 'New Milestone', operator: '=' } }, { type: 'milestone', value: { data: 'New Milestone', operator: '=' } },
{ type: 'type', value: { data: 'INCIDENT', operator: '=' } }, { type: 'type', value: { data: 'INCIDENT', operator: '=' } },
{ type: 'weight', value: { data: '2', operator: '=' } }, { type: 'weight', value: { data: '2', operator: '=' } },
...@@ -134,7 +134,7 @@ describe('BoardFilteredSearch', () => { ...@@ -134,7 +134,7 @@ describe('BoardFilteredSearch', () => {
title: '', title: '',
replace: true, replace: true,
url: url:
'http://test.host/?author_username=root&label_name[]=label&label_name[]=label2&assignee_username=root&milestone_title=New+Milestone&iteration_id=3341&types=INCIDENT&weight=2&release_tag=v1.0.0', 'http://test.host/?author_username=root&label_name[]=label&label_name[]=label%262&assignee_username=root&milestone_title=New%20Milestone&iteration_id=3341&types=INCIDENT&weight=2&release_tag=v1.0.0',
}); });
}); });
......
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