2018-11-08 19:23:39 +05:30
|
|
|
<script>
|
2019-02-15 15:39:39 +05:30
|
|
|
import { mapGetters, mapActions, mapState } from 'vuex';
|
2018-11-08 19:23:39 +05:30
|
|
|
import DiffTableCell from './diff_table_cell.vue';
|
|
|
|
import {
|
|
|
|
NEW_LINE_TYPE,
|
|
|
|
OLD_LINE_TYPE,
|
|
|
|
CONTEXT_LINE_TYPE,
|
|
|
|
CONTEXT_LINE_CLASS_NAME,
|
|
|
|
PARALLEL_DIFF_VIEW_TYPE,
|
|
|
|
LINE_POSITION_LEFT,
|
|
|
|
LINE_POSITION_RIGHT,
|
|
|
|
} from '../constants';
|
|
|
|
|
|
|
|
export default {
|
|
|
|
components: {
|
|
|
|
DiffTableCell,
|
|
|
|
},
|
|
|
|
props: {
|
|
|
|
fileHash: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
contextLinesPath: {
|
|
|
|
type: String,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
line: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
isBottom: {
|
|
|
|
type: Boolean,
|
|
|
|
required: false,
|
|
|
|
default: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
isHover: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
2019-02-15 15:39:39 +05:30
|
|
|
...mapState({
|
|
|
|
isHighlighted(state) {
|
|
|
|
return this.line.line_code !== null && this.line.line_code === state.diffs.highlightedRow;
|
|
|
|
},
|
|
|
|
}),
|
2018-11-08 19:23:39 +05:30
|
|
|
...mapGetters('diffs', ['isInlineView']),
|
|
|
|
isContextLine() {
|
|
|
|
return this.line.type === CONTEXT_LINE_TYPE;
|
|
|
|
},
|
|
|
|
classNameMap() {
|
|
|
|
return {
|
|
|
|
[this.line.type]: this.line.type,
|
|
|
|
[CONTEXT_LINE_CLASS_NAME]: this.isContextLine,
|
|
|
|
[PARALLEL_DIFF_VIEW_TYPE]: this.isParallelView,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
inlineRowId() {
|
2019-02-15 15:39:39 +05:30
|
|
|
return this.line.line_code || `${this.fileHash}_${this.line.old_line}_${this.line.new_line}`;
|
2018-11-08 19:23:39 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.newLineType = NEW_LINE_TYPE;
|
|
|
|
this.oldLineType = OLD_LINE_TYPE;
|
|
|
|
this.linePositionLeft = LINE_POSITION_LEFT;
|
|
|
|
this.linePositionRight = LINE_POSITION_RIGHT;
|
|
|
|
},
|
2018-11-20 20:47:30 +05:30
|
|
|
mounted() {
|
|
|
|
this.scrollToLineIfNeededInline(this.line);
|
|
|
|
},
|
2018-11-08 19:23:39 +05:30
|
|
|
methods: {
|
2018-11-20 20:47:30 +05:30
|
|
|
...mapActions('diffs', ['scrollToLineIfNeededInline']),
|
2018-11-08 19:23:39 +05:30
|
|
|
handleMouseMove(e) {
|
|
|
|
// To show the comment icon on the gutter we need to know if we hover the line.
|
|
|
|
// Current table structure doesn't allow us to do this with CSS in both of the diff view types
|
|
|
|
this.isHover = e.type === 'mouseover';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<tr
|
|
|
|
:id="inlineRowId"
|
|
|
|
:class="classNameMap"
|
|
|
|
class="line_holder"
|
|
|
|
@mouseover="handleMouseMove"
|
|
|
|
@mouseout="handleMouseMove"
|
|
|
|
>
|
|
|
|
<diff-table-cell
|
|
|
|
:file-hash="fileHash"
|
|
|
|
:context-lines-path="contextLinesPath"
|
|
|
|
:line="line"
|
|
|
|
:line-type="oldLineType"
|
|
|
|
:is-bottom="isBottom"
|
|
|
|
:is-hover="isHover"
|
|
|
|
:show-comment-button="true"
|
2019-02-15 15:39:39 +05:30
|
|
|
:is-highlighted="isHighlighted"
|
2018-11-08 19:23:39 +05:30
|
|
|
class="diff-line-num old_line"
|
|
|
|
/>
|
|
|
|
<diff-table-cell
|
|
|
|
:file-hash="fileHash"
|
|
|
|
:context-lines-path="contextLinesPath"
|
|
|
|
:line="line"
|
|
|
|
:line-type="newLineType"
|
|
|
|
:is-bottom="isBottom"
|
|
|
|
:is-hover="isHover"
|
2019-02-15 15:39:39 +05:30
|
|
|
:is-highlighted="isHighlighted"
|
2018-12-13 13:39:08 +05:30
|
|
|
class="diff-line-num new_line qa-new-diff-line"
|
2018-11-08 19:23:39 +05:30
|
|
|
/>
|
|
|
|
<td
|
2019-02-15 15:39:39 +05:30
|
|
|
:class="[
|
|
|
|
line.type,
|
|
|
|
{
|
|
|
|
hll: isHighlighted,
|
|
|
|
},
|
|
|
|
]"
|
2018-11-08 19:23:39 +05:30
|
|
|
class="line_content"
|
2019-02-15 15:39:39 +05:30
|
|
|
v-html="line.rich_text"
|
|
|
|
></td>
|
2018-11-08 19:23:39 +05:30
|
|
|
</tr>
|
|
|
|
</template>
|