summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/batch_comments/components/review_bar.vue
blob: b0e8b806701a60cc96d36e91db3bfdad0df37824 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<script>
import { mapActions, mapState, mapGetters } from 'vuex';
import { GlModal, GlModalDirective } from '@gitlab/ui';
import { sprintf, s__ } from '~/locale';
import LoadingButton from '~/vue_shared/components/loading_button.vue';
import PreviewDropdown from './preview_dropdown.vue';

export default {
  components: {
    LoadingButton,
    GlModal,
    PreviewDropdown,
  },
  directives: {
    'gl-modal': GlModalDirective,
  },
  computed: {
    ...mapGetters(['isNotesFetched']),
    ...mapState('batchComments', ['isDiscarding']),
    ...mapGetters('batchComments', ['draftsCount']),
  },
  watch: {
    isNotesFetched() {
      if (this.isNotesFetched) {
        this.expandAllDiscussions();
      }
    },
  },
  methods: {
    ...mapActions('batchComments', ['discardReview', 'expandAllDiscussions']),
  },
  modalId: 'discard-draft-review',
  text: sprintf(
    s__(
      `BatchComments|You're about to discard your review which will delete all of your pending comments.
      The deleted comments %{strong_start}cannot%{strong_end} be restored.`,
    ),
    {
      strong_start: '<strong>',
      strong_end: '</strong>',
    },
    false,
  ),
};
</script>
<template>
  <div v-show="draftsCount > 0">
    <nav class="review-bar-component">
      <div class="review-bar-content qa-review-bar">
        <preview-dropdown />
        <loading-button
          v-gl-modal="$options.modalId"
          :loading="isDiscarding"
          :label="__('Discard review')"
          class="qa-discard-review float-right"
        />
      </div>
    </nav>
    <gl-modal
      :title="s__('BatchComments|Discard review?')"
      :ok-title="s__('BatchComments|Delete all pending comments')"
      :modal-id="$options.modalId"
      title-tag="h4"
      ok-variant="danger qa-modal-delete-pending-comments"
      @ok="discardReview"
    >
      <p v-html="$options.text"></p>
    </gl-modal>
  </div>
</template>