debian-mirror-gitlab/app/assets/javascripts/diffs/components/diff_table_cell.vue

129 lines
2.7 KiB
Vue
Raw Normal View History

2018-11-08 19:23:39 +05:30
<script>
2019-02-15 15:39:39 +05:30
import { mapGetters, mapActions } from 'vuex';
2018-11-08 19:23:39 +05:30
import DiffLineGutterContent from './diff_line_gutter_content.vue';
import {
MATCH_LINE_TYPE,
CONTEXT_LINE_TYPE,
EMPTY_CELL_TYPE,
OLD_LINE_TYPE,
OLD_NO_NEW_LINE_TYPE,
NEW_NO_NEW_LINE_TYPE,
LINE_HOVER_CLASS_NAME,
LINE_UNFOLD_CLASS_NAME,
INLINE_DIFF_VIEW_TYPE,
} from '../constants';
export default {
components: {
DiffLineGutterContent,
},
props: {
line: {
type: Object,
required: true,
},
fileHash: {
type: String,
required: true,
},
contextLinesPath: {
type: String,
required: true,
},
2019-02-15 15:39:39 +05:30
isHighlighted: {
type: Boolean,
required: true,
default: false,
},
2018-11-08 19:23:39 +05:30
diffViewType: {
type: String,
required: false,
default: INLINE_DIFF_VIEW_TYPE,
},
showCommentButton: {
type: Boolean,
required: false,
default: false,
},
linePosition: {
type: String,
required: false,
default: '',
},
lineType: {
type: String,
required: false,
default: '',
},
isContentLine: {
type: Boolean,
required: false,
default: false,
},
isBottom: {
type: Boolean,
required: false,
default: false,
},
isHover: {
type: Boolean,
required: false,
default: false,
},
},
computed: {
...mapGetters(['isLoggedIn']),
isMatchLine() {
2018-11-20 20:47:30 +05:30
return this.line.type === MATCH_LINE_TYPE;
2018-11-08 19:23:39 +05:30
},
isContextLine() {
2018-11-20 20:47:30 +05:30
return this.line.type === CONTEXT_LINE_TYPE;
2018-11-08 19:23:39 +05:30
},
isMetaLine() {
2018-11-20 20:47:30 +05:30
const { type } = this.line;
2018-11-08 19:23:39 +05:30
return (
type === OLD_NO_NEW_LINE_TYPE || type === NEW_NO_NEW_LINE_TYPE || type === EMPTY_CELL_TYPE
);
},
classNameMap() {
2018-11-20 20:47:30 +05:30
const { type } = this.line;
2018-11-08 19:23:39 +05:30
return {
2019-02-15 15:39:39 +05:30
hll: this.isHighlighted,
2018-11-08 19:23:39 +05:30
[type]: type,
[LINE_UNFOLD_CLASS_NAME]: this.isMatchLine,
[LINE_HOVER_CLASS_NAME]:
this.isLoggedIn &&
this.isHover &&
!this.isMatchLine &&
!this.isContextLine &&
!this.isMetaLine,
};
},
lineNumber() {
2019-02-15 15:39:39 +05:30
return this.lineType === OLD_LINE_TYPE ? this.line.old_line : this.line.new_line;
2018-11-08 19:23:39 +05:30
},
},
2019-02-15 15:39:39 +05:30
methods: mapActions('diffs', ['setHighlightedRow']),
2018-11-08 19:23:39 +05:30
};
</script>
<template>
2019-02-15 15:39:39 +05:30
<td :class="classNameMap">
2018-11-08 19:23:39 +05:30
<diff-line-gutter-content
2018-11-20 20:47:30 +05:30
:line="line"
2018-11-08 19:23:39 +05:30
:file-hash="fileHash"
:context-lines-path="contextLinesPath"
:line-position="linePosition"
:line-number="lineNumber"
:show-comment-button="showCommentButton"
2018-11-18 11:00:15 +05:30
:is-hover="isHover"
2018-11-08 19:23:39 +05:30
:is-bottom="isBottom"
:is-match-line="isMatchLine"
:is-context-line="isContentLine"
:is-meta-line="isMetaLine"
/>
</td>
</template>