2018-12-13 19:17:19 +00:00
|
|
|
<script>
|
|
|
|
import SuggestionDiffHeader from './suggestion_diff_header.vue';
|
2019-04-04 13:08:34 +00:00
|
|
|
import SuggestionDiffRow from './suggestion_diff_row.vue';
|
|
|
|
import { selectDiffLines } from '../lib/utils/diff_utils';
|
2018-12-13 19:17:19 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
SuggestionDiffHeader,
|
2019-04-04 13:08:34 +00:00
|
|
|
SuggestionDiffRow,
|
2018-12-13 19:17:19 +00:00
|
|
|
},
|
|
|
|
props: {
|
|
|
|
suggestion: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
disabled: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
helpPagePath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
2019-04-04 13:08:34 +00:00
|
|
|
computed: {
|
|
|
|
lines() {
|
|
|
|
return selectDiffLines(this.suggestion.diff_lines);
|
|
|
|
},
|
|
|
|
},
|
2018-12-13 19:17:19 +00:00
|
|
|
methods: {
|
|
|
|
applySuggestion(callback) {
|
|
|
|
this.$emit('apply', { suggestionId: this.suggestion.id, callback });
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2019-01-21 17:26:11 +00:00
|
|
|
<div class="md-suggestion">
|
2018-12-13 19:17:19 +00:00
|
|
|
<suggestion-diff-header
|
2019-07-29 19:22:22 +00:00
|
|
|
class="qa-suggestion-diff-header js-suggestion-diff-header"
|
2018-12-13 19:17:19 +00:00
|
|
|
:can-apply="suggestion.appliable && suggestion.current_user.can_apply && !disabled"
|
|
|
|
:is-applied="suggestion.applied"
|
|
|
|
:help-page-path="helpPagePath"
|
|
|
|
@apply="applySuggestion"
|
|
|
|
/>
|
2019-01-10 09:54:39 +00:00
|
|
|
<table class="mb-3 md-suggestion-diff js-syntax-highlight code">
|
2018-12-13 19:17:19 +00:00
|
|
|
<tbody>
|
2019-04-04 13:08:34 +00:00
|
|
|
<suggestion-diff-row
|
|
|
|
v-for="(line, index) of lines"
|
|
|
|
:key="`${index}-${line.text}`"
|
|
|
|
:line="line"
|
|
|
|
/>
|
2018-12-13 19:17:19 +00:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</template>
|