Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge UI bug fixes and links #425

Merged
merged 3 commits into from
Jun 25, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 56 additions & 9 deletions src/client/js/Dialogs/Merge/MergeDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,28 @@ define([
};

MergeDialog.prototype._addDiff = function (mergeResult) {
var diff = $(diffTemplate),
var self = this,
diff = $(diffTemplate),
conflictsE,
conflictItem,
conflictItemTemplate = $('<div class="row conflict-item">' +
'<div class="col-md-6 path"></div>' +
'<div class="col-md-3 value-theirs"></div>' +
'<div class="col-md-3 value-mine"></div>' +
'</div>'),
'<div class="col-md-6 path"></div>' +
'<div class="col-md-3 value-theirs"></div>' +
'<div class="col-md-3 value-mine"></div>' +
'</div>'),
conflictItemE,
i;
mineText,
valueMineE,
valueTheirsE,
linkTheirs,
linkMine,
i,

// FIXME: HACK
// regular expression matching:
// /1/2/3/4/5/attr/name -> '/1/2/3/4/5' -> nodeId
// /attr/name -> '' -> root node
pathRegExp = /((\/\d+)*)/;

this.resolution = mergeResult;

Expand Down Expand Up @@ -153,8 +165,37 @@ define([
conflictItem = mergeResult.conflict.items[i];
conflictItemE = conflictItemTemplate.clone();
conflictItemE.find('.path').text(conflictItem.theirs.path);
conflictItemE.find('.value-theirs').text(JSON.stringify(conflictItem.theirs.value));
conflictItemE.find('.value-mine').text(JSON.stringify(conflictItem.mine.value));

linkTheirs = '?project=' + encodeURIComponent(self._client.getActiveProjectName()) +
'&commit=' + encodeURIComponent(mergeResult.theirCommitHash) +
// FIXME: regexp parses out the path
'&node=' + encodeURIComponent(pathRegExp.exec(conflictItem.theirs.path)[0]);

valueTheirsE = $('<div>' +
// FIXME: should we use fa-link instead ???
'<a class="fa fa-eye" href="' + linkTheirs + '" target="_blank" tooltip="Open"></a>' +
'<span>' + JSON.stringify(conflictItem.theirs.value) + '</span>' +
'</div>');

conflictItemE.find('.value-theirs').append(valueTheirsE);

if (conflictItem.theirs.path === conflictItem.mine.path) {
mineText = JSON.stringify(conflictItem.mine.value);
} else {
mineText = conflictItem.mine.path + ': ' + JSON.stringify(conflictItem.mine.value);
}

linkMine = '?project=' + encodeURIComponent(self._client.getActiveProjectName()) +
'&commit=' + encodeURIComponent(mergeResult.myCommitHash) +
'&node=' + encodeURIComponent(pathRegExp.exec(conflictItem.mine.path)[0]); // FIXME: regexp parses out the path

valueMineE = $('<div>' +
// FIXME: should we use fa-link instead ???
'<a class="fa fa-eye" href="' + linkMine + '" target="_blank" tooltip="Open"></a>' +
'<span>' + mineText + '</span>' +
'</div>');

conflictItemE.find('.value-mine').append(valueMineE);

this._updateSelection(conflictItem, conflictItemE);
this._addClickHandler(conflictItem, conflictItemE);
Expand All @@ -169,7 +210,13 @@ define([
MergeDialog.prototype._addClickHandler = function (conflictItem, conflictItemE) {
var self = this;

conflictItemE.on('click', function () {
conflictItemE.on('click', function (event) {

if (event.target.tagName === 'A') {
// clicked on an A tag we do not need to change the selection.
return;
}

if (conflictItem.selected === 'mine') {
conflictItem.selected = 'theirs';
} else if (conflictItem.selected === 'theirs') {
Expand Down