summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/vue_shared/components/markdown/suggestion_diff.vue
blob: 7b30053508fabaa35e7c8cda567991b6590a7fe0 (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
<script>
import suggestionDiffHeader from './suggestion_diff_header.vue';

export default {
  components: {
    suggestionDiffHeader
  },
  props: {
    canApply: {
      type: Boolean,
      required: false,
      default: false,
    },
    newLine: {
      type: Object,
      required: true,
    },
  },
  methods: {
    extractNewLine(suggestionEl) {
      const newLine = suggestionEl.getElementsByClassName('line');
      return (newLine && newLine[0]) ? newLine[0].innerHTML : '';
    },
    applySuggestion() {
      this.$emit('apply', this.newLine.content);
    },
  },
};
</script>

<template>
  <div>
    <suggestion-diff-header
      :can-apply="canApply"
      @apply="applySuggestion"
    />
    <table class="mb-3 md-suggestion-diff">
      <tbody>
        <!-- New Line -->
        <tr class="line_holder new">
          <td class="diff-line-num old_line new"></td>
          <td class="diff-line-num new_line qa-new-diff-line new">
            <div>
              {{ newLine.number }}
            </div>
          </td>
          <td class="line_content new">
            <span
              class="line"
              v-html="newLine.content"></span>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</template>