Commit f3d7d063 authored by Vitaly Slobodin's avatar Vitaly Slobodin

Merge branch '299504-epic-swimlanes-negated-filters-not-filtering' into 'master'

Swimlanes - Support negated filters [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!52449
parents eaea3e32 fbadc2d0
import { sortBy } from 'lodash';
import { ListType, NOT_FILTER } from './constants';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { ListType } from './constants';
export function getMilestone() {
return null;
......@@ -144,6 +144,17 @@ export function isListDraggable(list) {
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
export function transformBoardConfig() {
return '';
......@@ -157,4 +168,5 @@ export default {
fullLabelId,
fullIterationId,
isListDraggable,
transformNotFilters,
};
......@@ -16,6 +16,8 @@ export const inactiveId = 0;
export const ISSUABLE = 'issuable';
export const LIST = 'list';
export const NOT_FILTER = 'not[';
export default {
BoardType,
ListType,
......
......@@ -16,6 +16,7 @@ import {
formatIssue,
formatIssueInput,
updateListPosition,
transformNotFilters,
} from '../boards_util';
import listsIssuesQuery from '../graphql/lists_issues.query.graphql';
import boardLabelsQuery from '../graphql/board_labels.query.graphql';
......@@ -66,6 +67,7 @@ export default {
'releaseTag',
'search',
]);
filterParams.not = transformNotFilters(filters);
commit(types.SET_FILTERS, filterParams);
},
......
......@@ -15,6 +15,7 @@ import {
formatListIssues,
formatListsPageInfo,
fullBoardId,
transformNotFilters,
} from '~/boards/boards_util';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import eventHub from '~/boards/eventhub';
......@@ -87,6 +88,8 @@ export default {
'weight',
]);
filterParams.not = transformNotFilters(filters);
if (filters.groupBy === GroupByParamType.epic) {
dispatch('setEpicSwimlanes');
}
......@@ -97,6 +100,9 @@ export default {
} else if (filterParams.epicId) {
filterParams.epicId = fullEpicId(filterParams.epicId);
}
if (filterParams.not.epicId) {
filterParams.not.epicId = fullEpicId(filterParams.not.epicId);
}
if (
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
context 'when filtering by negated iteration' 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
find('.filtered-search').set('iter')
click_button('Iteration')
......@@ -164,17 +167,11 @@ RSpec.describe 'Filter issues by iteration', :js do
end
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
end
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
......@@ -37,7 +37,7 @@ describe('setFilters', () => {
};
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(
actions.setFilters,
......@@ -54,7 +54,7 @@ describe('setFilters', () => {
};
const filters = { labelName: 'label', epicId: 'None' };
const updatedFilters = { labelName: 'label', epicWildcardId: 'NONE' };
const updatedFilters = { labelName: 'label', epicWildcardId: 'NONE', not: {} };
return testAction(
actions.setFilters,
......@@ -71,7 +71,7 @@ describe('setFilters', () => {
};
const filters = { labelName: 'label', iterationId: 'None' };
const updatedFilters = { labelName: 'label', iterationWildcardId: 'NONE' };
const updatedFilters = { labelName: 'label', iterationWildcardId: 'NONE', not: {} };
return testAction(
actions.setFilters,
......@@ -88,7 +88,7 @@ describe('setFilters', () => {
};
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(
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', () => {
actions.setFilters,
filters,
state,
[{ type: types.SET_FILTERS, payload: filters }],
[{ type: types.SET_FILTERS, payload: { ...filters, not: {} } }],
[],
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