Commit ab742125 authored by Phil Hughes's avatar Phil Hughes

Merge branch...

Merge branch '322536-fix-label-filter-link-on-jira-issues-list-page-when-ff-is-enabled' into 'master'

Fix label filter link on Jira issues list page when ff is enabled

See merge request gitlab-org/gitlab!54899
parents 7f8aa875 0a7b0866
...@@ -34,6 +34,11 @@ export default { ...@@ -34,6 +34,11 @@ export default {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
labelFilterParam: {
type: String,
required: false,
default: 'label_name',
},
showCheckbox: { showCheckbox: {
type: Boolean, type: Boolean,
required: true, required: true,
...@@ -105,9 +110,8 @@ export default { ...@@ -105,9 +110,8 @@ export default {
}, },
labelTarget(label) { labelTarget(label) {
if (this.enableLabelPermalinks) { if (this.enableLabelPermalinks) {
const key = encodeURIComponent('label_name[]');
const value = encodeURIComponent(this.labelTitle(label)); const value = encodeURIComponent(this.labelTitle(label));
return `?${key}=${value}`; return `?${this.labelFilterParam}[]=${value}`;
} }
return '#'; return '#';
}, },
......
...@@ -122,6 +122,11 @@ export default { ...@@ -122,6 +122,11 @@ export default {
required: false, required: false,
default: true, default: true,
}, },
labelFilterParam: {
type: String,
required: false,
default: null,
},
}, },
data() { data() {
return { return {
...@@ -180,7 +185,7 @@ export default { ...@@ -180,7 +185,7 @@ export default {
handler(params) { handler(params) {
if (Object.keys(params).length) { if (Object.keys(params).length) {
updateHistory({ updateHistory({
url: setUrlParams(params, window.location.href, true), url: setUrlParams(params, window.location.href, true, false, true),
title: document.title, title: document.title,
replace: true, replace: true,
}); });
...@@ -258,6 +263,7 @@ export default { ...@@ -258,6 +263,7 @@ export default {
:issuable-symbol="issuableSymbol" :issuable-symbol="issuableSymbol"
:issuable="issuable" :issuable="issuable"
:enable-label-permalinks="enableLabelPermalinks" :enable-label-permalinks="enableLabelPermalinks"
:label-filter-param="labelFilterParam"
:show-checkbox="showBulkEditSidebar" :show-checkbox="showBulkEditSidebar"
:checked="issuableChecked(issuable)" :checked="issuableChecked(issuable)"
@checked-input="handleIssuableCheckedInput(issuable, $event)" @checked-input="handleIssuableCheckedInput(issuable, $event)"
......
...@@ -473,6 +473,7 @@ export const setUrlParams = ( ...@@ -473,6 +473,7 @@ export const setUrlParams = (
url = window.location.href, url = window.location.href,
clearParams = false, clearParams = false,
railsArraySyntax = false, railsArraySyntax = false,
decodeParams = false,
) => { ) => {
const urlObj = new URL(url); const urlObj = new URL(url);
const queryString = urlObj.search; const queryString = urlObj.search;
...@@ -495,7 +496,9 @@ export const setUrlParams = ( ...@@ -495,7 +496,9 @@ export const setUrlParams = (
} }
}); });
urlObj.search = searchParams.toString(); urlObj.search = decodeParams
? decodeURIComponent(searchParams.toString())
: searchParams.toString();
return urlObj.toString(); return urlObj.toString();
}; };
......
...@@ -75,13 +75,14 @@ export default { ...@@ -75,13 +75,14 @@ export default {
); );
}, },
hasFiltersApplied() { hasFiltersApplied() {
return Boolean(this.filterParams.search); return Boolean(this.filterParams.search || this.filterParams.labels);
}, },
urlParams() { urlParams() {
return { return {
state: this.currentState, state: this.currentState,
page: this.currentPage, page: this.currentPage,
sort: this.sortedBy, sort: this.sortedBy,
'labels[]': this.filterParams.labels,
search: this.filterParams.search, search: this.filterParams.search,
}; };
}, },
...@@ -101,6 +102,7 @@ export default { ...@@ -101,6 +102,7 @@ export default {
per_page: this.$options.defaultPageSize, per_page: this.$options.defaultPageSize,
state: this.currentState, state: this.currentState,
sort: this.sortedBy, sort: this.sortedBy,
labels: this.filterParams.labels,
search: this.filterParams.search, search: this.filterParams.search,
}, },
}) })
...@@ -190,7 +192,7 @@ export default { ...@@ -190,7 +192,7 @@ export default {
:previous-page="currentPage - 1" :previous-page="currentPage - 1"
:next-page="currentPage + 1" :next-page="currentPage + 1"
:url-params="urlParams" :url-params="urlParams"
:enable-label-permalinks="false" label-filter-param="labels"
recent-searches-storage-key="jira_issues" recent-searches-storage-key="jira_issues"
@click-tab="fetchIssuesBy('currentState', $event)" @click-tab="fetchIssuesBy('currentState', $event)"
@page-change="fetchIssuesBy('currentPage', $event)" @page-change="fetchIssuesBy('currentPage', $event)"
......
...@@ -217,7 +217,7 @@ describe('JiraIssuesListRoot', () => { ...@@ -217,7 +217,7 @@ describe('JiraIssuesListRoot', () => {
nextPage: 2, nextPage: 2,
urlParams: wrapper.vm.urlParams, urlParams: wrapper.vm.urlParams,
recentSearchesStorageKey: 'jira_issues', recentSearchesStorageKey: 'jira_issues',
enableLabelPermalinks: false, enableLabelPermalinks: true,
}); });
}); });
......
...@@ -202,7 +202,7 @@ describe('IssuableItem', () => { ...@@ -202,7 +202,7 @@ describe('IssuableItem', () => {
describe('labelTarget', () => { describe('labelTarget', () => {
it('returns target string for a provided label param when `enableLabelPermalinks` is true', () => { it('returns target string for a provided label param when `enableLabelPermalinks` is true', () => {
expect(wrapper.vm.labelTarget(mockRegularLabel)).toBe( expect(wrapper.vm.labelTarget(mockRegularLabel)).toBe(
'?label_name%5B%5D=Documentation%20Update', '?label_name[]=Documentation%20Update',
); );
}); });
......
...@@ -814,6 +814,14 @@ describe('URL utility', () => { ...@@ -814,6 +814,14 @@ describe('URL utility', () => {
); );
}); });
it('decodes URI when decodeURI=true', () => {
const url = 'https://gitlab.com/test';
expect(urlUtils.setUrlParams({ labels: ['foo', 'bar'] }, url, false, true, true)).toEqual(
'https://gitlab.com/test?labels[]=foo&labels[]=bar',
);
});
it('removes all existing URL params and sets a new param when cleanParams=true', () => { it('removes all existing URL params and sets a new param when cleanParams=true', () => {
const url = 'https://gitlab.com/test?group_id=gitlab-org&project_id=my-project'; const url = 'https://gitlab.com/test?group_id=gitlab-org&project_id=my-project';
......
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