summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/batch_comments/components/preview_dropdown.vue
blob: e18dc344cd7f5525f52ffff30d5200a3c23c63c2 (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
<script>
import { mapActions, mapGetters } from 'vuex';
import { GlDropdown, GlDropdownItem, GlIcon } from '@gitlab/ui';
import PreviewItem from './preview_item.vue';

export default {
  components: {
    GlDropdown,
    GlDropdownItem,
    GlIcon,
    PreviewItem,
  },
  computed: {
    ...mapGetters('batchComments', ['draftsCount', 'sortedDrafts']),
  },
  methods: {
    ...mapActions('batchComments', ['scrollToDraft']),
    isLast(index) {
      return index === this.sortedDrafts.length - 1;
    },
  },
};
</script>

<template>
  <gl-dropdown
    :header-text="n__('%d pending comment', '%d pending comments', draftsCount)"
    dropup
    toggle-class="qa-review-preview-toggle"
  >
    <template #button-content>
      {{ __('Pending comments') }}
      <gl-icon class="dropdown-chevron" name="chevron-up" />
    </template>
    <gl-dropdown-item
      v-for="(draft, index) in sortedDrafts"
      :key="draft.id"
      @click="scrollToDraft(draft)"
    >
      <preview-item :draft="draft" :is-last="isLast(index)" />
    </gl-dropdown-item>
  </gl-dropdown>
</template>