2021-03-11 19:13:27 +05:30
|
|
|
<script>
|
|
|
|
import { GlForm, GlSearchBoxByType, GlButton } from '@gitlab/ui';
|
|
|
|
import { mapState, mapActions } from 'vuex';
|
|
|
|
import GroupFilter from './group_filter.vue';
|
|
|
|
import ProjectFilter from './project_filter.vue';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'GlobalSearchTopbar',
|
|
|
|
components: {
|
|
|
|
GlForm,
|
|
|
|
GlSearchBoxByType,
|
|
|
|
GroupFilter,
|
|
|
|
ProjectFilter,
|
|
|
|
GlButton,
|
|
|
|
},
|
|
|
|
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';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
...mapActions(['applyQuery', 'setQuery']),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<gl-form class="search-page-form" @submit.prevent="applyQuery">
|
|
|
|
<section class="gl-lg-display-flex gl-align-items-flex-end">
|
2021-09-04 01:27:46 +05:30
|
|
|
<div class="gl-flex-grow-1 gl-mb-4 gl-lg-mb-0 gl-lg-mr-2">
|
2021-03-11 19:13:27 +05:30
|
|
|
<label>{{ __('What are you searching for?') }}</label>
|
|
|
|
<gl-search-box-by-type
|
|
|
|
id="dashboard_search"
|
|
|
|
v-model="search"
|
|
|
|
name="search"
|
|
|
|
:placeholder="__(`Search for projects, issues, etc.`)"
|
|
|
|
/>
|
|
|
|
</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>
|
2021-04-29 21:17:54 +05:30
|
|
|
<gl-button class="btn-search gl-lg-ml-2" category="primary" variant="confirm" type="submit"
|
|
|
|
>{{ __('Search') }}
|
|
|
|
</gl-button>
|
2021-03-11 19:13:27 +05:30
|
|
|
</section>
|
|
|
|
</gl-form>
|
|
|
|
</template>
|