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