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