BigW Consortium Gitlab

Commit b0b5e9f1 by Fatih Acet

Refactor data parser to remove duplicated objects.

parent 85507b25
...@@ -56,21 +56,19 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider { ...@@ -56,21 +56,19 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider {
lines.forEach( (line) => { lines.forEach( (line) => {
const { type } = line; const { type } = line;
if (conflict) { if (conflict) {
if (type === 'old') { if (type === 'old') {
line = { lineType: 'conflict', hasConflict: true, lineNumber: line.old_line, richText: line.rich_text, section: 'head', id, isSelected: false, isUnselected: false, isOrigin: true } file.parallelLines.left.push(this.getLineForParallelView(line, id, 'conflict'));
file.parallelLines.left.push(line);
} }
else if (type === 'new') { else if (type === 'new') {
line = { lineType: 'conflict', hasConflict: true, lineNumber: line.new_line, richText: line.rich_text, section: 'origin', id, isSelected: false, isUnselected: false, isHead: true } file.parallelLines.right.push(this.getLineForParallelView(line, id, 'conflict', true));
file.parallelLines.right.push(line);
} }
} }
else { else {
const lineType = line.type || 'context'; const lineType = type || 'context';
const hasMatch = line.type === 'match'; file.parallelLines.left.push (this.getLineForParallelView(line, id, lineType));
file.parallelLines.left.push({ lineType, hasMatch, lineNumber: line.old_line, richText: line.rich_text }); file.parallelLines.right.push(this.getLineForParallelView(line, id, lineType));
file.parallelLines.right.push({ lineType, hasMatch, lineNumber: line.new_line, richText: line.rich_text });
} }
}); });
}); });
...@@ -202,6 +200,25 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider { ...@@ -202,6 +200,25 @@ window.MergeConflictDataProvider = class MergeConflictDataProvider {
line.isUnselected = false; line.isUnselected = false;
} }
getLineForParallelView(line, id, lineType, isHead) {
const { old_line, new_line, rich_text } = line;
const hasConflict = lineType === 'conflict';
return {
id,
lineType,
hasConflict,
isHead: hasConflict && isHead,
isOrigin: hasConflict && !isHead,
hasMatch: lineType === 'match',
lineNumber: isHead ? new_line : old_line,
section: isHead ? 'head' : 'origin',
richText: rich_text,
isSelected: false,
isUnselected: false
}
}
getHeadHeaderLine(id) { getHeadHeaderLine(id) {
return { return {
......
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