Welcome to mirror list, hosted at ThFree Co, Russian Federation.

preview_dropdown.vue « components « batch_comments « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 91b3b6a685cd7db379b6e32585a467797aa718be (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
45
46
47
48
49
50
51
52
53
<script>
import { GlDropdown, GlDropdownItem, GlIcon } from '@gitlab/ui';
import { mapActions, mapGetters, mapState } from 'vuex';
import PreviewItem from './preview_item.vue';

export default {
  components: {
    GlDropdown,
    GlDropdownItem,
    GlIcon,
    PreviewItem,
  },
  computed: {
    ...mapState('diffs', ['viewDiffsFileByFile']),
    ...mapGetters('batchComments', ['draftsCount', 'sortedDrafts']),
  },
  methods: {
    ...mapActions('diffs', ['toggleActiveFileByHash']),
    ...mapActions('batchComments', ['scrollToDraft']),
    isLast(index) {
      return index === this.sortedDrafts.length - 1;
    },
    async onClickDraft(draft) {
      if (this.viewDiffsFileByFile && draft.file_hash) {
        await this.toggleActiveFileByHash(draft.file_hash);
      }

      await this.scrollToDraft(draft);
    },
  },
};
</script>

<template>
  <gl-dropdown
    :header-text="n__('%d pending comment', '%d pending comments', draftsCount)"
    dropup
    data-qa-selector="review_preview_dropdown"
  >
    <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"
      data-testid="preview-item"
      @click="onClickDraft(draft)"
    >
      <preview-item :draft="draft" :is-last="isLast(index)" />
    </gl-dropdown-item>
  </gl-dropdown>
</template>