2018-07-06 13:40:11 +00:00
|
|
|
<script>
|
2021-02-14 18:09:20 +00:00
|
|
|
import { GlSearchBoxByType } from '@gitlab/ui';
|
2020-02-20 09:09:13 +00:00
|
|
|
import { debounce } from 'lodash';
|
2021-05-06 00:10:32 +00:00
|
|
|
import { mapVuexModuleActions, mapVuexModuleState } from '~/lib/utils/vuex_module_mappers';
|
2021-02-01 15:08:56 +00:00
|
|
|
import Tracking from '~/tracking';
|
2018-07-06 13:40:11 +00:00
|
|
|
import frequentItemsMixin from './frequent_items_mixin';
|
2020-12-07 15:09:49 +00:00
|
|
|
|
|
|
|
const trackingMixin = Tracking.mixin();
|
2018-07-06 13:40:11 +00:00
|
|
|
|
|
|
|
export default {
|
2018-10-15 18:35:00 +00:00
|
|
|
components: {
|
2021-02-09 12:09:48 +00:00
|
|
|
GlSearchBoxByType,
|
2018-10-15 18:35:00 +00:00
|
|
|
},
|
2020-12-07 15:09:49 +00:00
|
|
|
mixins: [frequentItemsMixin, trackingMixin],
|
2021-05-06 00:10:32 +00:00
|
|
|
inject: ['vuexModule'],
|
2018-07-06 13:40:11 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
searchQuery: '',
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
2021-05-06 00:10:32 +00:00
|
|
|
...mapVuexModuleState((vm) => vm.vuexModule, ['dropdownType']),
|
2018-07-06 13:40:11 +00:00
|
|
|
translations() {
|
|
|
|
return this.getTranslations(['searchInputPlaceholder']);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
watch: {
|
2020-02-20 09:09:13 +00:00
|
|
|
searchQuery: debounce(function debounceSearchQuery() {
|
2020-12-07 15:09:49 +00:00
|
|
|
this.track('type_search_query', {
|
|
|
|
label: `${this.dropdownType}_dropdown_frequent_items_search_input`,
|
|
|
|
});
|
2018-07-06 13:40:11 +00:00
|
|
|
this.setSearchQuery(this.searchQuery);
|
|
|
|
}, 500),
|
|
|
|
},
|
|
|
|
methods: {
|
2021-05-06 00:10:32 +00:00
|
|
|
...mapVuexModuleActions((vm) => vm.vuexModule, ['setSearchQuery']),
|
2018-07-06 13:40:11 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2021-06-03 18:09:58 +00:00
|
|
|
<div class="search-input-container">
|
2021-02-09 12:09:48 +00:00
|
|
|
<gl-search-box-by-type
|
2018-07-06 13:40:11 +00:00
|
|
|
v-model="searchQuery"
|
|
|
|
:placeholder="translations.searchInputPlaceholder"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</template>
|