Merge "Update GWT footer link to be page specific"

This commit is contained in:
Andrew Bonventre 2016-09-30 10:52:26 +00:00 committed by Gerrit Code Review
commit 1b944dffd8
3 changed files with 27 additions and 1 deletions

View File

@ -129,7 +129,7 @@ limitations under the License.
target="_blank">Report PolyGerrit Bug</a>
<template is="dom-if" if="[[_computeShowGwtUiLink(_serverConfig)]]">
|
<a href="/?polygerrit=0" rel="external">GWT UI</a>
<a id="gwtLink" href$="/?polygerrit=0#[[_path]]" rel="external">GWT UI</a>
</template>
</footer>
<gr-overlay id="keyboardShortcuts" with-backdrop>

View File

@ -43,11 +43,13 @@
_showSettingsView: Boolean,
_viewState: Object,
_lastError: Object,
_path: String,
},
listeners: {
'page-error': '_handlePageError',
'title-change': '_handleTitleChange',
'location-change': '_handleLocationChange',
},
observers: [
@ -158,6 +160,15 @@
}
},
_handleLocationChange: function() {
var hash = location.hash.substring(1);
var pathname = location.pathname;
if (pathname.startsWith('/c/') && parseInt(hash, 10) > 0) {
pathname += '@' + hash;
}
this.set('_path', encodeURIComponent(pathname));
},
_handleTitleChange: function(e) {
if (e.detail.title) {
document.title = e.detail.title + ' · Gerrit Code Review';

View File

@ -39,6 +39,14 @@ limitations under the License.
stub('gr-reporting', {
appStarted: sandbox.stub(),
});
var config = {
gerrit: {web_uis: ['GWT', 'POLYGERRIT']},
plugin: {js_resource_paths: []},
};
stub('gr-rest-api-interface', {
getConfig: function() { return Promise.resolve(config); },
});
element = fixture('basic');
flush(done);
});
@ -49,5 +57,12 @@ limitations under the License.
test('reporting', function() {
assert.isTrue(element.$.reporting.appStarted.calledOnce);
});
test('location change updates gwt footer', function() {
element._path = '/test/path';
var gwtLink = element.$$('#gwtLink');
assert.equal(gwtLink.href,
'http://' + location.host + '/?polygerrit=0#/test/path');
});
});
</script>