Commit f8ee38c5 authored by Scott Stern's avatar Scott Stern Committed by Mark Florian

Add assignee wildcard id on new filtered search

Addresses https://gitlab.com/gitlab-org/gitlab/-/issues/349569.
parent 0c3b6bf0
...@@ -6,6 +6,7 @@ import { updateHistory, setUrlParams } from '~/lib/utils/url_utility'; ...@@ -6,6 +6,7 @@ import { updateHistory, setUrlParams } from '~/lib/utils/url_utility';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { FILTERED_SEARCH_TERM } from '~/vue_shared/components/filtered_search_bar/constants'; import { FILTERED_SEARCH_TERM } from '~/vue_shared/components/filtered_search_bar/constants';
import FilteredSearch from '~/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue'; import FilteredSearch from '~/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue';
import { AssigneeFilterType } from '~/boards/constants';
export default { export default {
i18n: { i18n: {
...@@ -37,6 +38,7 @@ export default { ...@@ -37,6 +38,7 @@ export default {
authorUsername, authorUsername,
labelName, labelName,
assigneeUsername, assigneeUsername,
assigneeId,
search, search,
milestoneTitle, milestoneTitle,
iterationId, iterationId,
...@@ -63,6 +65,13 @@ export default { ...@@ -63,6 +65,13 @@ export default {
}); });
} }
if (assigneeId) {
filteredSearchValue.push({
type: 'assignee',
value: { data: assigneeId, operator: '=' },
});
}
if (types) { if (types) {
filteredSearchValue.push({ filteredSearchValue.push({
type: 'type', type: 'type',
...@@ -211,6 +220,7 @@ export default { ...@@ -211,6 +220,7 @@ export default {
authorUsername, authorUsername,
labelName, labelName,
assigneeUsername, assigneeUsername,
assigneeId,
search, search,
milestoneTitle, milestoneTitle,
types, types,
...@@ -246,6 +256,7 @@ export default { ...@@ -246,6 +256,7 @@ export default {
author_username: authorUsername, author_username: authorUsername,
'label_name[]': labelName, 'label_name[]': labelName,
assignee_username: assigneeUsername, assignee_username: assigneeUsername,
assignee_id: assigneeId,
milestone_title: milestoneTitle, milestone_title: milestoneTitle,
iteration_id: iterationId, iteration_id: iterationId,
search, search,
...@@ -295,7 +306,11 @@ export default { ...@@ -295,7 +306,11 @@ export default {
filterParams.authorUsername = filter.value.data; filterParams.authorUsername = filter.value.data;
break; break;
case 'assignee': case 'assignee':
if (Object.values(AssigneeFilterType).includes(filter.value.data)) {
filterParams.assigneeId = filter.value.data;
} else {
filterParams.assigneeUsername = filter.value.data; filterParams.assigneeUsername = filter.value.data;
}
break; break;
case 'type': case 'type':
filterParams.types = filter.value.data; filterParams.types = filter.value.data;
......
...@@ -119,6 +119,7 @@ export const FilterFields = { ...@@ -119,6 +119,7 @@ export const FilterFields = {
/* eslint-disable @gitlab/require-i18n-strings */ /* eslint-disable @gitlab/require-i18n-strings */
export const AssigneeFilterType = { export const AssigneeFilterType = {
any: 'Any', any: 'Any',
none: 'None',
}; };
export const MilestoneFilterType = { export const MilestoneFilterType = {
......
...@@ -4,7 +4,7 @@ import { compact } from 'lodash'; ...@@ -4,7 +4,7 @@ import { compact } from 'lodash';
import createFlash from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { DEFAULT_LABEL_ANY } from '../constants'; import { DEFAULT_NONE_ANY } from '../constants';
import BaseToken from './base_token.vue'; import BaseToken from './base_token.vue';
...@@ -36,7 +36,7 @@ export default { ...@@ -36,7 +36,7 @@ export default {
}, },
computed: { computed: {
defaultAuthors() { defaultAuthors() {
return this.config.defaultAuthors || [DEFAULT_LABEL_ANY]; return this.config.defaultAuthors || DEFAULT_NONE_ANY;
}, },
preloadedAuthors() { preloadedAuthors() {
return this.config.preloadedAuthors || []; return this.config.preloadedAuthors || [];
......
...@@ -34,7 +34,9 @@ RSpec.describe 'Issue board filters', :js do ...@@ -34,7 +34,9 @@ RSpec.describe 'Issue board filters', :js do
it 'and submit one as filter', :aggregate_failures do it 'and submit one as filter', :aggregate_failures do
expect(find('.board:nth-child(1)')).to have_selector('.board-card', count: 2) expect(find('.board:nth-child(1)')).to have_selector('.board-card', count: 2)
expect_filtered_search_dropdown_results(filter_dropdown, 3) wait_for_requests
expect_filtered_search_dropdown_results(filter_dropdown, 4)
click_on user.username click_on user.username
filter_submit.click filter_submit.click
......
...@@ -118,6 +118,7 @@ describe('BoardFilteredSearch', () => { ...@@ -118,6 +118,7 @@ describe('BoardFilteredSearch', () => {
it('sets the url params to the correct results', async () => { it('sets the url params to the correct results', async () => {
const mockFilters = [ const mockFilters = [
{ type: 'author', value: { data: 'root', operator: '=' } }, { type: 'author', value: { data: 'root', operator: '=' } },
{ type: 'assignee', value: { data: 'root', operator: '=' } },
{ type: 'label', value: { data: 'label', operator: '=' } }, { type: 'label', value: { data: 'label', operator: '=' } },
{ type: 'label', value: { data: 'label2', operator: '=' } }, { type: 'label', value: { data: 'label2', operator: '=' } },
{ type: 'milestone', value: { data: 'New Milestone', operator: '=' } }, { type: 'milestone', value: { data: 'New Milestone', operator: '=' } },
...@@ -133,7 +134,26 @@ describe('BoardFilteredSearch', () => { ...@@ -133,7 +134,26 @@ describe('BoardFilteredSearch', () => {
title: '', title: '',
replace: true, replace: true,
url: url:
'http://test.host/?author_username=root&label_name[]=label&label_name[]=label2&milestone_title=New+Milestone&iteration_id=3341&types=INCIDENT&weight=2&release_tag=v1.0.0', 'http://test.host/?author_username=root&label_name[]=label&label_name[]=label2&assignee_username=root&milestone_title=New+Milestone&iteration_id=3341&types=INCIDENT&weight=2&release_tag=v1.0.0',
});
});
describe('when assignee is passed a wildcard value', () => {
const url = (arg) => `http://test.host/?assignee_id=${arg}`;
it.each([
['None', url('None')],
['Any', url('Any')],
])('sets the url param %s', (assigneeParam, expected) => {
const mockFilters = [{ type: 'assignee', value: { data: assigneeParam, operator: '=' } }];
jest.spyOn(urlUtility, 'updateHistory');
findFilteredSearch().vm.$emit('onFilter', mockFilters);
expect(urlUtility.updateHistory).toHaveBeenCalledWith({
title: '',
replace: true,
url: expected,
});
}); });
}); });
}); });
......
...@@ -10,10 +10,7 @@ import waitForPromises from 'helpers/wait_for_promises'; ...@@ -10,10 +10,7 @@ import waitForPromises from 'helpers/wait_for_promises';
import createFlash from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { import { DEFAULT_NONE_ANY } from '~/vue_shared/components/filtered_search_bar/constants';
DEFAULT_LABEL_ANY,
DEFAULT_NONE_ANY,
} from '~/vue_shared/components/filtered_search_bar/constants';
import AuthorToken from '~/vue_shared/components/filtered_search_bar/tokens/author_token.vue'; import AuthorToken from '~/vue_shared/components/filtered_search_bar/tokens/author_token.vue';
import BaseToken from '~/vue_shared/components/filtered_search_bar/tokens/base_token.vue'; import BaseToken from '~/vue_shared/components/filtered_search_bar/tokens/base_token.vue';
...@@ -276,7 +273,7 @@ describe('AuthorToken', () => { ...@@ -276,7 +273,7 @@ describe('AuthorToken', () => {
expect(wrapper.find(GlDropdownDivider).exists()).toBe(false); expect(wrapper.find(GlDropdownDivider).exists()).toBe(false);
}); });
it('renders `DEFAULT_LABEL_ANY` as default suggestions', async () => { it('renders `DEFAULT_NONE_ANY` as default suggestions', async () => {
wrapper = createComponent({ wrapper = createComponent({
active: true, active: true,
config: { ...mockAuthorToken, preloadedAuthors: mockPreloadedAuthors }, config: { ...mockAuthorToken, preloadedAuthors: mockPreloadedAuthors },
...@@ -287,8 +284,9 @@ describe('AuthorToken', () => { ...@@ -287,8 +284,9 @@ describe('AuthorToken', () => {
const suggestions = wrapper.findAll(GlFilteredSearchSuggestion); const suggestions = wrapper.findAll(GlFilteredSearchSuggestion);
expect(suggestions).toHaveLength(1 + currentUserLength); expect(suggestions).toHaveLength(2 + currentUserLength);
expect(suggestions.at(0).text()).toBe(DEFAULT_LABEL_ANY.text); expect(suggestions.at(0).text()).toBe(DEFAULT_NONE_ANY[0].text);
expect(suggestions.at(1).text()).toBe(DEFAULT_NONE_ANY[1].text);
}); });
it('emits listeners in the base-token', () => { it('emits listeners in the base-token', () => {
......
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