Commit 8c7ac040 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/unifiedDiffComponentsClassNameFixes' into 'master'

Fix line classes and unified diff components

See merge request gitlab-org/gitlab!51203
parents 9d7c81ee 36c6d39e
...@@ -58,7 +58,7 @@ export default { ...@@ -58,7 +58,7 @@ export default {
classNameMap() { classNameMap() {
return { return {
[CONTEXT_LINE_CLASS_NAME]: this.line.isContextLineLeft, [CONTEXT_LINE_CLASS_NAME]: this.line.isContextLineLeft,
[PARALLEL_DIFF_VIEW_TYPE]: true, [PARALLEL_DIFF_VIEW_TYPE]: !this.inline,
}; };
}, },
parallelViewLeftLineType() { parallelViewLeftLineType() {
...@@ -148,7 +148,7 @@ export default { ...@@ -148,7 +148,7 @@ export default {
<div <div
:class="classNameMapCellLeft" :class="classNameMapCellLeft"
data-testid="leftLineNumber" data-testid="leftLineNumber"
class="diff-td diff-line-num old_line" class="diff-td diff-line-num"
> >
<template v-if="!isLeftConflictMarker"> <template v-if="!isLeftConflictMarker">
<span <span
...@@ -189,7 +189,7 @@ export default { ...@@ -189,7 +189,7 @@ export default {
" "
/> />
</div> </div>
<div v-if="inline" :class="classNameMapCellLeft" class="diff-td diff-line-num old_line"> <div v-if="inline" :class="classNameMapCellLeft" class="diff-td diff-line-num">
<a <a
v-if="line.left.new_line && line.left.type !== $options.CONFLICT_OUR" v-if="line.left.new_line && line.left.type !== $options.CONFLICT_OUR"
:data-linenumber="line.left.new_line" :data-linenumber="line.left.new_line"
...@@ -202,8 +202,8 @@ export default { ...@@ -202,8 +202,8 @@ export default {
<div <div
:id="line.left.line_code" :id="line.left.line_code"
:key="line.left.line_code" :key="line.left.line_code"
:class="parallelViewLeftLineType" :class="[parallelViewLeftLineType, { parallel: !inline }]"
class="diff-td line_content with-coverage parallel left-side" class="diff-td line_content with-coverage left-side"
data-testid="leftContent" data-testid="leftContent"
@mousedown="handleParallelLineMouseDown" @mousedown="handleParallelLineMouseDown"
> >
...@@ -229,8 +229,8 @@ export default { ...@@ -229,8 +229,8 @@ export default {
:class="emptyCellLeftClassMap" :class="emptyCellLeftClassMap"
></div> ></div>
<div <div
class="diff-td line_content with-coverage parallel left-side empty-cell" class="diff-td line_content with-coverage left-side empty-cell"
:class="emptyCellLeftClassMap" :class="[emptyCellLeftClassMap, { parallel: !inline }]"
></div> ></div>
</template> </template>
</div> </div>
...@@ -285,8 +285,8 @@ export default { ...@@ -285,8 +285,8 @@ export default {
<div <div
:id="line.right.line_code" :id="line.right.line_code"
:key="line.right.rich_text" :key="line.right.rich_text"
:class="[line.right.type, { hll: isHighlighted }]" :class="[line.right.type, { hll: isHighlighted, parallel: !inline }]"
class="diff-td line_content with-coverage parallel right-side" class="diff-td line_content with-coverage right-side"
@mousedown="handleParallelLineMouseDown" @mousedown="handleParallelLineMouseDown"
> >
<strong v-if="line.right.type === $options.CONFLICT_MARKER_THEIR">{{ <strong v-if="line.right.type === $options.CONFLICT_MARKER_THEIR">{{
...@@ -311,8 +311,8 @@ export default { ...@@ -311,8 +311,8 @@ export default {
:class="emptyCellRightClassMap" :class="emptyCellRightClassMap"
></div> ></div>
<div <div
class="diff-td line_content with-coverage parallel right-side empty-cell" class="diff-td line_content with-coverage right-side empty-cell"
:class="emptyCellRightClassMap" :class="[emptyCellRightClassMap, { parallel: !inline }]"
></div> ></div>
</template> </template>
</div> </div>
......
...@@ -44,6 +44,8 @@ export const classNameMapCell = (line, hll, isLoggedIn, isHover) => { ...@@ -44,6 +44,8 @@ export const classNameMapCell = (line, hll, isLoggedIn, isHover) => {
{ {
hll, hll,
[LINE_HOVER_CLASS_NAME]: isLoggedIn && isHover && !isContextLine(type) && !isMetaLine(type), [LINE_HOVER_CLASS_NAME]: isLoggedIn && isHover && !isContextLine(type) && !isMetaLine(type),
old_line: line.type === 'old',
new_line: line.type === 'new',
}, },
]; ];
}; };
......
...@@ -128,10 +128,10 @@ describe('classNameMapCell', () => { ...@@ -128,10 +128,10 @@ describe('classNameMapCell', () => {
it.each` it.each`
line | hll | loggedIn | hovered | expectation line | hll | loggedIn | hovered | expectation
${undefined} | ${true} | ${true} | ${true} | ${[]} ${undefined} | ${true} | ${true} | ${true} | ${[]}
${{ type: 'new' }} | ${false} | ${false} | ${false} | ${['new', { hll: false, 'is-over': false }]} ${{ type: 'new' }} | ${false} | ${false} | ${false} | ${['new', { hll: false, 'is-over': false, new_line: true, old_line: false }]}
${{ type: 'new' }} | ${true} | ${true} | ${false} | ${['new', { hll: true, 'is-over': false }]} ${{ type: 'new' }} | ${true} | ${true} | ${false} | ${['new', { hll: true, 'is-over': false, new_line: true, old_line: false }]}
${{ type: 'new' }} | ${true} | ${false} | ${true} | ${['new', { hll: true, 'is-over': false }]} ${{ type: 'new' }} | ${true} | ${false} | ${true} | ${['new', { hll: true, 'is-over': false, new_line: true, old_line: false }]}
${{ type: 'new' }} | ${true} | ${true} | ${true} | ${['new', { hll: true, 'is-over': true }]} ${{ type: 'new' }} | ${true} | ${true} | ${true} | ${['new', { hll: true, 'is-over': true, new_line: true, old_line: false }]}
`('should return $expectation', ({ line, hll, loggedIn, hovered, expectation }) => { `('should return $expectation', ({ line, hll, loggedIn, hovered, expectation }) => {
const classes = utils.classNameMapCell(line, hll, loggedIn, hovered); const classes = utils.classNameMapCell(line, hll, loggedIn, hovered);
expect(classes).toEqual(expectation); expect(classes).toEqual(expectation);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment