Add PolyGerrit probe of /Documentation/index.html
Change-Id: I5817e033e1620e5f28a339e57699b366956037e5
This commit is contained in:
parent
f4a0eeb648
commit
0ed845c7de
@ -111,7 +111,6 @@
|
||||
},
|
||||
_docBaseUrl: {
|
||||
type: String,
|
||||
value: null,
|
||||
},
|
||||
_links: {
|
||||
type: Array,
|
||||
@ -220,10 +219,23 @@
|
||||
},
|
||||
|
||||
_loadConfig: function() {
|
||||
return this.$.restAPI.getConfig().then(function(config) {
|
||||
this.$.restAPI.getConfig().then(function(config) {
|
||||
if (config && config.gerrit) {
|
||||
this._docBaseUrl = config.gerrit.doc_url;
|
||||
}
|
||||
if (!this._docBaseUrl) {
|
||||
return this._probeDocLink('/Documentation/index.html');
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
_probeDocLink: function(path) {
|
||||
return this.$.restAPI.probePath(path).then(function(ok) {
|
||||
if (ok) {
|
||||
this._docBaseUrl = '/Documentation';
|
||||
} else {
|
||||
this._docBaseUrl = null;
|
||||
}
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
|
@ -41,6 +41,7 @@ limitations under the License.
|
||||
sandbox = sinon.sandbox.create();
|
||||
stub('gr-rest-api-interface', {
|
||||
getConfig: function() { return Promise.resolve({}); },
|
||||
probePath: function(path) { return Promise.resolve(false); },
|
||||
});
|
||||
stub('gr-main-header', {
|
||||
_loadAccount: function() {},
|
||||
@ -135,7 +136,7 @@ limitations under the License.
|
||||
var docLinks = [
|
||||
{
|
||||
name: 'Table of Contents',
|
||||
url: '/Documentation/index.html',
|
||||
url: '/index.html',
|
||||
},
|
||||
];
|
||||
|
||||
@ -147,13 +148,13 @@ limitations under the License.
|
||||
assert.deepEqual(element._getDocLinks('base', docLinks), [{
|
||||
name: 'Table of Contents',
|
||||
target: '_blank',
|
||||
url: 'base/Documentation/index.html',
|
||||
url: 'base/index.html',
|
||||
}]);
|
||||
|
||||
assert.deepEqual(element._getDocLinks('base/', docLinks), [{
|
||||
name: 'Table of Contents',
|
||||
target: '_blank',
|
||||
url: 'base/Documentation/index.html',
|
||||
url: 'base/index.html',
|
||||
}]);
|
||||
});
|
||||
});
|
||||
|
@ -1052,5 +1052,12 @@
|
||||
return this.send('DELETE',
|
||||
this.getChangeActionURL(changeNum, null, '/assignee'));
|
||||
},
|
||||
|
||||
probePath: function(path) {
|
||||
return fetch(new Request(path, {method: 'HEAD'}))
|
||||
.then(function(response) {
|
||||
return response.ok;
|
||||
});
|
||||
},
|
||||
});
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user