2018-06-21 08:22:40 -04:00
|
|
|
<script>
|
2020-07-16 02:09:33 -04:00
|
|
|
import { mapGetters, mapState } from 'vuex';
|
2020-08-26 08:10:53 -04:00
|
|
|
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
|
2020-06-01 02:08:21 -04:00
|
|
|
import draftCommentsMixin from '~/diffs/mixins/draft_comments';
|
|
|
|
import InlineDraftCommentRow from '~/batch_comments/components/inline_draft_comment_row.vue';
|
2018-07-03 19:18:27 -04:00
|
|
|
import inlineDiffTableRow from './inline_diff_table_row.vue';
|
2018-06-27 17:20:41 -04:00
|
|
|
import inlineDiffCommentRow from './inline_diff_comment_row.vue';
|
2019-08-09 22:36:32 -04:00
|
|
|
import inlineDiffExpansionRow from './inline_diff_expansion_row.vue';
|
2020-07-16 02:09:33 -04:00
|
|
|
import { getCommentedLines } from '~/notes/components/multiline_comment_utils';
|
2018-06-21 08:22:40 -04:00
|
|
|
|
|
|
|
export default {
|
2018-06-27 17:20:41 -04:00
|
|
|
components: {
|
|
|
|
inlineDiffCommentRow,
|
2018-07-03 19:18:27 -04:00
|
|
|
inlineDiffTableRow,
|
2020-06-01 02:08:21 -04:00
|
|
|
InlineDraftCommentRow,
|
2019-08-09 22:36:32 -04:00
|
|
|
inlineDiffExpansionRow,
|
2018-07-03 19:18:27 -04:00
|
|
|
},
|
2020-08-26 08:10:53 -04:00
|
|
|
mixins: [draftCommentsMixin, glFeatureFlagsMixin()],
|
2018-07-03 19:18:27 -04:00
|
|
|
props: {
|
|
|
|
diffFile: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
diffLines: {
|
|
|
|
type: Array,
|
|
|
|
required: true,
|
|
|
|
},
|
2018-12-13 14:17:19 -05:00
|
|
|
helpPagePath: {
|
|
|
|
type: String,
|
|
|
|
required: false,
|
|
|
|
default: '',
|
|
|
|
},
|
2018-07-03 19:18:27 -04:00
|
|
|
},
|
|
|
|
computed: {
|
2018-11-09 04:44:07 -05:00
|
|
|
...mapGetters('diffs', ['commitId']),
|
2020-07-16 02:09:33 -04:00
|
|
|
...mapState({
|
|
|
|
selectedCommentPosition: ({ notes }) => notes.selectedCommentPosition,
|
|
|
|
selectedCommentPositionHover: ({ notes }) => notes.selectedCommentPositionHover,
|
|
|
|
}),
|
2018-07-03 19:18:27 -04:00
|
|
|
diffLinesLength() {
|
2018-09-01 17:24:29 -04:00
|
|
|
return this.diffLines.length;
|
2018-07-03 19:18:27 -04:00
|
|
|
},
|
2020-07-16 02:09:33 -04:00
|
|
|
commentedLines() {
|
|
|
|
return getCommentedLines(
|
|
|
|
this.selectedCommentPosition || this.selectedCommentPositionHover,
|
|
|
|
this.diffLines,
|
|
|
|
);
|
|
|
|
},
|
2018-06-21 08:22:40 -04:00
|
|
|
},
|
2018-11-09 04:44:07 -05:00
|
|
|
userColorScheme: window.gon.user_color_scheme,
|
2018-06-21 08:22:40 -04:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<table
|
2018-11-09 04:44:07 -05:00
|
|
|
:class="$options.userColorScheme"
|
2018-06-21 08:22:40 -04:00
|
|
|
:data-commit-id="commitId"
|
2018-11-16 15:07:38 -05:00
|
|
|
class="code diff-wrap-lines js-syntax-highlight text-file js-diff-inline-view"
|
|
|
|
>
|
2019-10-01 17:06:09 -04:00
|
|
|
<colgroup>
|
|
|
|
<col style="width: 50px;" />
|
|
|
|
<col style="width: 50px;" />
|
2020-03-17 14:09:44 -04:00
|
|
|
<col style="width: 8px;" />
|
2019-10-01 17:06:09 -04:00
|
|
|
<col />
|
|
|
|
</colgroup>
|
2018-06-21 08:22:40 -04:00
|
|
|
<tbody>
|
2020-09-17 08:09:37 -04:00
|
|
|
<template v-for="(line, index) in diffLines">
|
|
|
|
<inline-diff-expansion-row
|
|
|
|
:key="`expand-${index}`"
|
|
|
|
:file-hash="diffFile.file_hash"
|
|
|
|
:context-lines-path="diffFile.context_lines_path"
|
|
|
|
:line="line"
|
|
|
|
:is-top="index === 0"
|
|
|
|
:is-bottom="index + 1 === diffLinesLength"
|
|
|
|
/>
|
|
|
|
<inline-diff-table-row
|
|
|
|
:key="`${line.line_code || index}`"
|
|
|
|
:file-hash="diffFile.file_hash"
|
|
|
|
:file-path="diffFile.file_path"
|
|
|
|
:line="line"
|
|
|
|
:is-bottom="index + 1 === diffLinesLength"
|
|
|
|
:is-commented="index >= commentedLines.startLine && index <= commentedLines.endLine"
|
|
|
|
/>
|
|
|
|
<inline-diff-comment-row
|
|
|
|
:key="`icr-${line.line_code || index}`"
|
|
|
|
:diff-file-hash="diffFile.file_hash"
|
|
|
|
:line="line"
|
|
|
|
:help-page-path="helpPagePath"
|
|
|
|
:has-draft="shouldRenderDraftRow(diffFile.file_hash, line) || false"
|
|
|
|
/>
|
|
|
|
<inline-draft-comment-row
|
|
|
|
v-if="shouldRenderDraftRow(diffFile.file_hash, line)"
|
|
|
|
:key="`draft_${index}`"
|
|
|
|
:draft="draftForLine(diffFile.file_hash, line)"
|
|
|
|
:diff-file="diffFile"
|
|
|
|
:line="line"
|
|
|
|
/>
|
2018-06-21 08:22:40 -04:00
|
|
|
</template>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</template>
|