Add placeholder when a repo has no local branches

This commit is contained in:
Nick O'Leary 2017-12-21 22:28:26 +00:00
parent 207d3d3340
commit 6013e186ed
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
1 changed files with 17 additions and 8 deletions

View File

@ -964,6 +964,11 @@ RED.projects.settings = (function() {
scrollOnAdd: false, scrollOnAdd: false,
addItem: function(row,index,entry) { addItem: function(row,index,entry) {
var container = $('<div class="projects-dialog-list-entry">').appendTo(row); var container = $('<div class="projects-dialog-list-entry">').appendTo(row);
if (entry.empty) {
container.addClass('red-ui-search-empty');
container.text("No branches");
return;
}
if (entry.current) { if (entry.current) {
container.addClass("current"); container.addClass("current");
} }
@ -1064,14 +1069,18 @@ RED.projects.settings = (function() {
$.getJSON("projects/"+activeProject.name+"/branches",function(result) { $.getJSON("projects/"+activeProject.name+"/branches",function(result) {
if (result.branches) { if (result.branches) {
result.branches.sort(function(A,B) { if (result.branches.length > 0) {
if (A.current) { return -1 } result.branches.sort(function(A,B) {
if (B.current) { return 1 } if (A.current) { return -1 }
return A.name.localeCompare(B.name); if (B.current) { return 1 }
}); return A.name.localeCompare(B.name);
result.branches.forEach(function(branch) { });
branchList.editableList('addItem',branch); result.branches.forEach(function(branch) {
}) branchList.editableList('addItem',branch);
})
} else {
branchList.editableList('addItem',{empty:true});
}
} }
}) })
} }