1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
<script>
import { __ } from '~/locale';
import RefSelector from '~/ref/components/ref_selector.vue';
import { REF_TYPE_BRANCHES, REF_TYPE_TAGS } from '~/ref/constants';
import { formatToShortName } from '../utils/format_refs';
export default {
ENABLED_TYPE_REFS: [REF_TYPE_BRANCHES, REF_TYPE_TAGS],
i18n: {
/**
* In order to hide ListBox header
* we need to explicitly provide
* empty string for translations
*/
dropdownHeader: '',
searchPlaceholder: __('Search refs'),
},
components: {
RefSelector,
},
props: {
projectId: {
type: String,
required: true,
},
value: {
type: Object,
required: false,
default: () => ({}),
},
},
computed: {
refShortName() {
return this.value.shortName;
},
},
methods: {
setRefSelected(fullName) {
this.$emit('input', {
shortName: formatToShortName(fullName),
fullName,
});
},
},
};
</script>
<template>
<ref-selector
:value="refShortName"
:enabled-ref-types="$options.ENABLED_TYPE_REFS"
:project-id="projectId"
:translations="$options.i18n"
:use-symbolic-ref-names="true"
toggle-button-class="gl-w-auto! gl-mb-0!"
@input="setRefSelected"
/>
</template>
|