2021-09-30 23:02:18 +05:30
|
|
|
<script>
|
2021-10-27 15:23:28 +05:30
|
|
|
import { GlFilteredSearchToken } from '@gitlab/ui';
|
2021-12-11 22:18:48 +05:30
|
|
|
import fuzzaldrinPlus from 'fuzzaldrin-plus';
|
2021-10-27 15:23:28 +05:30
|
|
|
import { mapActions } from 'vuex';
|
2022-01-26 12:08:38 +05:30
|
|
|
import { orderBy } from 'lodash';
|
2021-12-11 22:18:48 +05:30
|
|
|
import BoardFilteredSearch from 'ee_else_ce/boards/components/board_filtered_search.vue';
|
|
|
|
import { BoardType } from '~/boards/constants';
|
|
|
|
import axios from '~/lib/utils/axios_utils';
|
2022-01-26 12:08:38 +05:30
|
|
|
import { joinPaths } from '~/lib/utils/url_utility';
|
2021-09-30 23:02:18 +05:30
|
|
|
import issueBoardFilters from '~/boards/issue_board_filters';
|
|
|
|
import { TYPE_USER } from '~/graphql_shared/constants';
|
|
|
|
import { convertToGraphQLId } from '~/graphql_shared/utils';
|
|
|
|
import { __ } from '~/locale';
|
2021-12-11 22:18:48 +05:30
|
|
|
import {
|
|
|
|
TOKEN_TITLE_MY_REACTION,
|
2022-01-26 12:08:38 +05:30
|
|
|
OPERATOR_IS_AND_IS_NOT,
|
|
|
|
OPERATOR_IS_ONLY,
|
2021-12-11 22:18:48 +05:30
|
|
|
} from '~/vue_shared/components/filtered_search_bar/constants';
|
2021-09-30 23:02:18 +05:30
|
|
|
import AuthorToken from '~/vue_shared/components/filtered_search_bar/tokens/author_token.vue';
|
2021-12-11 22:18:48 +05:30
|
|
|
import EmojiToken from '~/vue_shared/components/filtered_search_bar/tokens/emoji_token.vue';
|
2021-09-30 23:02:18 +05:30
|
|
|
import LabelToken from '~/vue_shared/components/filtered_search_bar/tokens/label_token.vue';
|
2021-10-27 15:23:28 +05:30
|
|
|
import MilestoneToken from '~/vue_shared/components/filtered_search_bar/tokens/milestone_token.vue';
|
2022-01-26 12:08:38 +05:30
|
|
|
import ReleaseToken from '~/vue_shared/components/filtered_search_bar/tokens/release_token.vue';
|
2021-09-30 23:02:18 +05:30
|
|
|
|
|
|
|
export default {
|
2021-10-27 15:23:28 +05:30
|
|
|
types: {
|
|
|
|
ISSUE: 'ISSUE',
|
|
|
|
INCIDENT: 'INCIDENT',
|
|
|
|
},
|
2021-09-30 23:02:18 +05:30
|
|
|
i18n: {
|
|
|
|
search: __('Search'),
|
2021-12-11 22:18:48 +05:30
|
|
|
epic: __('Epic'),
|
2021-09-30 23:02:18 +05:30
|
|
|
label: __('Label'),
|
|
|
|
author: __('Author'),
|
|
|
|
assignee: __('Assignee'),
|
2021-10-27 15:23:28 +05:30
|
|
|
type: __('Type'),
|
|
|
|
incident: __('Incident'),
|
|
|
|
issue: __('Issue'),
|
|
|
|
milestone: __('Milestone'),
|
2022-01-26 12:08:38 +05:30
|
|
|
release: __('Release'),
|
|
|
|
confidential: __('Confidential'),
|
2021-09-30 23:02:18 +05:30
|
|
|
},
|
|
|
|
components: { BoardFilteredSearch },
|
2022-01-26 12:08:38 +05:30
|
|
|
inject: ['isSignedIn', 'releasesFetchPath'],
|
2021-09-30 23:02:18 +05:30
|
|
|
props: {
|
|
|
|
fullPath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
boardType: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
2021-12-11 22:18:48 +05:30
|
|
|
isGroupBoard() {
|
|
|
|
return this.boardType === BoardType.group;
|
|
|
|
},
|
|
|
|
epicsGroupPath() {
|
|
|
|
return this.isGroupBoard
|
|
|
|
? this.fullPath
|
|
|
|
: this.fullPath.slice(0, this.fullPath.lastIndexOf('/'));
|
|
|
|
},
|
|
|
|
tokensCE() {
|
2021-10-27 15:23:28 +05:30
|
|
|
const {
|
|
|
|
label,
|
|
|
|
author,
|
|
|
|
assignee,
|
|
|
|
issue,
|
|
|
|
incident,
|
|
|
|
type,
|
|
|
|
milestone,
|
2022-01-26 12:08:38 +05:30
|
|
|
release,
|
|
|
|
confidential,
|
2021-10-27 15:23:28 +05:30
|
|
|
} = this.$options.i18n;
|
|
|
|
const { types } = this.$options;
|
2021-09-30 23:02:18 +05:30
|
|
|
const { fetchAuthors, fetchLabels } = issueBoardFilters(
|
|
|
|
this.$apollo,
|
|
|
|
this.fullPath,
|
|
|
|
this.boardType,
|
|
|
|
);
|
|
|
|
|
2022-01-26 12:08:38 +05:30
|
|
|
const tokens = [
|
2021-09-30 23:02:18 +05:30
|
|
|
{
|
2021-11-11 11:23:49 +05:30
|
|
|
icon: 'user',
|
|
|
|
title: assignee,
|
2022-01-26 12:08:38 +05:30
|
|
|
type: 'assignee',
|
|
|
|
operators: OPERATOR_IS_AND_IS_NOT,
|
2021-11-11 11:23:49 +05:30
|
|
|
token: AuthorToken,
|
|
|
|
unique: true,
|
|
|
|
fetchAuthors,
|
|
|
|
preloadedAuthors: this.preloadedAuthors(),
|
2021-09-30 23:02:18 +05:30
|
|
|
},
|
|
|
|
{
|
|
|
|
icon: 'pencil',
|
|
|
|
title: author,
|
2022-01-26 12:08:38 +05:30
|
|
|
type: 'author',
|
|
|
|
operators: OPERATOR_IS_AND_IS_NOT,
|
2021-09-30 23:02:18 +05:30
|
|
|
symbol: '@',
|
|
|
|
token: AuthorToken,
|
|
|
|
unique: true,
|
|
|
|
fetchAuthors,
|
|
|
|
preloadedAuthors: this.preloadedAuthors(),
|
|
|
|
},
|
|
|
|
{
|
2021-11-11 11:23:49 +05:30
|
|
|
icon: 'labels',
|
|
|
|
title: label,
|
2022-01-26 12:08:38 +05:30
|
|
|
type: 'label',
|
|
|
|
operators: OPERATOR_IS_AND_IS_NOT,
|
2021-11-11 11:23:49 +05:30
|
|
|
token: LabelToken,
|
|
|
|
unique: false,
|
|
|
|
symbol: '~',
|
|
|
|
fetchLabels,
|
|
|
|
},
|
2021-12-11 22:18:48 +05:30
|
|
|
...(this.isSignedIn
|
|
|
|
? [
|
|
|
|
{
|
2022-01-26 12:08:38 +05:30
|
|
|
type: 'my-reaction',
|
2021-12-11 22:18:48 +05:30
|
|
|
title: TOKEN_TITLE_MY_REACTION,
|
|
|
|
icon: 'thumb-up',
|
|
|
|
token: EmojiToken,
|
|
|
|
unique: true,
|
|
|
|
fetchEmojis: (search = '') => {
|
|
|
|
// TODO: Switch to GraphQL query when backend is ready: https://gitlab.com/gitlab-org/gitlab/-/issues/339694
|
|
|
|
return axios
|
|
|
|
.get(`${gon.relative_url_root || ''}/-/autocomplete/award_emojis`)
|
|
|
|
.then(({ data }) => {
|
|
|
|
if (search) {
|
|
|
|
return {
|
|
|
|
data: fuzzaldrinPlus.filter(data, search, {
|
|
|
|
key: ['name'],
|
|
|
|
}),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return { data };
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
2022-01-26 12:08:38 +05:30
|
|
|
{
|
|
|
|
type: 'confidential',
|
|
|
|
icon: 'eye-slash',
|
|
|
|
title: confidential,
|
|
|
|
unique: true,
|
|
|
|
token: GlFilteredSearchToken,
|
|
|
|
operators: OPERATOR_IS_ONLY,
|
|
|
|
options: [
|
|
|
|
{ icon: 'eye-slash', value: 'yes', title: __('Yes') },
|
|
|
|
{ icon: 'eye', value: 'no', title: __('No') },
|
|
|
|
],
|
|
|
|
},
|
2021-12-11 22:18:48 +05:30
|
|
|
]
|
|
|
|
: []),
|
2021-11-11 11:23:49 +05:30
|
|
|
{
|
2022-01-26 12:08:38 +05:30
|
|
|
type: 'milestone',
|
2021-11-11 11:23:49 +05:30
|
|
|
title: milestone,
|
|
|
|
icon: 'clock',
|
|
|
|
symbol: '%',
|
|
|
|
token: MilestoneToken,
|
2021-09-30 23:02:18 +05:30
|
|
|
unique: true,
|
2022-04-04 11:22:00 +05:30
|
|
|
shouldSkipSort: true,
|
2021-11-11 11:23:49 +05:30
|
|
|
fetchMilestones: this.fetchMilestones,
|
2021-09-30 23:02:18 +05:30
|
|
|
},
|
2021-10-27 15:23:28 +05:30
|
|
|
{
|
|
|
|
icon: 'issues',
|
|
|
|
title: type,
|
2022-01-26 12:08:38 +05:30
|
|
|
type: 'type',
|
2021-10-27 15:23:28 +05:30
|
|
|
token: GlFilteredSearchToken,
|
|
|
|
unique: true,
|
|
|
|
options: [
|
|
|
|
{ icon: 'issue-type-issue', value: types.ISSUE, title: issue },
|
|
|
|
{ icon: 'issue-type-incident', value: types.INCIDENT, title: incident },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2022-01-26 12:08:38 +05:30
|
|
|
type: 'release',
|
|
|
|
title: release,
|
|
|
|
icon: 'rocket',
|
|
|
|
token: ReleaseToken,
|
|
|
|
fetchReleases: (search) => {
|
|
|
|
// TODO: Switch to GraphQL query when backend is ready: https://gitlab.com/gitlab-org/gitlab/-/issues/337686
|
|
|
|
return axios
|
|
|
|
.get(joinPaths(gon.relative_url_root, this.releasesFetchPath))
|
|
|
|
.then(({ data }) => {
|
|
|
|
if (search) {
|
|
|
|
return fuzzaldrinPlus.filter(data, search, {
|
|
|
|
key: ['tag'],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
});
|
|
|
|
},
|
2021-10-27 15:23:28 +05:30
|
|
|
},
|
2021-09-30 23:02:18 +05:30
|
|
|
];
|
2022-01-26 12:08:38 +05:30
|
|
|
|
|
|
|
return orderBy(tokens, ['title']);
|
2021-09-30 23:02:18 +05:30
|
|
|
},
|
2021-12-11 22:18:48 +05:30
|
|
|
tokens() {
|
|
|
|
return this.tokensCE;
|
|
|
|
},
|
2021-09-30 23:02:18 +05:30
|
|
|
},
|
|
|
|
methods: {
|
2021-10-27 15:23:28 +05:30
|
|
|
...mapActions(['fetchMilestones']),
|
2021-09-30 23:02:18 +05:30
|
|
|
preloadedAuthors() {
|
|
|
|
return gon?.current_user_id
|
|
|
|
? [
|
|
|
|
{
|
|
|
|
id: convertToGraphQLId(TYPE_USER, gon.current_user_id),
|
|
|
|
name: gon.current_user_fullname,
|
|
|
|
username: gon.current_username,
|
|
|
|
avatarUrl: gon.current_user_avatar_url,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
: [];
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<board-filtered-search data-testid="issue-board-filtered-search" :tokens="tokens" />
|
|
|
|
</template>
|