1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Disable view-diff button for deletes/unknown files

This commit is contained in:
Nick O'Leary 2017-10-09 12:10:00 +01:00
parent 10567afbb9
commit eae390acf5
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
4 changed files with 48 additions and 10 deletions

View File

@ -22,11 +22,17 @@ RED.stack = (function() {
var entries = [];
var visible = true;
// TODO: make this a singleton function - and watch out for stacks no longer
// in the DOM
var resizeStack = function() {
if (entries.length > 0) {
var headerHeight = entries[0].header.outerHeight();
var headerHeight = 0;
entries.forEach(function(entry) {
headerHeight += entry.header.outerHeight();
});
var height = container.innerHeight();
contentHeight = height - entries.length*headerHeight - (entries.length-1);
contentHeight = height - headerHeight - (entries.length-1);
entries.forEach(function(e) {
e.contentWrap.height(contentHeight);
});

View File

@ -37,11 +37,18 @@ RED.sidebar.versionControl = (function() {
function createChangeEntry(row, entry, status, unstaged) {
row.addClass("sidebar-version-control-change-entry");
var container = $('<div>').appendTo(row);
if (entry.label) {
row.addClass('node-info-none');
container.text(entry.label);
return;
}
var icon = $('<i class=""></i>').appendTo(container);
var label = $('<span>').appendTo(container);
var bg = $('<div class="button-group"></div>').appendTo(row);
$('<button class="editor-button editor-button-small"><i class="fa fa-eye"></i></button>')
var viewDiffButton = $('<button class="editor-button editor-button-small"><i class="fa fa-eye"></i></button>')
.appendTo(bg)
.click(function(evt) {
evt.preventDefault();
@ -131,6 +138,12 @@ RED.sidebar.versionControl = (function() {
entry.spinner.remove();
delete entry.spinner;
}
viewDiffButton.attr("disabled",(status === 'D' || status === '?'));
viewDiffButton.find("i")
.toggleClass('fa-eye',!(status === 'D' || status === '?'))
.toggleClass('fa-eye-slash',(status === 'D' || status === '?'))
}
entry["update"+(unstaged?"Unstaged":"Staged")](entry, status);
}
@ -156,7 +169,7 @@ RED.sidebar.versionControl = (function() {
localChanges.content.css({height:"100%"});
var bg = $('<div style="float: right"></div>').appendTo(localChanges.header);
$('<button class="sidebar-header-button"><i class="fa fa-refresh"></i></button>')
$('<button class="editor-button editor-button-small"><i class="fa fa-refresh"></i></button>')
.appendTo(bg)
.click(function(evt) {
evt.preventDefault();
@ -208,6 +221,7 @@ RED.sidebar.versionControl = (function() {
submitCommitButton.attr("disabled",true);
unstagedContent.css("height","30px");
stagedContent.css("height","calc(100% - 30px - 175px)");
commitBox.show();
commitBox.css("height","175px");
stageAllButton.attr("disabled",true);
unstageAllButton.attr("disabled",true);
@ -239,7 +253,7 @@ RED.sidebar.versionControl = (function() {
}
})
commitBox = $('<div class="sidebar-version-control-change-commit-box"></div>').appendTo(localChanges.content);
commitBox = $('<div class="sidebar-version-control-change-commit-box"></div>').hide().appendTo(localChanges.content);
var commitMessage = $('<textarea>')
.appendTo(commitBox)
@ -256,6 +270,9 @@ RED.sidebar.versionControl = (function() {
unstagedContent.css("height","");
stagedContent.css("height","");
commitBox.css("height","");
setTimeout(function() {
commitBox.hide();
},200);
stageAllButton.attr("disabled",false);
unstageAllButton.attr("disabled",false);
commitButton.attr("disabled",false);
@ -350,13 +367,16 @@ RED.sidebar.versionControl = (function() {
var refreshInProgress = false;
var emptyStagedItem = { label:"None" };
function refreshFiles(result) {
if (bulkChangeSpinner) {
bulkChangeSpinner.remove();
bulkChangeSpinner = null;
}
// unstagedChangesList.editableList('empty');
// stagedChangesList.editableList('empty');
unstagedChangesList.editableList('removeItem',emptyStagedItem);
stagedChangesList.editableList('removeItem',emptyStagedItem);
var fileNames = Object.keys(result).filter(function(f) { return result[f].type === 'f'})
fileNames.sort();
var updateIndex = Date.now()+Math.floor(Math.random()*100);
@ -425,6 +445,14 @@ RED.sidebar.versionControl = (function() {
stageAllButton.attr('disabled',unstagedCount === 0);
unstageAllButton.attr('disabled',stagedCount === 0);
if (stagedCount === 0) {
stagedChangesList.editableList('addItem',emptyStagedItem);
}
if (unstagedCount === 0) {
unstagedChangesList.editableList('addItem',emptyStagedItem);
}
}
function refresh(full) {

View File

@ -115,10 +115,10 @@ RED.tray = (function() {
$("#editor-shade").show();
$("#palette-shade").show();
$(".sidebar-shade").show();
tray.preferredWidth = Math.max(el.width(),500);
body.css({"minWidth":tray.preferredWidth-40});
if (!options.maximized) {
body.css({"minWidth":tray.preferredWidth-40});
}
if (options.width) {
if (options.width > $("#editor-stack").position().left-8) {
options.width = $("#editor-stack").position().left-8;

View File

@ -318,6 +318,10 @@
display: block;
}
}
&.node-info-none {
text-align: center;
background: #fefefe;
}
}
.sidebar-version-control-change-header {
color: #666;