Properly handle empty repos

This commit is contained in:
Joseph Schorr 2013-10-16 22:42:35 -04:00
parent 50929102b5
commit 0c3c1b9e0e

View file

@ -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);