diff --git a/editor/js/main.js b/editor/js/main.js index bd41a2ca4..4573d57aa 100644 --- a/editor/js/main.js +++ b/editor/js/main.js @@ -43,9 +43,13 @@ $(".palette-scroll").removeClass("hide"); $("#palette-search").removeClass("hide"); loadFlows(function() { - RED.projects.refresh(function() { + if (RED.settings.theme("projects.enabled",true)) { + RED.projects.refresh(function() { + RED.sidebar.info.refresh() + }); + } else { RED.sidebar.info.refresh() - }); + } var persistentNotifications = {}; RED.comms.subscribe("notification/#",function(topic,msg) { @@ -65,15 +69,15 @@ RED.view.redraw(true); RED.projects.refresh(function() { loadFlows(function() { - console.log(msg); var project = RED.projects.getActiveProject(); var message = { "change-branch":"Change to local branch '"+project.git.branches.local+"'", "abort-merge":"Git merge aborted", "loaded":"Project '"+msg.project+"' loaded", "updated":"Project '"+msg.project+"' updated", - "pull":"Project '"+msg.project+"' reloaded" - }[msg.action] + "pull":"Project '"+msg.project+"' reloaded", + "revert": "Project '"+msg.project+"' reloaded" + }[msg.action]; RED.notify(message); RED.sidebar.info.refresh() }); @@ -213,12 +217,13 @@ function loadEditor() { var menuOptions = []; - - menuOptions.push({id:"menu-item-projects-menu",label:"NLS: Projects",options:[ - {id:"menu-item-projects-new",label:"New...",disabled:false,onselect:"core:new-project"}, - {id:"menu-item-projects-open",label:"Open...",disabled:false,onselect:"core:open-project"}, - {id:"menu-item-projects-delete",label:"Delete...",disabled:false,onselect:"core:delete-project"}, - ]}); + if (RED.settings.theme("projects.enabled",true)) { + menuOptions.push({id:"menu-item-projects-menu",label:"NLS: Projects",options:[ + {id:"menu-item-projects-new",label:"New...",disabled:false,onselect:"core:new-project"}, + {id:"menu-item-projects-open",label:"Open...",disabled:false,onselect:"core:open-project"}, + {id:"menu-item-projects-delete",label:"Delete...",disabled:false,onselect:"core:delete-project"}, + ]}); + } menuOptions.push({id:"menu-item-view-menu",label:RED._("menu.label.view.view"),options:[ @@ -283,10 +288,18 @@ RED.palette.init(); if (RED.settings.theme('palette.editable') !== false) { RED.palette.editor.init(); + } else { + console.log("Palette editor disabled"); } RED.sidebar.init(); - RED.projects.init(); + + if (RED.settings.theme("projects.enabled",true)) { + RED.projects.init(); + } else { + console.log("Palette editor disabled"); + } + RED.subflow.init(); RED.workspaces.init(); RED.clipboard.init(); diff --git a/editor/js/ui/diff.js b/editor/js/ui/diff.js index 8e9fdbbd3..0d8a5cfbd 100644 --- a/editor/js/ui/diff.js +++ b/editor/js/ui/diff.js @@ -1678,9 +1678,10 @@ RED.diff = (function() { function createUnifiedDiffTable(files,commitOptions) { var diffPanel = $('
'); + console.log(files); files.forEach(function(file) { var hunks = file.hunks; - + var isBinary = file.binary; var codeTable = $("').appendTo(diffBinaryRow); + $('').text("Cannot show binary file contents").appendTo(binaryContent); - hunks.forEach(function(hunk) { - var diffRow = $(' | |||||
').appendTo(diffRow); - var label = $('').text(hunk.header).appendTo(content); - var isConflict = hunk.conflict; - var localLine = hunk.localStartLine; - var remoteLine = hunk.remoteStartLine; - if (isConflict) { - unresolvedConflicts++; - } - - hunk.lines.forEach(function(lineText,lineNumber) { - // if (lineText[0] === '\\' || lineText === "") { - // // Comment line - bail out of this hunk - // break; - // } - - var actualLineNumber = hunk.diffStart + lineNumber; - var isMergeHeader = isConflict && /^..(<<<<<<<|=======$|>>>>>>>)/.test(lineText); - var diffRow = $(' | |||||
').appendTo(diffRow); - var remoteLineNo; - if (!isMergeHeader) { - remoteLineNo = $(' | ').appendTo(diffRow); - } else { - localLineNo.attr('colspan',2); - } - var line = $(' | ').appendTo(diffRow); - var prefixStart = 0; - var prefixEnd = 1; + } else { + hunks.forEach(function(hunk) { + var diffRow = $(' | |||
').appendTo(diffRow); + var label = $('').text(hunk.header).appendTo(content); + var isConflict = hunk.conflict; + var localLine = hunk.localStartLine; + var remoteLine = hunk.remoteStartLine; if (isConflict) { - prefixEnd = 2; + unresolvedConflicts++; } - if (!isMergeHeader) { - var changeMarker = lineText[0]; - if (isConflict && !commitOptions.unmerged && changeMarker === ' ') { - changeMarker = lineText[1]; - } - $('').text(changeMarker).appendTo(line); - var handledlLine = false; - if (isConflict && commitOptions.unmerged) { - $('').text(lineText[1]).appendTo(line); - if (lineText[0] === '+') { - localLineNo.text(localLine++); - handledlLine = true; - } - if (lineText[1] === '+') { - remoteLineNo.text(remoteLine++); - handledlLine = true; - } + + hunk.lines.forEach(function(lineText,lineNumber) { + // if (lineText[0] === '\\' || lineText === "") { + // // Comment line - bail out of this hunk + // break; + // } + + var actualLineNumber = hunk.diffStart + lineNumber; + var isMergeHeader = isConflict && /^..(<<<<<<<|=======$|>>>>>>>)/.test(lineText); + var diffRow = $(' | |||||
').appendTo(diffRow); + var remoteLineNo; + if (!isMergeHeader) { + remoteLineNo = $(' | ').appendTo(diffRow); } else { - if (lineText[0] === '+' || (isConflict && lineText[1] === '+')) { - localLineNo.addClass("added"); - remoteLineNo.addClass("added"); - line.addClass("added"); - remoteLineNo.text(remoteLine++); - handledlLine = true; - } else if (lineText[0] === '-' || (isConflict && lineText[1] === '-')) { - localLineNo.addClass("removed"); - remoteLineNo.addClass("removed"); - line.addClass("removed"); - localLineNo.text(localLine++); - handledlLine = true; - } + localLineNo.attr('colspan',2); } - if (!handledlLine) { - line.addClass("unchanged"); - if (localLine > 0 && lineText[0] !== '\\' && lineText !== "") { - localLineNo.text(localLine++); - } - if (remoteLine > 0 && lineText[0] !== '\\' && lineText !== "") { - remoteLineNo.text(remoteLine++); - } + var line = $(' | ').appendTo(diffRow);
+ var prefixStart = 0;
+ var prefixEnd = 1;
+ if (isConflict) {
+ prefixEnd = 2;
}
- $('').text(lineText.substring(prefixEnd)).appendTo(line);
- } else {
- diffRow.addClass("mergeHeader");
- var isSeparator = /^..(=======$)/.test(lineText);
- if (!isSeparator) {
- var isOurs = /^..<<<<<<').text("<<<<<<< Local Changes").appendTo(line);
- hunk.localChangeStart = actualLineNumber;
+ if (!isMergeHeader) {
+ var changeMarker = lineText[0];
+ if (isConflict && !commitOptions.unmerged && changeMarker === ' ') {
+ changeMarker = lineText[1];
+ }
+ $('').text(changeMarker).appendTo(line);
+ var handledlLine = false;
+ if (isConflict && commitOptions.unmerged) {
+ $('').text(lineText[1]).appendTo(line);
+ if (lineText[0] === '+') {
+ localLineNo.text(localLine++);
+ handledlLine = true;
+ }
+ if (lineText[1] === '+') {
+ remoteLineNo.text(remoteLine++);
+ handledlLine = true;
+ }
} else {
- hunk.remoteChangeEnd = actualLineNumber;
- $('').text(">>>>>>> Remote Changes").appendTo(line);
-
+ if (lineText[0] === '+' || (isConflict && lineText[1] === '+')) {
+ localLineNo.addClass("added");
+ remoteLineNo.addClass("added");
+ line.addClass("added");
+ remoteLineNo.text(remoteLine++);
+ handledlLine = true;
+ } else if (lineText[0] === '-' || (isConflict && lineText[1] === '-')) {
+ localLineNo.addClass("removed");
+ remoteLineNo.addClass("removed");
+ line.addClass("removed");
+ localLineNo.text(localLine++);
+ handledlLine = true;
+ }
}
- diffRow.addClass("mergeHeader-"+(isOurs?"ours":"theirs"));
- $('')
- .appendTo(line)
- .click(function(evt) {
- evt.preventDefault();
- resolvedConflicts++;
- var addedRows;
- var midRow;
- if (isOurs) {
- addedRows = diffRow.nextUntil(".mergeHeader-separator");
- midRow = addedRows.last().next();
- midRow.nextUntil(".mergeHeader").remove();
- midRow.next().remove();
- } else {
- addedRows = diffRow.prevUntil(".mergeHeader-separator");
- midRow = addedRows.last().prev();
- midRow.prevUntil(".mergeHeader").remove();
- midRow.prev().remove();
- }
- midRow.remove();
- diffRow.remove();
- addedRows.find(".linetext").addClass('added');
- conflictHeader.empty();
- $(''+resolvedConflicts+' of '+unresolvedConflicts+' conflicts resolved').appendTo(conflictHeader);
-
- conflictResolutions[file.file] = conflictResolutions[file.file] || {};
- conflictResolutions[file.file][hunk.localChangeStart] = {
- changeStart: hunk.localChangeStart,
- separator: hunk.changeSeparator,
- changeEnd: hunk.remoteChangeEnd,
- selection: isOurs?"A":"B"
- }
- if (commitOptions.resolveConflict) {
- commitOptions.resolveConflict({
- conflicts: unresolvedConflicts,
- resolved: resolvedConflicts,
- resolutions: conflictResolutions
- });
- }
- })
+ if (!handledlLine) {
+ line.addClass("unchanged");
+ if (localLine > 0 && lineText[0] !== '\\' && lineText !== "") {
+ localLineNo.text(localLine++);
+ }
+ if (remoteLine > 0 && lineText[0] !== '\\' && lineText !== "") {
+ remoteLineNo.text(remoteLine++);
+ }
+ }
+ $('').text(lineText.substring(prefixEnd)).appendTo(line);
} else {
- hunk.changeSeparator = actualLineNumber;
- diffRow.addClass("mergeHeader-separator");
+ diffRow.addClass("mergeHeader");
+ var isSeparator = /^..(=======$)/.test(lineText);
+ if (!isSeparator) {
+ var isOurs = /^..<<<<<<').text("<<<<<<< Local Changes").appendTo(line);
+ hunk.localChangeStart = actualLineNumber;
+ } else {
+ hunk.remoteChangeEnd = actualLineNumber;
+ $('').text(">>>>>>> Remote Changes").appendTo(line);
+
+ }
+ diffRow.addClass("mergeHeader-"+(isOurs?"ours":"theirs"));
+ $('')
+ .appendTo(line)
+ .click(function(evt) {
+ evt.preventDefault();
+ resolvedConflicts++;
+ var addedRows;
+ var midRow;
+ if (isOurs) {
+ addedRows = diffRow.nextUntil(".mergeHeader-separator");
+ midRow = addedRows.last().next();
+ midRow.nextUntil(".mergeHeader").remove();
+ midRow.next().remove();
+ } else {
+ addedRows = diffRow.prevUntil(".mergeHeader-separator");
+ midRow = addedRows.last().prev();
+ midRow.prevUntil(".mergeHeader").remove();
+ midRow.prev().remove();
+ }
+ midRow.remove();
+ diffRow.remove();
+ addedRows.find(".linetext").addClass('added');
+ conflictHeader.empty();
+ $(''+resolvedConflicts+' of '+unresolvedConflicts+' conflicts resolved').appendTo(conflictHeader);
+
+ conflictResolutions[file.file] = conflictResolutions[file.file] || {};
+ conflictResolutions[file.file][hunk.localChangeStart] = {
+ changeStart: hunk.localChangeStart,
+ separator: hunk.changeSeparator,
+ changeEnd: hunk.remoteChangeEnd,
+ selection: isOurs?"A":"B"
+ }
+ if (commitOptions.resolveConflict) {
+ commitOptions.resolveConflict({
+ conflicts: unresolvedConflicts,
+ resolved: resolvedConflicts,
+ resolutions: conflictResolutions
+ });
+ }
+ })
+ } else {
+ hunk.changeSeparator = actualLineNumber;
+ diffRow.addClass("mergeHeader-separator");
+ }
}
- }
+ });
});
- });
+ }
if (commitOptions.unmerged) {
conflictHeader = $(''+resolvedConflicts+' of '+unresolvedConflicts+' conflicts resolved').appendTo(content);
}
@@ -2041,7 +2048,9 @@ RED.diff = (function() {
} else {
lines = diff.split("\n");
}
+ var diffHeader = /^diff --git a\/(.*) b\/(.*)$/;
var fileHeader = /^\+\+\+ b\/(.*)\t?/;
+ var binaryFile = /^Binary files /;
var hunkHeader = /^@@ -((\d+)(,(\d+))?) \+((\d+)(,(\d+))?) @@ ?(.*)$/;
var conflictHunkHeader = /^@+ -((\d+)(,(\d+))?) -((\d+)(,(\d+))?) \+((\d+)(,(\d+))?) @+/;
var files = [];
@@ -2050,16 +2059,21 @@ RED.diff = (function() {
var currentHunk;
for (var i=0;i
').appendTo(row);
+ $('').appendTo(container);
+ $('').text(entry.name).appendTo(container);
+ // if (entry.commit) {
+ // $('').text(entry.commit.sha).appendTo(container);
+ // }
+
+ if (entry.remote) {
+ $('').text(entry.remote||"").appendTo(container);
+ if (entry.status.ahead+entry.status.behind > 0) {
+ $(''+
+ ' '+entry.status.ahead+' '+
+ ' '+entry.status.behind+''+
+ '').appendTo(container);
+ }
+ }
+
+ var tools = $('').appendTo(container);
+ if (entry.current) {
+ tools.text('current');
+ } else {
+ $('')
+ .appendTo(tools)
+ .click(function(e) {
+ e.preventDefault();
+ var spinner = utils.addSpinnerOverlay(row).addClass('projects-dialog-spinner-contain');
+ var notification = RED.notify("Are you sure you want to delete the local branch '"+entry.name+"'? This cannot be undone.", {
+ type: "warning",
+ modal: true,
+ fixed: true,
+ buttons: [
+ {
+ text: RED._("common.label.cancel"),
+ click: function() {
+ spinner.remove();
+ notification.close();
+ }
+ },{
+ text: 'Delete branch',
+ click: function() {
+ notification.close();
+ var url = "projects/"+activeProject.name+"/branches/"+entry.name;
+ var options = {
+ url: url,
+ type: "DELETE",
+ responses: {
+ 200: function(data) {
+ row.fadeOut(200,function() {
+ branchList.editableList('removeItem',entry);
+ spinner.remove();
+ });
+ },
+ 400: {
+ 'git_delete_branch_unmerged': function(error) {
+ notification = RED.notify("The local branch '"+entry.name+"' has unmerged changes that will be lost. Are you sure you want to delete it?", {
+ type: "warning",
+ modal: true,
+ fixed: true,
+ buttons: [
+ {
+ text: RED._("common.label.cancel"),
+ click: function() {
+ spinner.remove();
+ notification.close();
+ }
+ },{
+ text: 'Delete unmerged branch',
+ click: function() {
+ options.url += "?force=true";
+ notification.close();
+ utils.sendRequest(options);
+ }
+ }
+ ]
+ });
+ },
+ 'unexpected_error': function(error) {
+ console.log(error);
+ spinner.remove();
+ }
+ },
+ }
+ }
+ utils.sendRequest(options);
+ }
+ }
+
+ ]
+ })
+ })
+ }
+
+ }
+ });
+ $.getJSON("projects/"+activeProject.name+"/branches",function(result) {
+ if (result.branches) {
+ result.branches.sort(function(A,B) {
+ if (A.current) { return -1 }
+ if (B.current) { return 1 }
+ return A.name.localeCompare(B.name);
+ });
+ result.branches.forEach(function(branch) {
+ branchList.editableList('addItem',branch);
+ })
+ }
+ })
+ }
function createRemoteRepositorySection(activeProject,pane) {
- var title = $('').text("Version Control").appendTo(pane);
+ $('').text("Version Control").appendTo(pane);
+
+ createLocalBranchListSection(activeProject,pane);
+
+ var repoContainer = $('').appendTo(pane);
+ var title = $('').text("Git remotes").appendTo(repoContainer);
+
var editRepoButton = $('')
.appendTo(title)
.click(function(evt) {
@@ -958,9 +1086,9 @@ RED.projects.settings = (function() {
$('.projects-dialog-remote-list-entry-delete').show();
remoteListAddButton.show();
});
-
- var repoContainer = $('').appendTo(pane);
- var grTitle = $('').text("Git remotes").appendTo(repoContainer);
+
+
+
row = $('').appendTo(repoContainer);
var remotesList = $('
').appendTo(options.container);
@@ -1010,15 +1009,15 @@ RED.projects = (function() {
scrollOnAdd: false,
addItem: function(row,index,entry) {
var container = $(' |