Commit 2b9a731b authored by Kushal Pandya's avatar Kushal Pandya

Hide `None` & `Any` token wildcards

Hides `None` & `Any` token wildcards for
Author and Milestone tokens in Epics filtering.

Changelog: changed
EE: true
parent 6970412c
...@@ -23,9 +23,19 @@ export const DEFAULT_LABEL_NONE = { value: FILTER_NONE, text: __('None'), title: ...@@ -23,9 +23,19 @@ export const DEFAULT_LABEL_NONE = { value: FILTER_NONE, text: __('None'), title:
export const DEFAULT_LABEL_ANY = { value: FILTER_ANY, text: __('Any'), title: __('Any') }; export const DEFAULT_LABEL_ANY = { value: FILTER_ANY, text: __('Any'), title: __('Any') };
export const DEFAULT_NONE_ANY = [DEFAULT_LABEL_NONE, DEFAULT_LABEL_ANY]; export const DEFAULT_NONE_ANY = [DEFAULT_LABEL_NONE, DEFAULT_LABEL_ANY];
export const DEFAULT_MILESTONE_UPCOMING = {
value: FILTER_UPCOMING,
text: __('Upcoming'),
title: __('Upcoming'),
};
export const DEFAULT_MILESTONE_STARTED = {
value: FILTER_STARTED,
text: __('Started'),
title: __('Started'),
};
export const DEFAULT_MILESTONES = DEFAULT_NONE_ANY.concat([ export const DEFAULT_MILESTONES = DEFAULT_NONE_ANY.concat([
{ value: FILTER_UPCOMING, text: __('Upcoming'), title: __('Upcoming') }, DEFAULT_MILESTONE_UPCOMING,
{ value: FILTER_STARTED, text: __('Started'), title: __('Started') }, DEFAULT_MILESTONE_STARTED,
]); ]);
export const SortDirection = { export const SortDirection = {
......
...@@ -163,19 +163,22 @@ export default { ...@@ -163,19 +163,22 @@ export default {
}, },
}, },
methods: { methods: {
handleInput: debounce(function debouncedSearch({ data }) { handleInput: debounce(function debouncedSearch({ data, operator }) {
this.searchKey = data; // Prevent fetching suggestions when data or operator is not present
if (data || operator) {
this.searchKey = data;
if (!this.suggestionsLoading && !this.activeTokenValue) { if (!this.suggestionsLoading && !this.activeTokenValue) {
let search = this.searchTerm ? this.searchTerm : data; let search = this.searchTerm ? this.searchTerm : data;
if (search.startsWith('"') && search.endsWith('"')) { if (search.startsWith('"') && search.endsWith('"')) {
search = stripQuotes(search); search = stripQuotes(search);
} else if (search.startsWith('"')) { } else if (search.startsWith('"')) {
search = search.slice(1, search.length); search = search.slice(1, search.length);
} }
this.$emit('fetch-suggestions', search); this.$emit('fetch-suggestions', search);
}
} }
}, DEBOUNCE_DELAY), }, DEBOUNCE_DELAY),
handleTokenValueSelected(selectedValue) { handleTokenValueSelected(selectedValue) {
......
...@@ -9,6 +9,8 @@ import { ...@@ -9,6 +9,8 @@ import {
OPERATOR_IS_NOT, OPERATOR_IS_NOT,
OPERATOR_IS, OPERATOR_IS,
OPERATOR_IS_AND_IS_NOT, OPERATOR_IS_AND_IS_NOT,
DEFAULT_MILESTONE_UPCOMING,
DEFAULT_MILESTONE_STARTED,
} from '~/vue_shared/components/filtered_search_bar/constants'; } 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 EmojiToken from '~/vue_shared/components/filtered_search_bar/tokens/emoji_token.vue'; import EmojiToken from '~/vue_shared/components/filtered_search_bar/tokens/emoji_token.vue';
...@@ -80,6 +82,7 @@ export default { ...@@ -80,6 +82,7 @@ export default {
operators: OPERATOR_IS_AND_IS_NOT, operators: OPERATOR_IS_AND_IS_NOT,
recentSuggestionsStorageKey: `${this.groupFullPath}-epics-recent-tokens-author_username`, recentSuggestionsStorageKey: `${this.groupFullPath}-epics-recent-tokens-author_username`,
fetchAuthors: Api.users.bind(Api), fetchAuthors: Api.users.bind(Api),
defaultAuthors: [],
preloadedAuthors, preloadedAuthors,
}, },
{ {
...@@ -115,6 +118,7 @@ export default { ...@@ -115,6 +118,7 @@ export default {
symbol: '%', symbol: '%',
token: MilestoneToken, token: MilestoneToken,
operators: OPERATOR_IS_ONLY, operators: OPERATOR_IS_ONLY,
defaultMilestones: [DEFAULT_MILESTONE_UPCOMING, DEFAULT_MILESTONE_STARTED],
fetchMilestones: (search = '') => { fetchMilestones: (search = '') => {
return axios.get(this.groupMilestonesPath).then(({ data }) => { return axios.get(this.groupMilestonesPath).then(({ data }) => {
// TODO: Remove below condition check once either of the following is supported. // TODO: Remove below condition check once either of the following is supported.
......
...@@ -801,6 +801,7 @@ export const mockAuthorTokenConfig = { ...@@ -801,6 +801,7 @@ export const mockAuthorTokenConfig = {
recentSuggestionsStorageKey: 'gitlab-org-epics-recent-tokens-author_username', recentSuggestionsStorageKey: 'gitlab-org-epics-recent-tokens-author_username',
fetchAuthors: expect.any(Function), fetchAuthors: expect.any(Function),
preloadedAuthors: [], preloadedAuthors: [],
defaultAuthors: [],
}; };
export const mockLabelTokenConfig = { export const mockLabelTokenConfig = {
...@@ -824,6 +825,7 @@ export const mockMilestoneTokenConfig = { ...@@ -824,6 +825,7 @@ export const mockMilestoneTokenConfig = {
token: MilestoneToken, token: MilestoneToken,
operators: OPERATOR_IS_ONLY, operators: OPERATOR_IS_ONLY,
fetchMilestones: expect.any(Function), fetchMilestones: expect.any(Function),
defaultMilestones: expect.any(Array),
}; };
export const mockConfidentialTokenConfig = { export const mockConfidentialTokenConfig = {
......
...@@ -4,14 +4,14 @@ require 'spec_helper' ...@@ -4,14 +4,14 @@ require 'spec_helper'
RSpec.shared_examples 'filtered search bar' do |tokens| RSpec.shared_examples 'filtered search bar' do |tokens|
minimum_values_for_token = { minimum_values_for_token = {
# Count must be at least 3 as `Any` & current user are available by default # Count must be at least 2 as current user are available by default
"Author" => 3, "Author" => 2,
# Count must be at least 3 as `None` & `Any` are available by default # Count must be at least 3 as `None` & `Any` are available by default
"Label" => 3, "Label" => 3,
# Count must be at least 5 as `None`, `Any`, `Upcoming` & `Started` are available by default # Count must be at least 3 as `Upcoming` & `Started` are available by default
"Milestone" => 5, "Milestone" => 3,
# Count must be at least 1 # Count must be at least 1
"Epic" => 1, "Epic" => 1,
......
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