2021-03-11 19:13:27 +05:30
|
|
|
<script>
|
2022-05-07 20:08:51 +05:30
|
|
|
import { GlSearchBoxByClick } from '@gitlab/ui';
|
2021-03-11 19:13:27 +05:30
|
|
|
import { mapState, mapActions } from 'vuex';
|
2022-05-07 20:08:51 +05:30
|
|
|
import { s__ } from '~/locale';
|
2021-03-11 19:13:27 +05:30
|
|
|
import GroupFilter from './group_filter.vue';
|
|
|
|
import ProjectFilter from './project_filter.vue';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'GlobalSearchTopbar',
|
2022-05-07 20:08:51 +05:30
|
|
|
i18n: {
|
|
|
|
searchPlaceholder: s__(`GlobalSearch|Search for projects, issues, etc.`),
|
|
|
|
searchLabel: s__(`GlobalSearch|What are you searching for?`),
|
|
|
|
},
|
2021-03-11 19:13:27 +05:30
|
|
|
components: {
|
2022-05-07 20:08:51 +05:30
|
|
|
GlSearchBoxByClick,
|
2021-03-11 19:13:27 +05:30
|
|
|
GroupFilter,
|
|
|
|
ProjectFilter,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
groupInitialData: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
|
|
|
projectInitialData: {
|
|
|
|
type: Object,
|
|
|
|
required: false,
|
|
|
|
default: () => ({}),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapState(['query']),
|
|
|
|
search: {
|
|
|
|
get() {
|
|
|
|
return this.query ? this.query.search : '';
|
|
|
|
},
|
|
|
|
set(value) {
|
|
|
|
this.setQuery({ key: 'search', value });
|
|
|
|
},
|
|
|
|
},
|
|
|
|
showFilters() {
|
|
|
|
return !this.query.snippets || this.query.snippets === 'false';
|
|
|
|
},
|
|
|
|
},
|
2021-10-27 15:23:28 +05:30
|
|
|
created() {
|
|
|
|
this.preloadStoredFrequentItems();
|
|
|
|
},
|
2021-03-11 19:13:27 +05:30
|
|
|
methods: {
|
2021-10-27 15:23:28 +05:30
|
|
|
...mapActions(['applyQuery', 'setQuery', 'preloadStoredFrequentItems']),
|
2021-03-11 19:13:27 +05:30
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2022-05-07 20:08:51 +05:30
|
|
|
<section class="search-page-form gl-lg-display-flex gl-align-items-flex-end">
|
|
|
|
<div class="gl-flex-grow-1 gl-mb-4 gl-lg-mb-0 gl-lg-mr-2">
|
|
|
|
<label>{{ $options.i18n.searchLabel }}</label>
|
|
|
|
<gl-search-box-by-click
|
|
|
|
id="dashboard_search"
|
|
|
|
v-model="search"
|
|
|
|
name="search"
|
|
|
|
:placeholder="$options.i18n.searchPlaceholder"
|
|
|
|
@submit="applyQuery"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div v-if="showFilters" class="gl-mb-4 gl-lg-mb-0 gl-lg-mx-2">
|
|
|
|
<label class="gl-display-block">{{ __('Group') }}</label>
|
|
|
|
<group-filter :initial-data="groupInitialData" />
|
|
|
|
</div>
|
|
|
|
<div v-if="showFilters" class="gl-mb-4 gl-lg-mb-0 gl-lg-mx-2">
|
|
|
|
<label class="gl-display-block">{{ __('Project') }}</label>
|
|
|
|
<project-filter :initial-data="projectInitialData" />
|
|
|
|
</div>
|
|
|
|
</section>
|
2021-03-11 19:13:27 +05:30
|
|
|
</template>
|