Commit fbadc2d0 authored by Florie Guibert's avatar Florie Guibert

Swimlanes - Support negated filters

Add support for not filters on Swimlanes
parent 42dffc6c
import { sortBy } from 'lodash'; import { sortBy } from 'lodash';
import { ListType, NOT_FILTER } from './constants';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { ListType } from './constants';
export function getMilestone() { export function getMilestone() {
return null; return null;
...@@ -144,6 +144,17 @@ export function isListDraggable(list) { ...@@ -144,6 +144,17 @@ export function isListDraggable(list) {
return list.listType !== ListType.backlog && list.listType !== ListType.closed; return list.listType !== ListType.backlog && list.listType !== ListType.closed;
} }
export function transformNotFilters(filters) {
return Object.keys(filters)
.filter((key) => key.startsWith(NOT_FILTER))
.reduce((obj, key) => {
return {
...obj,
[key.substring(4, key.length - 1)]: filters[key],
};
}, {});
}
// EE-specific feature. Find the implementation in the `ee/`-folder // EE-specific feature. Find the implementation in the `ee/`-folder
export function transformBoardConfig() { export function transformBoardConfig() {
return ''; return '';
...@@ -157,4 +168,5 @@ export default { ...@@ -157,4 +168,5 @@ export default {
fullLabelId, fullLabelId,
fullIterationId, fullIterationId,
isListDraggable, isListDraggable,
transformNotFilters,
}; };
...@@ -16,6 +16,8 @@ export const inactiveId = 0; ...@@ -16,6 +16,8 @@ export const inactiveId = 0;
export const ISSUABLE = 'issuable'; export const ISSUABLE = 'issuable';
export const LIST = 'list'; export const LIST = 'list';
export const NOT_FILTER = 'not[';
export default { export default {
BoardType, BoardType,
ListType, ListType,
......
...@@ -16,6 +16,7 @@ import { ...@@ -16,6 +16,7 @@ import {
formatIssue, formatIssue,
formatIssueInput, formatIssueInput,
updateListPosition, updateListPosition,
transformNotFilters,
} from '../boards_util'; } from '../boards_util';
import listsIssuesQuery from '../graphql/lists_issues.query.graphql'; import listsIssuesQuery from '../graphql/lists_issues.query.graphql';
import boardLabelsQuery from '../graphql/board_labels.query.graphql'; import boardLabelsQuery from '../graphql/board_labels.query.graphql';
...@@ -66,6 +67,7 @@ export default { ...@@ -66,6 +67,7 @@ export default {
'releaseTag', 'releaseTag',
'search', 'search',
]); ]);
filterParams.not = transformNotFilters(filters);
commit(types.SET_FILTERS, filterParams); commit(types.SET_FILTERS, filterParams);
}, },
......
...@@ -15,6 +15,7 @@ import { ...@@ -15,6 +15,7 @@ import {
formatListIssues, formatListIssues,
formatListsPageInfo, formatListsPageInfo,
fullBoardId, fullBoardId,
transformNotFilters,
} from '~/boards/boards_util'; } from '~/boards/boards_util';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import eventHub from '~/boards/eventhub'; import eventHub from '~/boards/eventhub';
...@@ -87,6 +88,8 @@ export default { ...@@ -87,6 +88,8 @@ export default {
'weight', 'weight',
]); ]);
filterParams.not = transformNotFilters(filters);
if (filters.groupBy === GroupByParamType.epic) { if (filters.groupBy === GroupByParamType.epic) {
dispatch('setEpicSwimlanes'); dispatch('setEpicSwimlanes');
} }
...@@ -97,6 +100,9 @@ export default { ...@@ -97,6 +100,9 @@ export default {
} else if (filterParams.epicId) { } else if (filterParams.epicId) {
filterParams.epicId = fullEpicId(filterParams.epicId); filterParams.epicId = fullEpicId(filterParams.epicId);
} }
if (filterParams.not.epicId) {
filterParams.not.epicId = fullEpicId(filterParams.not.epicId);
}
if ( if (
filters.iterationId === IterationFilterType.any || filters.iterationId === IterationFilterType.any ||
......
---
title: Swimlanes - Support negated filters
merge_request: 52449
author:
type: fixed
...@@ -79,6 +79,9 @@ RSpec.describe 'Filter issues by iteration', :js do ...@@ -79,6 +79,9 @@ RSpec.describe 'Filter issues by iteration', :js do
context 'when filtering by negated iteration' do context 'when filtering by negated iteration' do
before do before do
# iterationWildCardId is not yet supported by graphQL https://gitlab.com/gitlab-org/gitlab/-/issues/300115
stub_feature_flags(graphql_board_lists: false)
page.within('.filtered-search-wrapper') do page.within('.filtered-search-wrapper') do
find('.filtered-search').set('iter') find('.filtered-search').set('iter')
click_button('Iteration') click_button('Iteration')
...@@ -164,17 +167,11 @@ RSpec.describe 'Filter issues by iteration', :js do ...@@ -164,17 +167,11 @@ RSpec.describe 'Filter issues by iteration', :js do
end end
before do before do
# iterationWildCardId is not yet supported by graphQL https://gitlab.com/gitlab-org/gitlab/-/issues/300115
stub_feature_flags(graphql_board_lists: false)
sign_in user sign_in user
end end
it_behaves_like 'filters by iteration' it_behaves_like 'filters by iteration'
context 'when graphql_board_lists is disabled' do
before do
stub_feature_flags(graphql_board_lists: false)
end
it_behaves_like 'filters by iteration'
end
end end
end end
...@@ -37,7 +37,7 @@ describe('setFilters', () => { ...@@ -37,7 +37,7 @@ describe('setFilters', () => {
}; };
const filters = { labelName: 'label', epicId: 1 }; const filters = { labelName: 'label', epicId: 1 };
const updatedFilters = { labelName: 'label', epicId: 'gid://gitlab/Epic/1' }; const updatedFilters = { labelName: 'label', epicId: 'gid://gitlab/Epic/1', not: {} };
return testAction( return testAction(
actions.setFilters, actions.setFilters,
...@@ -54,7 +54,7 @@ describe('setFilters', () => { ...@@ -54,7 +54,7 @@ describe('setFilters', () => {
}; };
const filters = { labelName: 'label', epicId: 'None' }; const filters = { labelName: 'label', epicId: 'None' };
const updatedFilters = { labelName: 'label', epicWildcardId: 'NONE' }; const updatedFilters = { labelName: 'label', epicWildcardId: 'NONE', not: {} };
return testAction( return testAction(
actions.setFilters, actions.setFilters,
...@@ -71,7 +71,7 @@ describe('setFilters', () => { ...@@ -71,7 +71,7 @@ describe('setFilters', () => {
}; };
const filters = { labelName: 'label', iterationId: 'None' }; const filters = { labelName: 'label', iterationId: 'None' };
const updatedFilters = { labelName: 'label', iterationWildcardId: 'NONE' }; const updatedFilters = { labelName: 'label', iterationWildcardId: 'NONE', not: {} };
return testAction( return testAction(
actions.setFilters, actions.setFilters,
...@@ -88,7 +88,7 @@ describe('setFilters', () => { ...@@ -88,7 +88,7 @@ describe('setFilters', () => {
}; };
const filters = { labelName: 'label', epicId: 1, groupBy: 'epic' }; const filters = { labelName: 'label', epicId: 1, groupBy: 'epic' };
const updatedFilters = { labelName: 'label', epicId: 'gid://gitlab/Epic/1' }; const updatedFilters = { labelName: 'label', epicId: 'gid://gitlab/Epic/1', not: {} };
return testAction( return testAction(
actions.setFilters, actions.setFilters,
......
import { transformNotFilters } from '~/boards/boards_util';
describe('transformNotFilters', () => {
const filters = {
'not[labelName]': ['label'],
'not[assigneeUsername]': 'assignee',
};
it('formats not filters, transforms epicId to fullEpicId', () => {
const result = transformNotFilters(filters);
expect(result).toEqual({
labelName: ['label'],
assigneeUsername: 'assignee',
});
});
});
...@@ -71,7 +71,7 @@ describe('setFilters', () => { ...@@ -71,7 +71,7 @@ describe('setFilters', () => {
actions.setFilters, actions.setFilters,
filters, filters,
state, state,
[{ type: types.SET_FILTERS, payload: filters }], [{ type: types.SET_FILTERS, payload: { ...filters, not: {} } }],
[], [],
done, done,
); );
......
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