2017-01-12 05:52:42 +00:00
|
|
|
|
/* eslint-disable comma-dangle, object-shorthand, no-param-reassign, camelcase, no-nested-ternary, no-continue, max-len */
|
2017-03-17 17:21:25 +00:00
|
|
|
|
|
2018-03-09 20:18:59 +00:00
|
|
|
|
import $ from 'jquery';
|
2017-03-17 17:21:25 +00:00
|
|
|
|
import Vue from 'vue';
|
2017-03-11 06:45:34 +00:00
|
|
|
|
import Cookies from 'js-cookie';
|
2016-12-14 03:01:05 +00:00
|
|
|
|
|
2016-09-28 10:12:13 +00:00
|
|
|
|
((global) => {
|
|
|
|
|
global.mergeConflicts = global.mergeConflicts || {};
|
|
|
|
|
|
2016-10-24 21:26:41 +00:00
|
|
|
|
const diffViewType = Cookies.get('diff_view');
|
2016-09-28 10:12:13 +00:00
|
|
|
|
const HEAD_HEADER_TEXT = 'HEAD//our changes';
|
|
|
|
|
const ORIGIN_HEADER_TEXT = 'origin//their changes';
|
|
|
|
|
const HEAD_BUTTON_TITLE = 'Use ours';
|
|
|
|
|
const ORIGIN_BUTTON_TITLE = 'Use theirs';
|
|
|
|
|
const INTERACTIVE_RESOLVE_MODE = 'interactive';
|
|
|
|
|
const EDIT_RESOLVE_MODE = 'edit';
|
|
|
|
|
const DEFAULT_RESOLVE_MODE = INTERACTIVE_RESOLVE_MODE;
|
|
|
|
|
const VIEW_TYPES = {
|
|
|
|
|
INLINE: 'inline',
|
|
|
|
|
PARALLEL: 'parallel'
|
|
|
|
|
};
|
2016-09-30 01:26:01 +00:00
|
|
|
|
const CONFLICT_TYPES = {
|
|
|
|
|
TEXT: 'text',
|
|
|
|
|
TEXT_EDITOR: 'text-editor'
|
|
|
|
|
};
|
2016-09-28 10:12:13 +00:00
|
|
|
|
|
|
|
|
|
global.mergeConflicts.mergeConflictsStore = {
|
|
|
|
|
state: {
|
|
|
|
|
isLoading: true,
|
|
|
|
|
hasError: false,
|
|
|
|
|
isSubmitting: false,
|
|
|
|
|
isParallel: diffViewType === VIEW_TYPES.PARALLEL,
|
|
|
|
|
diffViewType: diffViewType,
|
|
|
|
|
conflictsData: {}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
setConflictsData(data) {
|
|
|
|
|
this.decorateFiles(data.files);
|
|
|
|
|
|
|
|
|
|
this.state.conflictsData = {
|
|
|
|
|
files: data.files,
|
|
|
|
|
commitMessage: data.commit_message,
|
|
|
|
|
sourceBranch: data.source_branch,
|
|
|
|
|
targetBranch: data.target_branch,
|
|
|
|
|
shortCommitSha: data.commit_sha.slice(0, 7),
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
decorateFiles(files) {
|
|
|
|
|
files.forEach((file) => {
|
|
|
|
|
file.content = '';
|
|
|
|
|
file.resolutionData = {};
|
|
|
|
|
file.promptDiscardConfirmation = false;
|
|
|
|
|
file.resolveMode = DEFAULT_RESOLVE_MODE;
|
2016-09-30 01:26:01 +00:00
|
|
|
|
file.filePath = this.getFilePath(file);
|
2016-09-28 10:12:13 +00:00
|
|
|
|
file.iconClass = `fa-${file.blob_icon}`;
|
|
|
|
|
file.blobPath = file.blob_path;
|
|
|
|
|
|
2016-09-30 01:26:01 +00:00
|
|
|
|
if (file.type === CONFLICT_TYPES.TEXT) {
|
|
|
|
|
file.showEditor = false;
|
|
|
|
|
file.loadEditor = false;
|
2016-09-28 10:12:13 +00:00
|
|
|
|
|
2016-09-30 01:26:01 +00:00
|
|
|
|
this.setInlineLine(file);
|
|
|
|
|
this.setParallelLine(file);
|
|
|
|
|
} else if (file.type === CONFLICT_TYPES.TEXT_EDITOR) {
|
|
|
|
|
file.showEditor = true;
|
|
|
|
|
file.loadEditor = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
2016-09-28 10:12:13 +00:00
|
|
|
|
|
2016-09-30 01:26:01 +00:00
|
|
|
|
setInlineLine(file) {
|
|
|
|
|
file.inlineLines = [];
|
2016-09-28 10:12:13 +00:00
|
|
|
|
|
2016-09-30 01:26:01 +00:00
|
|
|
|
file.sections.forEach((section) => {
|
|
|
|
|
let currentLineType = 'new';
|
|
|
|
|
const { conflict, lines, id } = section;
|
|
|
|
|
|
|
|
|
|
if (conflict) {
|
|
|
|
|
file.inlineLines.push(this.getHeadHeaderLine(id));
|
|
|
|
|
}
|
2016-09-28 10:12:13 +00:00
|
|
|
|
|
2016-09-30 01:26:01 +00:00
|
|
|
|
lines.forEach((line) => {
|
|
|
|
|
const { type } = line;
|
2016-09-28 10:12:13 +00:00
|
|
|
|
|
2016-09-30 01:26:01 +00:00
|
|
|
|
if ((type === 'new' || type === 'old') && currentLineType !== type) {
|
|
|
|
|
currentLineType = type;
|
|
|
|
|
file.inlineLines.push({ lineType: 'emptyLine', richText: '' });
|
2016-09-28 10:12:13 +00:00
|
|
|
|
}
|
2016-09-30 01:26:01 +00:00
|
|
|
|
|
|
|
|
|
this.decorateLineForInlineView(line, id, conflict);
|
|
|
|
|
file.inlineLines.push(line);
|
2017-01-10 22:54:56 +00:00
|
|
|
|
});
|
2016-09-30 01:26:01 +00:00
|
|
|
|
|
|
|
|
|
if (conflict) {
|
|
|
|
|
file.inlineLines.push(this.getOriginHeaderLine(id));
|
|
|
|
|
}
|
2016-09-28 10:12:13 +00:00
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2016-09-30 01:26:01 +00:00
|
|
|
|
setParallelLine(file) {
|
|
|
|
|
file.parallelLines = [];
|
|
|
|
|
const linesObj = { left: [], right: [] };
|
2016-09-28 10:12:13 +00:00
|
|
|
|
|
2016-09-30 01:26:01 +00:00
|
|
|
|
file.sections.forEach((section) => {
|
|
|
|
|
const { conflict, lines, id } = section;
|
2016-09-28 10:12:13 +00:00
|
|
|
|
|
2016-09-30 01:26:01 +00:00
|
|
|
|
if (conflict) {
|
|
|
|
|
linesObj.left.push(this.getOriginHeaderLine(id));
|
|
|
|
|
linesObj.right.push(this.getHeadHeaderLine(id));
|
|
|
|
|
}
|
2016-09-28 10:12:13 +00:00
|
|
|
|
|
2016-09-30 01:26:01 +00:00
|
|
|
|
lines.forEach((line) => {
|
|
|
|
|
const { type } = line;
|
2016-09-28 10:12:13 +00:00
|
|
|
|
|
2016-09-30 01:26:01 +00:00
|
|
|
|
if (conflict) {
|
|
|
|
|
if (type === 'old') {
|
|
|
|
|
linesObj.left.push(this.getLineForParallelView(line, id, 'conflict'));
|
|
|
|
|
} else if (type === 'new') {
|
|
|
|
|
linesObj.right.push(this.getLineForParallelView(line, id, 'conflict', true));
|
2016-09-28 10:12:13 +00:00
|
|
|
|
}
|
2016-09-30 01:26:01 +00:00
|
|
|
|
} else {
|
|
|
|
|
const lineType = type || 'context';
|
2016-09-28 10:12:13 +00:00
|
|
|
|
|
2017-01-12 04:27:41 +00:00
|
|
|
|
linesObj.left.push(this.getLineForParallelView(line, id, lineType));
|
2016-09-30 01:26:01 +00:00
|
|
|
|
linesObj.right.push(this.getLineForParallelView(line, id, lineType, true));
|
|
|
|
|
}
|
2016-09-28 10:12:13 +00:00
|
|
|
|
});
|
|
|
|
|
|
2016-09-30 01:26:01 +00:00
|
|
|
|
this.checkLineLengths(linesObj);
|
2016-09-28 10:12:13 +00:00
|
|
|
|
});
|
2016-09-30 01:26:01 +00:00
|
|
|
|
|
2017-01-10 22:35:09 +00:00
|
|
|
|
for (let i = 0, len = linesObj.left.length; i < len; i += 1) {
|
2016-09-30 01:26:01 +00:00
|
|
|
|
file.parallelLines.push([
|
|
|
|
|
linesObj.right[i],
|
|
|
|
|
linesObj.left[i]
|
|
|
|
|
]);
|
|
|
|
|
}
|
2016-09-28 10:12:13 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
setLoadingState(state) {
|
|
|
|
|
this.state.isLoading = state;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
setErrorState(state) {
|
|
|
|
|
this.state.hasError = state;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
setFailedRequest(message) {
|
|
|
|
|
this.state.hasError = true;
|
|
|
|
|
this.state.conflictsData.errorMessage = message;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getConflictsCount() {
|
2016-09-30 01:26:01 +00:00
|
|
|
|
if (!this.state.conflictsData.files.length) {
|
2016-09-28 10:12:13 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-16 21:50:13 +00:00
|
|
|
|
const { files } = this.state.conflictsData;
|
2016-09-28 10:12:13 +00:00
|
|
|
|
let count = 0;
|
|
|
|
|
|
|
|
|
|
files.forEach((file) => {
|
2016-09-30 01:26:01 +00:00
|
|
|
|
if (file.type === CONFLICT_TYPES.TEXT) {
|
|
|
|
|
file.sections.forEach((section) => {
|
|
|
|
|
if (section.conflict) {
|
2017-01-10 22:35:09 +00:00
|
|
|
|
count += 1;
|
2016-09-30 01:26:01 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
2017-01-10 22:35:09 +00:00
|
|
|
|
count += 1;
|
2016-09-30 01:26:01 +00:00
|
|
|
|
}
|
2016-09-28 10:12:13 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return count;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getConflictsCountText() {
|
|
|
|
|
const count = this.getConflictsCount();
|
2017-07-24 15:04:54 +00:00
|
|
|
|
const text = count > 1 ? 'conflicts' : 'conflict';
|
2016-09-28 10:12:13 +00:00
|
|
|
|
|
|
|
|
|
return `${count} ${text}`;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
setViewType(viewType) {
|
2016-09-30 01:26:01 +00:00
|
|
|
|
this.state.diffView = viewType;
|
2016-09-28 10:12:13 +00:00
|
|
|
|
this.state.isParallel = viewType === VIEW_TYPES.PARALLEL;
|
|
|
|
|
|
2016-10-24 21:54:38 +00:00
|
|
|
|
Cookies.set('diff_view', viewType);
|
2016-09-28 10:12:13 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getHeadHeaderLine(id) {
|
|
|
|
|
return {
|
|
|
|
|
id: id,
|
|
|
|
|
richText: HEAD_HEADER_TEXT,
|
|
|
|
|
buttonTitle: HEAD_BUTTON_TITLE,
|
|
|
|
|
type: 'new',
|
|
|
|
|
section: 'head',
|
|
|
|
|
isHeader: true,
|
|
|
|
|
isHead: true,
|
|
|
|
|
isSelected: false,
|
|
|
|
|
isUnselected: false
|
2016-10-05 12:57:22 +00:00
|
|
|
|
};
|
2016-09-28 10:12:13 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
decorateLineForInlineView(line, id, conflict) {
|
|
|
|
|
const { type } = line;
|
|
|
|
|
line.id = id;
|
|
|
|
|
line.hasConflict = conflict;
|
|
|
|
|
line.isHead = type === 'new';
|
|
|
|
|
line.isOrigin = type === 'old';
|
|
|
|
|
line.hasMatch = type === 'match';
|
|
|
|
|
line.richText = line.rich_text;
|
|
|
|
|
line.isSelected = 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
|
2016-10-05 12:57:22 +00:00
|
|
|
|
};
|
2016-09-28 10:12:13 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getOriginHeaderLine(id) {
|
|
|
|
|
return {
|
|
|
|
|
id: id,
|
|
|
|
|
richText: ORIGIN_HEADER_TEXT,
|
|
|
|
|
buttonTitle: ORIGIN_BUTTON_TITLE,
|
|
|
|
|
type: 'old',
|
|
|
|
|
section: 'origin',
|
|
|
|
|
isHeader: true,
|
|
|
|
|
isOrigin: true,
|
|
|
|
|
isSelected: false,
|
|
|
|
|
isUnselected: false
|
2016-10-05 12:57:22 +00:00
|
|
|
|
};
|
2016-09-28 10:12:13 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getFilePath(file) {
|
|
|
|
|
const { old_path, new_path } = file;
|
|
|
|
|
return old_path === new_path ? new_path : `${old_path} → ${new_path}`;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
checkLineLengths(linesObj) {
|
2017-01-12 05:52:42 +00:00
|
|
|
|
const { left, right } = linesObj;
|
2016-09-28 10:12:13 +00:00
|
|
|
|
|
|
|
|
|
if (left.length !== right.length) {
|
|
|
|
|
if (left.length > right.length) {
|
|
|
|
|
const diff = left.length - right.length;
|
2017-01-10 22:35:09 +00:00
|
|
|
|
for (let i = 0; i < diff; i += 1) {
|
2016-09-28 10:12:13 +00:00
|
|
|
|
right.push({ lineType: 'emptyLine', richText: '' });
|
|
|
|
|
}
|
2016-09-30 01:26:01 +00:00
|
|
|
|
} else {
|
2016-09-28 10:12:13 +00:00
|
|
|
|
const diff = right.length - left.length;
|
2017-01-10 22:35:09 +00:00
|
|
|
|
for (let i = 0; i < diff; i += 1) {
|
2016-09-28 10:12:13 +00:00
|
|
|
|
left.push({ lineType: 'emptyLine', richText: '' });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
setPromptConfirmationState(file, state) {
|
|
|
|
|
file.promptDiscardConfirmation = state;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
setFileResolveMode(file, mode) {
|
2016-09-30 01:26:01 +00:00
|
|
|
|
if (mode === INTERACTIVE_RESOLVE_MODE) {
|
|
|
|
|
file.showEditor = false;
|
|
|
|
|
} else if (mode === EDIT_RESOLVE_MODE) {
|
|
|
|
|
// Restore Interactive mode when switching to Edit mode
|
|
|
|
|
file.showEditor = true;
|
|
|
|
|
file.loadEditor = true;
|
2016-09-28 10:12:13 +00:00
|
|
|
|
file.resolutionData = {};
|
|
|
|
|
|
|
|
|
|
this.restoreFileLinesState(file);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
file.resolveMode = mode;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
restoreFileLinesState(file) {
|
|
|
|
|
file.inlineLines.forEach((line) => {
|
|
|
|
|
if (line.hasConflict || line.isHeader) {
|
|
|
|
|
line.isSelected = false;
|
|
|
|
|
line.isUnselected = false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
file.parallelLines.forEach((lines) => {
|
2016-09-30 01:26:01 +00:00
|
|
|
|
const left = lines[0];
|
|
|
|
|
const right = lines[1];
|
|
|
|
|
const isLeftMatch = left.hasConflict || left.isHeader;
|
2016-09-28 10:12:13 +00:00
|
|
|
|
const isRightMatch = right.hasConflict || right.isHeader;
|
|
|
|
|
|
|
|
|
|
if (isLeftMatch || isRightMatch) {
|
|
|
|
|
left.isSelected = false;
|
|
|
|
|
left.isUnselected = false;
|
|
|
|
|
right.isSelected = false;
|
|
|
|
|
right.isUnselected = false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
isReadyToCommit() {
|
2018-06-16 21:50:13 +00:00
|
|
|
|
const { files } = this.state.conflictsData;
|
2016-09-28 10:12:13 +00:00
|
|
|
|
const hasCommitMessage = $.trim(this.state.conflictsData.commitMessage).length;
|
|
|
|
|
let unresolved = 0;
|
|
|
|
|
|
2017-01-10 22:35:09 +00:00
|
|
|
|
for (let i = 0, l = files.length; i < l; i += 1) {
|
2017-01-12 05:52:42 +00:00
|
|
|
|
const file = files[i];
|
2016-09-28 10:12:13 +00:00
|
|
|
|
|
|
|
|
|
if (file.resolveMode === INTERACTIVE_RESOLVE_MODE) {
|
|
|
|
|
let numberConflicts = 0;
|
2017-01-12 05:52:42 +00:00
|
|
|
|
const resolvedConflicts = Object.keys(file.resolutionData).length;
|
2016-09-28 10:12:13 +00:00
|
|
|
|
|
2016-10-05 12:57:57 +00:00
|
|
|
|
// We only check for conflicts type 'text'
|
|
|
|
|
// since conflicts `text_editor` can´t be resolved in interactive mode
|
2016-09-30 01:26:01 +00:00
|
|
|
|
if (file.type === CONFLICT_TYPES.TEXT) {
|
2017-01-10 22:35:09 +00:00
|
|
|
|
for (let j = 0, k = file.sections.length; j < k; j += 1) {
|
2016-09-30 01:26:01 +00:00
|
|
|
|
if (file.sections[j].conflict) {
|
2017-01-10 22:35:09 +00:00
|
|
|
|
numberConflicts += 1;
|
2016-09-30 01:26:01 +00:00
|
|
|
|
}
|
2016-09-28 10:12:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-09-30 01:26:01 +00:00
|
|
|
|
if (resolvedConflicts !== numberConflicts) {
|
2017-01-10 22:35:09 +00:00
|
|
|
|
unresolved += 1;
|
2016-09-30 01:26:01 +00:00
|
|
|
|
}
|
2016-09-28 10:12:13 +00:00
|
|
|
|
}
|
|
|
|
|
} else if (file.resolveMode === EDIT_RESOLVE_MODE) {
|
|
|
|
|
// Unlikely to happen since switching to Edit mode saves content automatically.
|
|
|
|
|
// Checking anyway in case the save strategy changes in the future
|
|
|
|
|
if (!file.content) {
|
2017-01-10 22:35:09 +00:00
|
|
|
|
unresolved += 1;
|
2016-09-28 10:12:13 +00:00
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return !this.state.isSubmitting && hasCommitMessage && !unresolved;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getCommitButtonText() {
|
2018-05-11 19:41:46 +00:00
|
|
|
|
const initial = 'Commit to source branch';
|
2016-09-28 10:12:13 +00:00
|
|
|
|
const inProgress = 'Committing...';
|
|
|
|
|
|
|
|
|
|
return this.state ? this.state.isSubmitting ? inProgress : initial : initial;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getCommitData() {
|
|
|
|
|
let commitData = {};
|
|
|
|
|
|
|
|
|
|
commitData = {
|
|
|
|
|
commit_message: this.state.conflictsData.commitMessage,
|
|
|
|
|
files: []
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.state.conflictsData.files.forEach((file) => {
|
2017-01-12 05:52:42 +00:00
|
|
|
|
const addFile = {
|
2016-09-28 10:12:13 +00:00
|
|
|
|
old_path: file.old_path,
|
|
|
|
|
new_path: file.new_path
|
|
|
|
|
};
|
|
|
|
|
|
2016-09-30 01:26:01 +00:00
|
|
|
|
if (file.type === CONFLICT_TYPES.TEXT) {
|
|
|
|
|
// Submit only one data for type of editing
|
|
|
|
|
if (file.resolveMode === INTERACTIVE_RESOLVE_MODE) {
|
|
|
|
|
addFile.sections = file.resolutionData;
|
|
|
|
|
} else if (file.resolveMode === EDIT_RESOLVE_MODE) {
|
|
|
|
|
addFile.content = file.content;
|
|
|
|
|
}
|
|
|
|
|
} else if (file.type === CONFLICT_TYPES.TEXT_EDITOR) {
|
2016-09-28 10:12:13 +00:00
|
|
|
|
addFile.content = file.content;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
commitData.files.push(addFile);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return commitData;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
handleSelected(file, sectionId, selection) {
|
|
|
|
|
Vue.set(file.resolutionData, sectionId, selection);
|
|
|
|
|
|
2016-09-30 01:26:01 +00:00
|
|
|
|
file.inlineLines.forEach((line) => {
|
|
|
|
|
if (line.id === sectionId && (line.hasConflict || line.isHeader)) {
|
|
|
|
|
this.markLine(line, selection);
|
|
|
|
|
}
|
|
|
|
|
});
|
2016-09-28 10:12:13 +00:00
|
|
|
|
|
2016-09-30 01:26:01 +00:00
|
|
|
|
file.parallelLines.forEach((lines) => {
|
|
|
|
|
const left = lines[0];
|
|
|
|
|
const right = lines[1];
|
|
|
|
|
const hasSameId = right.id === sectionId || left.id === sectionId;
|
|
|
|
|
const isLeftMatch = left.hasConflict || left.isHeader;
|
|
|
|
|
const isRightMatch = right.hasConflict || right.isHeader;
|
2016-09-28 10:12:13 +00:00
|
|
|
|
|
2016-09-30 01:26:01 +00:00
|
|
|
|
if (hasSameId && (isLeftMatch || isRightMatch)) {
|
|
|
|
|
this.markLine(left, selection);
|
|
|
|
|
this.markLine(right, selection);
|
|
|
|
|
}
|
2016-09-28 10:12:13 +00:00
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
markLine(line, selection) {
|
|
|
|
|
if (selection === 'head' && line.isHead) {
|
2016-09-30 01:26:01 +00:00
|
|
|
|
line.isSelected = true;
|
2016-09-28 10:12:13 +00:00
|
|
|
|
line.isUnselected = false;
|
2016-09-30 01:26:01 +00:00
|
|
|
|
} else if (selection === 'origin' && line.isOrigin) {
|
|
|
|
|
line.isSelected = true;
|
2016-09-28 10:12:13 +00:00
|
|
|
|
line.isUnselected = false;
|
2016-09-30 01:26:01 +00:00
|
|
|
|
} else {
|
|
|
|
|
line.isSelected = false;
|
2016-09-28 10:12:13 +00:00
|
|
|
|
line.isUnselected = true;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
setSubmitState(state) {
|
|
|
|
|
this.state.isSubmitting = state;
|
2016-09-30 21:23:38 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
fileTextTypePresent() {
|
2016-10-04 08:24:44 +00:00
|
|
|
|
return this.state.conflictsData.files.some(f => f.type === CONFLICT_TYPES.TEXT);
|
2016-09-28 10:12:13 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
})(window.gl || (window.gl = {}));
|