Commit 765884f5 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'kp-hide-wildcard-values-for-author-milestone-tokens' into 'master'

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

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