mirror of https://github.com/perkeep/perkeep.git
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
This commit is contained in:
parent
1763efbefe
commit
41bdd85120
|
@ -30,7 +30,7 @@ limitations under the License.
|
|||
</head>
|
||||
<body class="cam-permanode-page">
|
||||
<div class="cam-permanode-nav"><a href="./" target="_top">Home</a></div>
|
||||
<h1>Permanode</h1>
|
||||
<h1 id="mainTitle">Permanode</h1>
|
||||
|
||||
<p>
|
||||
Permalink:
|
||||
|
|
|
@ -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 = "<a href='./?b=" + permanode + "'>Reload as blob</a>";
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue