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;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!d.image) {
|
||||||
|
return '(This repository is empty)';
|
||||||
|
}
|
||||||
|
|
||||||
if (d.image.comment) {
|
if (d.image.comment) {
|
||||||
html += '<span class="comment">' + formatComment(d.image.comment) + '</span>';
|
html += '<span class="comment">' + formatComment(d.image.comment) + '</span>';
|
||||||
}
|
}
|
||||||
|
@ -198,7 +202,7 @@ ImageHistoryTree.prototype.buildRoot_ = function() {
|
||||||
// "name": "...",
|
// "name": "...",
|
||||||
// "children": [...]
|
// "children": [...]
|
||||||
// }
|
// }
|
||||||
var formatted = {};
|
var formatted = {"name": "No images found"};
|
||||||
|
|
||||||
// Build a node for each image.
|
// Build a node for each image.
|
||||||
var imageByDBID = {};
|
var imageByDBID = {};
|
||||||
|
@ -266,9 +270,11 @@ ImageHistoryTree.prototype.buildRoot_ = function() {
|
||||||
*/
|
*/
|
||||||
ImageHistoryTree.prototype.determineMaximumHeight_ = function(node) {
|
ImageHistoryTree.prototype.determineMaximumHeight_ = function(node) {
|
||||||
var maxHeight = 0;
|
var maxHeight = 0;
|
||||||
|
if (node.children) {
|
||||||
for (var i = 0; i < node.children.length; ++i) {
|
for (var i = 0; i < node.children.length; ++i) {
|
||||||
maxHeight = Math.max(this.determineMaximumHeight_(node.children[i]), maxHeight);
|
maxHeight = Math.max(this.determineMaximumHeight_(node.children[i]), maxHeight);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return maxHeight + 1;
|
return maxHeight + 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -476,7 +482,7 @@ ImageHistoryTree.prototype.update_ = function(source) {
|
||||||
.attr("dy", ".35em")
|
.attr("dy", ".35em")
|
||||||
.attr("text-anchor", function(d) { return d.children || d._children ? "end" : "start"; })
|
.attr("text-anchor", function(d) { return d.children || d._children ? "end" : "start"; })
|
||||||
.text(function(d) { return d.name; })
|
.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('mouseover', tip.show)
|
||||||
.on('mouseout', tip.hide);
|
.on('mouseout', tip.hide);
|
||||||
|
|
||||||
|
|
Reference in a new issue