summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/header_search/components/header_search_scoped_items.vue
blob: d3def9297525d8c12469186316271fd3d30c167e (plain)
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
<script>
import { GlDropdownItem } from '@gitlab/ui';
import { mapState, mapGetters } from 'vuex';

export default {
  name: 'HeaderSearchScopedItems',
  components: {
    GlDropdownItem,
  },
  props: {
    currentFocusedOption: {
      type: Object,
      required: false,
      default: () => null,
    },
  },
  computed: {
    ...mapState(['search']),
    ...mapGetters(['scopedSearchOptions']),
  },
  methods: {
    isOptionFocused(option) {
      return this.currentFocusedOption?.html_id === option.html_id;
    },
  },
};
</script>

<template>
  <div>
    <gl-dropdown-item
      v-for="option in scopedSearchOptions"
      :ref="option.html_id"
      :key="option.html_id"
      :class="{ 'gl-bg-gray-50': isOptionFocused(option) }"
      tabindex="-1"
      :href="option.url"
    >
      "<span class="gl-font-weight-bold">{{ search }}</span
      >" {{ option.description }}
      <span v-if="option.scope" class="gl-font-style-italic">{{ option.scope }}</span>
    </gl-dropdown-item>
  </div>
</template>