diff --git a/editor/js/ui/diff.js b/editor/js/ui/diff.js
index 1f9a64f4a..171db8637 100644
--- a/editor/js/ui/diff.js
+++ b/editor/js/ui/diff.js
@@ -21,15 +21,9 @@ RED.diff = (function() {
RED.keyboard.add("*","ctrl-shift-f 3","core:show-test-flow-diff-3");
}
-
- function buildDiffPanel(container) {
- var diffPanel = $('
",{class:"node-diff-property-wires"})
@@ -917,7 +1084,7 @@ RED.diff = (function() {
if (diff === undefined) {
getRemoteDiff(showRemoteDiff);
} else {
- showDiff(diff);
+ showDiff(diff,{mode:'merge'});
}
}
function parseNodes(nodeList) {
@@ -1054,10 +1221,12 @@ RED.diff = (function() {
return diff;
}
- function showDiff(diff) {
+ function showDiff(diff,options) {
if (diffVisible) {
return;
}
+ options = options || {};
+ var mode = options.mode || 'merge';
var localDiff = diff.localDiff;
var remoteDiff = diff.remoteDiff;
@@ -1065,15 +1234,56 @@ RED.diff = (function() {
currentDiff = diff;
var trayOptions = {
- title: "Review Changes", //TODO: nls
+ title: options.title||"Review Changes", //TODO: nls
width: Infinity,
+ overlay: true,
buttons: [
{
- text: RED._("common.label.cancel"),
+ text: RED._((options.mode === 'merge')?"common.label.cancel":"common.label.close"),
click: function() {
RED.tray.close();
}
- },
+ }
+ ],
+ resize: function(dimensions) {
+ // trayWidth = dimensions.width;
+ },
+ open: function(tray) {
+ var trayBody = tray.find('.editor-tray-body');
+ var diffTable = buildDiffPanel(trayBody,diff,options);
+ diffTable.list.hide();
+ if (remoteDiff) {
+ $("#node-diff-view-diff-merge").show();
+ if (Object.keys(conflicts).length === 0) {
+ $("#node-diff-view-diff-merge").removeClass('disabled');
+ } else {
+ $("#node-diff-view-diff-merge").addClass('disabled');
+ }
+ } else {
+ $("#node-diff-view-diff-merge").hide();
+ }
+ refreshConflictHeader();
+ // console.log("--------------");
+ // console.log(localDiff);
+ // console.log(remoteDiff);
+
+ setTimeout(function() {
+ diffTable.finish();
+ diffTable.list.show();
+ },300);
+ $("#sidebar-shade").show();
+ },
+ close: function() {
+ diffVisible = false;
+ $("#sidebar-shade").hide();
+
+ },
+ show: function() {
+
+ }
+ }
+ if (options.mode === 'merge') {
+ trayOptions.buttons.push(
{
id: "node-diff-view-diff-merge",
text: RED._("deploy.confirm.button.merge"),
@@ -1086,189 +1296,9 @@ RED.diff = (function() {
}
}
}
- ],
- resize: function(dimensions) {
- // trayWidth = dimensions.width;
- },
- open: function(tray) {
- var trayBody = tray.find('.editor-tray-body');
- var diffPanel = buildDiffPanel(trayBody);
- if (remoteDiff) {
- $("#node-diff-view-diff-merge").show();
- if (Object.keys(conflicts).length === 0) {
- $("#node-diff-view-diff-merge").removeClass('disabled');
- } else {
- $("#node-diff-view-diff-merge").addClass('disabled');
- }
- } else {
- $("#node-diff-view-diff-merge").hide();
- }
- refreshConflictHeader();
-
- $("#node-dialog-view-diff-headers").empty();
- // console.log("--------------");
- // console.log(localDiff);
- // console.log(remoteDiff);
- var currentConfig = localDiff.currentConfig;
- var newConfig = localDiff.newConfig;
- conflicts = conflicts || {};
-
- var el = {
- diff: localDiff,
- def: {
- category: 'config',
- color: '#f0f0f0'
- },
- tab: {
- n: {},
- nodes: currentConfig.globals
- },
- newTab: {
- n: {},
- nodes: newConfig.globals
- }
- };
-
- if (remoteDiff !== undefined) {
- diffPanel.addClass('node-diff-three-way');
-
- $('
').i18n().appendTo("#node-dialog-view-diff-headers");
- el.remoteTab = {
- n:{},
- nodes:remoteDiff.newConfig.globals
- };
- el.remoteDiff = remoteDiff;
- } else {
- diffPanel.removeClass('node-diff-three-way');
- }
-
- diffList.editableList('addItem',el);
-
- var seenTabs = {};
-
- currentConfig.tabOrder.forEach(function(tabId) {
- var tab = currentConfig.tabs[tabId];
- var el = {
- diff: localDiff,
- def: RED.nodes.getType('tab'),
- tab:tab
- };
- if (newConfig.tabs.hasOwnProperty(tabId)) {
- el.newTab = newConfig.tabs[tabId];
- }
- if (remoteDiff !== undefined) {
- el.remoteTab = remoteDiff.newConfig.tabs[tabId];
- el.remoteDiff = remoteDiff;
- }
- seenTabs[tabId] = true;
- diffList.editableList('addItem',el)
- });
- newConfig.tabOrder.forEach(function(tabId) {
- if (!seenTabs[tabId]) {
- seenTabs[tabId] = true;
- var tab = newConfig.tabs[tabId];
- var el = {
- diff: localDiff,
- def: RED.nodes.getType('tab'),
- tab:tab,
- newTab: tab
- };
- if (remoteDiff !== undefined) {
- el.remoteDiff = remoteDiff;
- }
- diffList.editableList('addItem',el)
- }
- });
- if (remoteDiff !== undefined) {
- remoteDiff.newConfig.tabOrder.forEach(function(tabId) {
- if (!seenTabs[tabId]) {
- var tab = remoteDiff.newConfig.tabs[tabId];
- // TODO how to recognise this is a remotely added flow
- var el = {
- diff: localDiff,
- remoteDiff: remoteDiff,
- def: RED.nodes.getType('tab'),
- tab:tab,
- remoteTab:tab
- };
- diffList.editableList('addItem',el)
- }
- });
- }
- var subflowId;
- for (subflowId in currentConfig.subflows) {
- if (currentConfig.subflows.hasOwnProperty(subflowId)) {
- seenTabs[subflowId] = true;
- el = {
- diff: localDiff,
- def: {
- defaults:{},
- icon:"subflow.png",
- category: "subflows",
- color: "#da9"
- },
- tab:currentConfig.subflows[subflowId]
- }
- if (newConfig.subflows.hasOwnProperty(subflowId)) {
- el.newTab = newConfig.subflows[subflowId];
- }
- if (remoteDiff !== undefined) {
- el.remoteTab = remoteDiff.newConfig.subflows[subflowId];
- el.remoteDiff = remoteDiff;
- }
- diffList.editableList('addItem',el)
- }
- }
- for (subflowId in newConfig.subflows) {
- if (newConfig.subflows.hasOwnProperty(subflowId) && !seenTabs[subflowId]) {
- seenTabs[subflowId] = true;
- el = {
- diff: localDiff,
- def: {
- defaults:{},
- icon:"subflow.png",
- category: "subflows",
- color: "#da9"
- },
- tab:newConfig.subflows[subflowId],
- newTab:newConfig.subflows[subflowId]
- }
- if (remoteDiff !== undefined) {
- el.remoteDiff = remoteDiff;
- }
- diffList.editableList('addItem',el)
- }
- }
- if (remoteDiff !== undefined) {
- for (subflowId in remoteDiff.newConfig.subflows) {
- if (remoteDiff.newConfig.subflows.hasOwnProperty(subflowId) && !seenTabs[subflowId]) {
- el = {
- diff: localDiff,
- remoteDiff: remoteDiff,
- def: {
- defaults:{},
- icon:"subflow.png",
- category: "subflows",
- color: "#da9"
- },
- tab:remoteDiff.newConfig.subflows[subflowId],
- remoteTab: remoteDiff.newConfig.subflows[subflowId]
- }
- diffList.editableList('addItem',el)
- }
- }
- }
- $("#sidebar-shade").show();
- },
- close: function() {
- diffVisible = false;
- $("#sidebar-shade").hide();
-
- },
- show: function() {
-
- }
+ );
}
+
RED.tray.show(trayOptions);
}
@@ -1374,7 +1404,7 @@ RED.diff = (function() {
overlay: true,
buttons: [
{
- text: RED._("common.label.done"),
+ text: RED._("common.label.close"),
click: function() {
RED.tray.close();
}
@@ -1646,7 +1676,7 @@ RED.diff = (function() {
return string1 === string2 ? 0 : 1;
}
- function createUnifiedDiffTable(files) {
+ function createUnifiedDiffTable(files,commitOptions) {
var diffPanel = $('
');
files.forEach(function(file) {
var hunks = file.hunks;
@@ -1655,10 +1685,61 @@ RED.diff = (function() {
$('
').appendTo(codeTable);
var codeBody = $('
').appendTo(codeTable);
- var diffRow = $('").insertAfter(diffRow);
+ // var content = $(' | ').appendTo(flowDiffRow);
+ // currentDiff = diff;
+ // var diffTable = buildDiffPanel(content,diff,{mode:"view"}).finish();
+ });
+ })
+ }
+
+
for (var i=0;i