Properly handle empty repos
This commit is contained in:
parent
50929102b5
commit
0c3c1b9e0e
1 changed files with 10 additions and 4 deletions
|
@ -101,6 +101,10 @@ ImageHistoryTree.prototype.draw = function(container) {
|
|||
return html;
|
||||
}
|
||||
|
||||
if (!d.image) {
|
||||
return '(This repository is empty)';
|
||||
}
|
||||
|
||||
if (d.image.comment) {
|
||||
html += '<span class="comment">' + formatComment(d.image.comment) + '</span>';
|
||||
}
|
||||
|
@ -198,7 +202,7 @@ ImageHistoryTree.prototype.buildRoot_ = function() {
|
|||
// "name": "...",
|
||||
// "children": [...]
|
||||
// }
|
||||
var formatted = {};
|
||||
var formatted = {"name": "No images found"};
|
||||
|
||||
// Build a node for each image.
|
||||
var imageByDBID = {};
|
||||
|
@ -266,8 +270,10 @@ ImageHistoryTree.prototype.buildRoot_ = function() {
|
|||
*/
|
||||
ImageHistoryTree.prototype.determineMaximumHeight_ = function(node) {
|
||||
var maxHeight = 0;
|
||||
for (var i = 0; i < node.children.length; ++i) {
|
||||
maxHeight = Math.max(this.determineMaximumHeight_(node.children[i]), maxHeight);
|
||||
if (node.children) {
|
||||
for (var i = 0; i < node.children.length; ++i) {
|
||||
maxHeight = Math.max(this.determineMaximumHeight_(node.children[i]), maxHeight);
|
||||
}
|
||||
}
|
||||
return maxHeight + 1;
|
||||
};
|
||||
|
@ -476,7 +482,7 @@ ImageHistoryTree.prototype.update_ = function(source) {
|
|||
.attr("dy", ".35em")
|
||||
.attr("text-anchor", function(d) { return d.children || d._children ? "end" : "start"; })
|
||||
.text(function(d) { return d.name; })
|
||||
.on("click", function(d) { that.changeImage_(d.image.id); })
|
||||
.on("click", function(d) { if (d.image) { that.changeImage_(d.image.id); } })
|
||||
.on('mouseover', tip.show)
|
||||
.on('mouseout', tip.hide);
|
||||
|
||||
|
|
Reference in a new issue