Commit a8098344 authored by Enrique Alcántara's avatar Enrique Alcántara

Merge branch '280781-support-assignee-wildcard-filtering-boards-frontend' into 'master'

Add support for assignee wildcard for graphql boards [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!59348
parents 93d4932c cea78902
import { sortBy, cloneDeep } from 'lodash';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { ListType, NOT_FILTER } from './constants';
import { ListType, NOT_FILTER, AssigneeIdParamValues } from './constants';
export function getMilestone() {
return null;
......@@ -186,6 +186,35 @@ export function transformNotFilters(filters) {
}, {});
}
export function getSupportedParams(filters, supportedFilters) {
return supportedFilters.reduce((acc, f) => {
/**
* TODO the API endpoint for the classic boards
* accepts assignee wildcard value as 'assigneeId' param -
* while the GraphQL query accepts the value in 'assigneWildcardId' field.
* Once we deprecate the classics boards,
* we should change the filtered search bar to use 'asssigneeWildcardId' as a token name.
*/
if (f === 'assigneeId' && filters[f]) {
return AssigneeIdParamValues.includes(filters[f])
? {
...acc,
assigneeWildcardId: filters[f].toUpperCase(),
}
: acc;
}
if (filters[f]) {
return {
...acc,
[f]: filters[f],
};
}
return acc;
}, {});
}
// EE-specific feature. Find the implementation in the `ee/`-folder
export function transformBoardConfig() {
return '';
......
......@@ -5,6 +5,20 @@ import boardBlockingIssuesQuery from './graphql/board_blocking_issues.query.grap
import issueSetSubscriptionMutation from './graphql/issue_set_subscription.mutation.graphql';
import issueSetTitleMutation from './graphql/issue_set_title.mutation.graphql';
export const SupportedFilters = [
'assigneeUsername',
'authorUsername',
'labelName',
'milestoneTitle',
'releaseTag',
'search',
'myReactionEmoji',
'assigneeId',
];
/* eslint-disable-next-line @gitlab/require-i18n-strings */
export const AssigneeIdParamValues = ['Any', 'None'];
export const issuableTypes = {
issue: 'issue',
epic: 'epic',
......
import * as Sentry from '@sentry/browser';
import { pick } from 'lodash';
import createBoardListMutation from 'ee_else_ce/boards/graphql/board_list_create.mutation.graphql';
import boardListsQuery from 'ee_else_ce/boards/graphql/board_lists.query.graphql';
import issueMoveListMutation from 'ee_else_ce/boards/graphql/issue_move_list.mutation.graphql';
......@@ -11,6 +10,7 @@ import {
ISSUABLE,
titleQueries,
subscriptionQueries,
SupportedFilters,
} from '~/boards/constants';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import createGqClient, { fetchPolicies } from '~/lib/graphql';
......@@ -27,6 +27,7 @@ import {
transformNotFilters,
moveItemListHelper,
getMoveData,
getSupportedParams,
} from '../boards_util';
import boardLabelsQuery from '../graphql/board_labels.query.graphql';
import destroyBoardListMutation from '../graphql/board_list_destroy.mutation.graphql';
......@@ -65,16 +66,11 @@ export default {
},
setFilters: ({ commit }, filters) => {
const filterParams = pick(filters, [
'assigneeUsername',
'authorUsername',
'labelName',
'milestoneTitle',
'releaseTag',
'search',
'myReactionEmoji',
]);
filterParams.not = transformNotFilters(filters);
const filterParams = {
...getSupportedParams(filters, SupportedFilters),
not: transformNotFilters(filters),
};
commit(types.SET_FILTERS, filterParams);
},
......
......@@ -10,6 +10,8 @@ export const EpicFilterType = {
none: 'None',
};
export const SupportedFiltersEE = ['epicId', 'iterationTitle', 'weight'];
export const IterationFilterType = {
any: 'Any',
none: 'None',
......
import { pick } from 'lodash';
import {
formatBoardLists,
formatListIssues,
......@@ -6,8 +5,9 @@ import {
fullBoardId,
transformNotFilters,
getMoveData,
getSupportedParams,
} from '~/boards/boards_util';
import { BoardType } from '~/boards/constants';
import { BoardType, SupportedFilters } from '~/boards/constants';
import eventHub from '~/boards/eventhub';
import listsIssuesQuery from '~/boards/graphql/lists_issues.query.graphql';
import actionsCE from '~/boards/stores/actions';
......@@ -28,7 +28,12 @@ import {
formatEpicListsPageInfo,
} from '../boards_util';
import { EpicFilterType, IterationFilterType, GroupByParamType } from '../constants';
import {
EpicFilterType,
IterationFilterType,
GroupByParamType,
SupportedFiltersEE,
} from '../constants';
import epicQuery from '../graphql/epic.query.graphql';
import createEpicBoardListMutation from '../graphql/epic_board_list_create.mutation.graphql';
import epicBoardListsQuery from '../graphql/epic_board_lists.query.graphql';
......@@ -116,18 +121,8 @@ export default {
...actionsCE,
setFilters: ({ commit, dispatch, getters }, filters) => {
const filterParams = pick(filters, [
'assigneeUsername',
'authorUsername',
'epicId',
'labelName',
'milestoneTitle',
'iterationTitle',
'releaseTag',
'search',
'weight',
'myReactionEmoji',
]);
const supportedFilters = [...SupportedFilters, ...SupportedFiltersEE];
const filterParams = getSupportedParams(filters, supportedFilters);
// Temporarily disabled until negated filters are supported for epic boards
if (!getters.isEpicBoard) {
......
---
title: Support filtering by assignee wildcard in epic swimlanes
merge_request: 59348
author:
type: fixed
......@@ -66,20 +66,32 @@ describe('setInitialBoardData', () => {
});
describe('setFilters', () => {
it('should commit mutation SET_FILTERS', (done) => {
it.each([
[
'with correct filters as payload',
{
filters: { labelName: 'label' },
updatedFilters: { labelName: 'label', not: {} },
},
],
[
'and updates assigneeWildcardId',
{
filters: { assigneeId: 'None' },
updatedFilters: { assigneeWildcardId: 'NONE', not: {} },
},
],
])('should commit mutation SET_FILTERS %s', (_, { filters, updatedFilters }) => {
const state = {
filters: {},
};
const filters = { labelName: 'label' };
testAction(
actions.setFilters,
filters,
state,
[{ type: types.SET_FILTERS, payload: { ...filters, not: {} } }],
[{ type: types.SET_FILTERS, payload: updatedFilters }],
[],
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