summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/header_search/components/header_search_default_items.vue
blob: 2871937ed3ac28f375bf23ac9f77149f9e302cef (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
<script>
import { GlDropdownItem, GlDropdownSectionHeader } from '@gitlab/ui';
import { mapState, mapGetters } from 'vuex';
import { __ } from '~/locale';

export default {
  name: 'HeaderSearchDefaultItems',
  i18n: {
    allGitLab: __('All GitLab'),
  },
  components: {
    GlDropdownSectionHeader,
    GlDropdownItem,
  },
  computed: {
    ...mapState(['searchContext']),
    ...mapGetters(['defaultSearchOptions']),
    sectionHeader() {
      return (
        this.searchContext.project?.name ||
        this.searchContext.group?.name ||
        this.$options.i18n.allGitLab
      );
    },
  },
};
</script>

<template>
  <div>
    <gl-dropdown-section-header>{{ sectionHeader }}</gl-dropdown-section-header>
    <gl-dropdown-item
      v-for="(option, index) in defaultSearchOptions"
      :id="`default-${index}`"
      :key="index"
      tabindex="-1"
      :href="option.url"
    >
      {{ option.title }}
    </gl-dropdown-item>
  </div>
</template>