Commit 83738de3 authored by Eulyeon Ko's avatar Eulyeon Ko Committed by Natalia Tepluhina

Fix labels board scope config parsing in GraphQL boards [RUN AS-IF-FOSS]

parent a32387e5
...@@ -28,6 +28,10 @@ export default class FilteredSearchBoards extends FilteredSearchManager { ...@@ -28,6 +28,10 @@ export default class FilteredSearchBoards extends FilteredSearchManager {
if (vuexstore.getters.shouldUseGraphQL && vuexstore.state.boardConfig) { if (vuexstore.getters.shouldUseGraphQL && vuexstore.state.boardConfig) {
const boardConfigPath = transformBoardConfig(vuexstore.state.boardConfig); const boardConfigPath = transformBoardConfig(vuexstore.state.boardConfig);
// TODO Refactor: https://gitlab.com/gitlab-org/gitlab/-/issues/329274
// here we are using "window.location.search" as a temporary store
// only to unpack the params and do another validation inside
// 'performSearch' and 'setFilter' vuex actions.
if (boardConfigPath !== '') { if (boardConfigPath !== '') {
const filterPath = window.location.search ? `${window.location.search}&` : '?'; const filterPath = window.location.search ? `${window.location.search}&` : '?';
updateHistory({ updateHistory({
......
...@@ -124,9 +124,8 @@ export function transformBoardConfig(boardConfig) { ...@@ -124,9 +124,8 @@ export function transformBoardConfig(boardConfig) {
boardConfig.labels.forEach((label) => { boardConfig.labels.forEach((label) => {
const labelTitle = encodeURIComponent(label.title); const labelTitle = encodeURIComponent(label.title);
const param = `label_name[]=${labelTitle}`; const param = `label_name[]=${labelTitle}`;
const labelIndex = passedFilterParams.label_name?.indexOf(labelTitle);
if (labelIndex === -1 || labelIndex === undefined) { if (!passedFilterParams.label_name?.includes(label.title)) {
filterPath.push(param); filterPath.push(param);
} }
}); });
......
...@@ -85,6 +85,7 @@ describe('transformBoardConfig', () => { ...@@ -85,6 +85,7 @@ describe('transformBoardConfig', () => {
assigneeUsername: 'username', assigneeUsername: 'username',
labels: [ labels: [
{ id: 5, title: 'Deliverable', color: '#34ebec', type: 'GroupLabel', textColor: '#333333' }, { id: 5, title: 'Deliverable', color: '#34ebec', type: 'GroupLabel', textColor: '#333333' },
{ id: 6, title: 'On hold', color: '#34ebec', type: 'GroupLabel', textColor: '#333333' },
], ],
weight: 0, weight: 0,
}; };
...@@ -94,12 +95,12 @@ describe('transformBoardConfig', () => { ...@@ -94,12 +95,12 @@ describe('transformBoardConfig', () => {
const result = transformBoardConfig(boardConfig); const result = transformBoardConfig(boardConfig);
expect(result).toContain( expect(result).toContain(
'milestone_title=milestone&weight=0&assignee_username=username&label_name[]=Deliverable', 'milestone_title=milestone&weight=0&assignee_username=username&label_name[]=Deliverable&label_name[]=On%20hold',
); );
}); });
it('formats url parameters from boardConfig object preventing duplicates with passed filter query', () => { it('formats url parameters from boardConfig object preventing duplicates with passed filter query', () => {
window.location = { search: 'label_name[]=Deliverable' }; window.location = { search: '?label_name[]=Deliverable&label_name[]=On%20hold' };
const result = transformBoardConfig(boardConfig); const result = transformBoardConfig(boardConfig);
expect(result).toContain('milestone_title=milestone&weight=0&assignee_username=username'); expect(result).toContain('milestone_title=milestone&weight=0&assignee_username=username');
......
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