summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/batch_comments/components/parallel_draft_comment_row.vue
blob: b0916623cd21989a4fa96b3f8ff7d1d7f84a8483 (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
<script>
import { mapGetters } from 'vuex';
import DraftNote from './draft_note.vue';

export default {
  components: {
    DraftNote,
  },
  props: {
    line: {
      type: Object,
      required: true,
    },
    diffFileContentSha: {
      type: String,
      required: true,
    },
  },
  computed: {
    ...mapGetters('batchComments', ['draftForLine']),
    className() {
      return this.leftDraft > 0 || this.rightDraft > 0 ? '' : 'js-temp-notes-holder';
    },
    leftDraft() {
      return this.draftForLine(this.diffFileContentSha, this.line, 'left');
    },
    rightDraft() {
      return this.draftForLine(this.diffFileContentSha, this.line, 'right');
    },
  },
};
</script>

<template>
  <tr :class="className" class="notes_holder">
    <td class="notes_line old"></td>
    <td class="notes-content parallel old" colspan="2">
      <div v-if="leftDraft.isDraft" class="content">
        <draft-note :draft="leftDraft" :line="line.left" />
      </div>
    </td>
    <td class="notes_line new"></td>
    <td class="notes-content parallel new" colspan="2">
      <div v-if="rightDraft.isDraft" class="content">
        <draft-note :draft="rightDraft" :line="line.right" />
      </div>
    </td>
  </tr>
</template>