From 41bdd85120d17756d601f6700dbc21a89ec94f27 Mon Sep 17 00:00:00 2001 From: mpl Date: Wed, 30 Jul 2014 00:50:53 +0200 Subject: [PATCH] ui/permanode: cope better with not a permanode case A camliPath can now have a file blob as a target (instead of a permanode). And when we render these camliPath members as links, since it can happen that these members haven't been described, we can't know in advance whether to link them as permanodes or as blobs, so we always default to permanode. Therefore, it can now legitimately happen that we end up on the permanode page, while the blobRef is actually one of a non permanode. This patch tries to cope with that situation in a bit nicer way. Context: http://camlistore.org/issue/470 Change-Id: Ic3b728541e164a6e6056d8f275a1d7e76b41e043 --- server/camlistored/ui/permanode.html | 2 +- server/camlistored/ui/permanode.js | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/server/camlistored/ui/permanode.html b/server/camlistored/ui/permanode.html index 342d29595..61a0e630f 100644 --- a/server/camlistored/ui/permanode.html +++ b/server/camlistored/ui/permanode.html @@ -30,7 +30,7 @@ limitations under the License.
Home
-

Permanode

+

Permanode

Permalink: diff --git a/server/camlistored/ui/permanode.js b/server/camlistored/ui/permanode.js index 0ace0522e..4b4f78633 100644 --- a/server/camlistored/ui/permanode.js +++ b/server/camlistored/ui/permanode.js @@ -74,8 +74,6 @@ cam.PermanodePage.prototype.enterDocument = function() { this.setupFilesHandlers_(); this.updateAll_(); - - this.buildPathsList_() }; // Gets the |p| query parameter, assuming that it looks like a blobref. @@ -130,10 +128,15 @@ cam.PermanodePage.prototype.describeBlob_ = function() { cam.PermanodePage.prototype.handleDescribeBlob_ = function(permanode, searchResponse) { var describeResult = searchResponse.description; var meta = describeResult.meta; - if (!meta[permanode]) { - alert(permanode + " was not described"); + if (!meta[permanode] || meta[permanode].camliType != 'permanode') { + // Cope with the case where we loaded that page but we're actually not on a permanode. + console.log(permanode + " was not described as a permanode."); + goog.dom.setTextContent(goog.dom.getElement('mainTitle'), 'Not described'); + goog.dom.getElement('permanode').innerHTML = ""; + goog.dom.getElement('permanodeBlob').innerHTML = "Reload as blob"; return; } + var permObj = meta[permanode].permanode; if (!permObj) { alert("blob " + permanode + " isn't a permanode"); @@ -196,6 +199,8 @@ cam.PermanodePage.prototype.handleDescribeBlob_ = function(permanode, searchResp // debug attrs goog.dom.setTextContent(goog.dom.getElement("debugattrs"), JSON.stringify(permObj.attr, null, 2)); + + this.buildPathsList_() }; // TODO(mpl): pass directly the permanode object