summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/diffs/components/inline_diff_comment_row.vue
blob: 1b5ae5e9f75b0583a80ff17cfe4e62c1eb1dd0a3 (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
<script>
import { mapState } from 'vuex';
import diffDiscussions from './diff_discussions.vue';
import diffLineNoteForm from './diff_line_note_form.vue';

export default {
  components: {
    diffDiscussions,
    diffLineNoteForm,
  },
  props: {
    line: {
      type: Object,
      required: true,
    },
    diffFileHash: {
      type: String,
      required: true,
    },
    lineIndex: {
      type: Number,
      required: true,
    },
    discussions: {
      type: Array,
      required: false,
      default: () => [],
    },
  },
  computed: {
    ...mapState({
      diffLineCommentForms: state => state.diffs.diffLineCommentForms,
    }),
    className() {
      return this.discussions.length ? '' : 'js-temp-notes-holder';
    },
    hasCommentForm() {
      return this.diffLineCommentForms[this.line.lineCode];
    },
  },
};
</script>

<template>
  <tr
    :class="className"
    class="notes_holder"
  >
    <td
      class="notes_line"
      colspan="2"
    ></td>
    <td class="notes_content">
      <div class="content">
        <diff-discussions
          v-if="discussions.length"
          :discussions="discussions"
        />
        <diff-line-note-form
          v-if="hasCommentForm"
          :diff-file-hash="diffFileHash"
          :line="line"
          :note-target-line="line"
        />
      </div>
    </td>
  </tr>
</template>