Commit 1495c665 authored by Scott Stern's avatar Scott Stern Committed by Natalia Tepluhina

Add weight token to issue board filtered search

parent 187fe7d4
...@@ -34,6 +34,7 @@ export default { ...@@ -34,6 +34,7 @@ export default {
search, search,
milestoneTitle, milestoneTitle,
types, types,
weight,
} = this.filterParams; } = this.filterParams;
let notParams = {}; let notParams = {};
...@@ -45,6 +46,7 @@ export default { ...@@ -45,6 +46,7 @@ export default {
'not[assignee_username]': this.filterParams.not.assigneeUsername, 'not[assignee_username]': this.filterParams.not.assigneeUsername,
'not[types]': this.filterParams.not.types, 'not[types]': this.filterParams.not.types,
'not[milestone_title]': this.filterParams.not.milestoneTitle, 'not[milestone_title]': this.filterParams.not.milestoneTitle,
'not[weight]': this.filterParams.not.weight,
}, },
undefined, undefined,
); );
...@@ -58,6 +60,7 @@ export default { ...@@ -58,6 +60,7 @@ export default {
milestone_title: milestoneTitle, milestone_title: milestoneTitle,
search, search,
types, types,
weight,
}; };
}, },
}, },
...@@ -82,6 +85,7 @@ export default { ...@@ -82,6 +85,7 @@ export default {
search, search,
milestoneTitle, milestoneTitle,
types, types,
weight,
} = this.filterParams; } = this.filterParams;
const filteredSearchValue = []; const filteredSearchValue = [];
...@@ -122,6 +126,13 @@ export default { ...@@ -122,6 +126,13 @@ export default {
}); });
} }
if (weight) {
filteredSearchValue.push({
type: 'weight',
value: { data: weight, operator: '=' },
});
}
if (this.filterParams['not[authorUsername]']) { if (this.filterParams['not[authorUsername]']) {
filteredSearchValue.push({ filteredSearchValue.push({
type: 'author_username', type: 'author_username',
...@@ -136,6 +147,13 @@ export default { ...@@ -136,6 +147,13 @@ export default {
}); });
} }
if (this.filterParams['not[weight]']) {
filteredSearchValue.push({
type: 'weight',
value: { data: this.filterParams['not[weight]'], operator: '!=' },
});
}
if (this.filterParams['not[assigneeUsername]']) { if (this.filterParams['not[assigneeUsername]']) {
filteredSearchValue.push({ filteredSearchValue.push({
type: 'assignee_username', type: 'assignee_username',
...@@ -195,6 +213,9 @@ export default { ...@@ -195,6 +213,9 @@ export default {
case 'milestone_title': case 'milestone_title':
filterParams.milestoneTitle = filter.value.data; filterParams.milestoneTitle = filter.value.data;
break; break;
case 'weight':
filterParams.weight = filter.value.data;
break;
case 'filtered-search-term': case 'filtered-search-term':
if (filter.value.data) plainText.push(filter.value.data); if (filter.value.data) plainText.push(filter.value.data);
break; break;
......
...@@ -9,6 +9,7 @@ import { __ } from '~/locale'; ...@@ -9,6 +9,7 @@ import { __ } from '~/locale';
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 LabelToken from '~/vue_shared/components/filtered_search_bar/tokens/label_token.vue'; import LabelToken from '~/vue_shared/components/filtered_search_bar/tokens/label_token.vue';
import MilestoneToken from '~/vue_shared/components/filtered_search_bar/tokens/milestone_token.vue'; import MilestoneToken from '~/vue_shared/components/filtered_search_bar/tokens/milestone_token.vue';
import WeightToken from '~/vue_shared/components/filtered_search_bar/tokens/weight_token.vue';
export default { export default {
types: { types: {
...@@ -24,6 +25,7 @@ export default { ...@@ -24,6 +25,7 @@ export default {
incident: __('Incident'), incident: __('Incident'),
issue: __('Issue'), issue: __('Issue'),
milestone: __('Milestone'), milestone: __('Milestone'),
weight: __('Weight'),
is: __('is'), is: __('is'),
isNot: __('is not'), isNot: __('is not'),
}, },
...@@ -50,6 +52,7 @@ export default { ...@@ -50,6 +52,7 @@ export default {
incident, incident,
type, type,
milestone, milestone,
weight,
} = this.$options.i18n; } = this.$options.i18n;
const { types } = this.$options; const { types } = this.$options;
const { fetchAuthors, fetchLabels } = issueBoardFilters( const { fetchAuthors, fetchLabels } = issueBoardFilters(
...@@ -121,6 +124,13 @@ export default { ...@@ -121,6 +124,13 @@ export default {
defaultMilestones: [], // todo: https://gitlab.com/gitlab-org/gitlab/-/issues/337044#note_640010094 defaultMilestones: [], // todo: https://gitlab.com/gitlab-org/gitlab/-/issues/337044#note_640010094
fetchMilestones: this.fetchMilestones, fetchMilestones: this.fetchMilestones,
}, },
{
type: 'weight',
title: weight,
icon: 'weight',
token: WeightToken,
unique: true,
},
]; ];
}, },
}, },
......
...@@ -110,6 +110,7 @@ export const FilterFields = { ...@@ -110,6 +110,7 @@ export const FilterFields = {
'releaseTag', 'releaseTag',
'search', 'search',
'types', 'types',
'weight',
], ],
}; };
......
...@@ -117,6 +117,7 @@ describe('BoardFilteredSearch', () => { ...@@ -117,6 +117,7 @@ describe('BoardFilteredSearch', () => {
{ type: 'label_name', value: { data: 'label2', operator: '=' } }, { type: 'label_name', value: { data: 'label2', operator: '=' } },
{ type: 'milestone_title', value: { data: 'New Milestone', operator: '=' } }, { type: 'milestone_title', value: { data: 'New Milestone', operator: '=' } },
{ type: 'types', value: { data: 'INCIDENT', operator: '=' } }, { type: 'types', value: { data: 'INCIDENT', operator: '=' } },
{ type: 'weight', value: { data: '2', operator: '=' } },
]; ];
jest.spyOn(urlUtility, 'updateHistory'); jest.spyOn(urlUtility, 'updateHistory');
findFilteredSearch().vm.$emit('onFilter', mockFilters); findFilteredSearch().vm.$emit('onFilter', mockFilters);
...@@ -125,7 +126,7 @@ describe('BoardFilteredSearch', () => { ...@@ -125,7 +126,7 @@ 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&types=INCIDENT', 'http://test.host/?author_username=root&label_name[]=label&label_name[]=label2&milestone_title=New+Milestone&types=INCIDENT&weight=2',
}); });
}); });
}); });
......
...@@ -10,6 +10,7 @@ import { __ } from '~/locale'; ...@@ -10,6 +10,7 @@ import { __ } from '~/locale';
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 LabelToken from '~/vue_shared/components/filtered_search_bar/tokens/label_token.vue'; import LabelToken from '~/vue_shared/components/filtered_search_bar/tokens/label_token.vue';
import MilestoneToken from '~/vue_shared/components/filtered_search_bar/tokens/milestone_token.vue'; import MilestoneToken from '~/vue_shared/components/filtered_search_bar/tokens/milestone_token.vue';
import WeightToken from '~/vue_shared/components/filtered_search_bar/tokens/weight_token.vue';
export const boardObj = { export const boardObj = {
id: 1, id: 1,
...@@ -607,4 +608,11 @@ export const mockTokens = (fetchLabels, fetchAuthors, fetchMilestones) => [ ...@@ -607,4 +608,11 @@ export const mockTokens = (fetchLabels, fetchAuthors, fetchMilestones) => [
defaultMilestones: [], defaultMilestones: [],
fetchMilestones, fetchMilestones,
}, },
{
icon: 'weight',
title: __('Weight'),
type: 'weight',
token: WeightToken,
unique: true,
},
]; ];
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