in ee/app/assets/javascripts/roadmap/mixins/filtered_search_mixin.js [108:263]
getFilteredSearchTokens({ supportsEpic = true } = {}) {
let preloadedUsers = [];
if (gon.current_user_id) {
preloadedUsers = [
{
id: gon.current_user_id,
name: gon.current_user_fullname,
username: gon.current_username,
avatar_url: gon.current_user_avatar_url,
},
];
}
const tokens = [
{
type: TOKEN_TYPE_AUTHOR,
icon: 'user',
title: TOKEN_TITLE_AUTHOR,
unique: false,
symbol: '@',
token: UserToken,
operators: OPERATORS_IS_NOT_OR,
recentSuggestionsStorageKey: `${this.groupFullPath}-epics-recent-tokens-author_username`,
fetchUsers: Api.users.bind(Api),
defaultUsers: [],
preloadedUsers,
},
{
type: TOKEN_TYPE_LABEL,
icon: 'labels',
title: TOKEN_TITLE_LABEL,
unique: false,
symbol: '~',
token: LabelToken,
operators: OPERATORS_IS_NOT_OR,
recentSuggestionsStorageKey: `${this.groupFullPath}-epics-recent-tokens-label_name`,
fetchLabels: (search = '') => {
const params = {
only_group_labels: true,
include_ancestor_groups: true,
include_descendant_groups: true,
};
if (search) {
params.search = search;
}
return Api.groupLabels(encodeURIComponent(this.groupFullPath), {
params,
});
},
},
{
type: TOKEN_TYPE_MILESTONE,
icon: 'milestone',
title: TOKEN_TITLE_MILESTONE,
unique: true,
symbol: '%',
token: MilestoneToken,
operators: OPERATORS_IS,
defaultMilestones: [], // TODO: Add support for wildcards once https://gitlab.com/gitlab-org/gitlab/-/issues/356756 is resolved
fetchMilestones: (search = '') => {
return axios.get(this.groupMilestonesPath).then(({ data }) => {
// TODO: Remove below condition check once either of the following is supported.
// a) Milestones Private API supports search param.
// b) Milestones Public API supports including child projects' milestones.
if (search) {
return {
data: data.filter((m) => m.title.toLowerCase().includes(search.toLowerCase())),
};
}
return { data };
});
},
},
{
type: TOKEN_TYPE_CONFIDENTIAL,
icon: 'eye-slash',
title: TOKEN_TITLE_CONFIDENTIAL,
unique: true,
token: GlFilteredSearchToken,
operators: OPERATORS_IS,
options: [
{ icon: 'eye-slash', value: true, title: __('Yes') },
{ icon: 'eye', value: false, title: __('No') },
],
},
{
type: TOKEN_TYPE_GROUP,
icon: 'group',
title: TOKEN_TITLE_GROUP,
unique: true,
token: GroupToken,
operators: OPERATORS_IS,
fullPath: this.groupFullPath,
},
];
if (supportsEpic) {
tokens.push({
type: TOKEN_TYPE_EPIC,
icon: 'epic',
title: TOKEN_TITLE_EPIC,
unique: true,
idProperty: 'iid',
useIdValue: true,
symbol: '&',
token: EpicToken,
operators: OPERATORS_IS,
recentSuggestionsStorageKey: `${this.groupFullPath}-epics-recent-tokens-epic_iid`,
fullPath: this.groupFullPath,
});
}
if (gon.current_user_id) {
// Appending to tokens only when logged-in
tokens.push({
type: TOKEN_TYPE_MY_REACTION,
icon: 'thumb-up',
title: TOKEN_TITLE_MY_REACTION,
unique: true,
token: EmojiToken,
operators: OPERATORS_IS_NOT,
fetchEmojis: (search = '') => {
return axios
.get(`${gon.relative_url_root || ''}/-/autocomplete/award_emojis`)
.then(({ data }) => {
if (search) {
return {
data: data.filter((e) => e.name.toLowerCase().includes(search.toLowerCase())),
};
}
return { data };
});
},
});
}
if (this.hasCustomFieldsFeature) {
this.customFields.forEach((field) => {
tokens.push({
type: `${TOKEN_TYPE_CUSTOM_FIELD}[${getIdFromGraphQLId(field.id)}]`,
title: field.name,
icon: 'multiple-choice',
field,
fullPath: this.groupFullPath,
token: CustomFieldToken,
operators: OPERATORS_IS,
unique: true,
});
});
}
return orderBy(tokens, ['title']);
},