Remove dependency on gr-ajax from gr-app
Change-Id: Ifeda55aef692e73f74eadf7fdb4b5ba12e8a659e
diff --git a/polygerrit-ui/app/elements/gr-app.html b/polygerrit-ui/app/elements/gr-app.html
index d7c6c64..b1c084e 100644
--- a/polygerrit-ui/app/elements/gr-app.html
+++ b/polygerrit-ui/app/elements/gr-app.html
@@ -26,7 +26,6 @@
<link rel="import" href="./change/gr-change-view/gr-change-view.html">
<link rel="import" href="./diff/gr-diff-view/gr-diff-view.html">
-<link rel="import" href="./shared/gr-ajax/gr-ajax.html">
<link rel="import" href="./shared/gr-overlay/gr-overlay.html">
<link rel="import" href="./shared/gr-rest-api-interface/gr-rest-api-interface.html">
@@ -56,10 +55,6 @@
color: #b71c1c;
}
</style>
- <gr-ajax auto url="/config/server/version" last-response="{{version}}"></gr-ajax>
- <gr-ajax id="diffPreferencesXHR"
- url="/accounts/self/preferences.diff"
- last-response="{{_diffPreferences}}"></gr-ajax>
<gr-main-header search-query="{{params.query}}"></gr-main-header>
<main>
<template is="dom-if" if="{{_showChangeListView}}" restamp="true">
@@ -67,18 +62,18 @@
params="[[params]]"
view-state="{{_viewState.changeListView}}"
changes-per-page="[[_preferences.changes_per_page]]"
- logged-in="[[_computeLoggedIn(account)]]"></gr-change-list-view>
+ logged-in="[[_computeLoggedIn(_account)]]"></gr-change-list-view>
</template>
<template is="dom-if" if="{{_showDashboardView}}" restamp="true">
<gr-dashboard-view
- account="[[account]]"
+ account="[[_account]]"
params="[[params]]"
view-state="{{_viewState.dashboardView}}"></gr-dashboard-view>
</template>
<template is="dom-if" if="{{_showChangeView}}" restamp="true">
<gr-change-view
params="[[params]]"
- server-config="[[config]]"
+ server-config="[[_serverConfig]]"
view-state="{{_viewState.changeView}}"></gr-change-view>
</template>
<template is="dom-if" if="{{_showDiffView}}" restamp="true">
@@ -90,14 +85,14 @@
</main>
<footer role="contentinfo">
Powered by <a href="https://www.gerritcodereview.com/" target="_blank">Gerrit Code Review</a>
- ([[version]])
- <span hidden$="[[!config.gerrit.report_bug_url]]">
+ ([[_version]])
+ <span hidden$="[[!_serverConfig.gerrit.report_bug_url]]">
|
- <a href$="[[config.gerrit.report_bug_url]]" target="_blank">
- <span hidden$="[[!config.gerrit.report_bug_text]]">
- [[config.gerrit.report_bug_text]]
+ <a href$="[[_serverConfig.gerrit.report_bug_url]]" target="_blank">
+ <span hidden$="[[!_serverConfig.gerrit.report_bug_text]]">
+ [[_serverConfig.gerrit.report_bug_text]]
</span>
- <span hidden$="[[config.gerrit.report_bug_text]]">Report Bug</span>
+ <span hidden$="[[_serverConfig.gerrit.report_bug_text]]">Report Bug</span>
</a>
</span>
|
diff --git a/polygerrit-ui/app/elements/gr-app.js b/polygerrit-ui/app/elements/gr-app.js
index e115d4b..31797dd 100644
--- a/polygerrit-ui/app/elements/gr-app.js
+++ b/polygerrit-ui/app/elements/gr-app.js
@@ -18,10 +18,7 @@
is: 'gr-app',
properties: {
- account: {
- type: Object,
- observer: '_accountChanged',
- },
+ params: Object,
accountReady: {
type: Object,
readOnly: true,
@@ -32,16 +29,20 @@
}.bind(this));
},
},
- config: Object,
- version: String,
- params: Object,
keyEventTarget: {
type: Object,
value: function() { return document.body; },
},
+ _account: {
+ type: Object,
+ observer: '_accountChanged',
+ },
+ _serverConfig: Object,
+ _version: String,
_diffPreferences: Object,
_preferences: Object,
+ _resolveAccountReady: Function,
_showChangeListView: Boolean,
_showDashboardView: Boolean,
_showChangeView: Boolean,
@@ -62,15 +63,18 @@
],
get loggedIn() {
- return !!(this.account && Object.keys(this.account).length > 0);
+ return !!(this._account && Object.keys(this._account).length > 0);
},
attached: function() {
this.$.restAPI.getAccount().then(function(account) {
- this.account = account;
+ this._account = account;
}.bind(this));
this.$.restAPI.getConfig().then(function(config) {
- this.config = config;
+ this._serverConfig = config;
+ }.bind(this));
+ this.$.restAPI.getVersion().then(function(version) {
+ this._version = version;
}.bind(this));
},
@@ -95,12 +99,14 @@
_accountChanged: function() {
this._resolveAccountReady();
- if (this.loggedIn) {
- this.$.diffPreferencesXHR.generateRequest();
+ if (this.loggedIn) {
this.$.restAPI.getPreferences().then(function(preferences) {
this._preferences = preferences;
}.bind(this));
+ this.$.restAPI.getDiffPreferences().then(function(prefs) {
+ this._diffPreferences = prefs;
+ }.bind(this));
} else {
// These defaults should match the defaults in
// gerrit-extension-api/src/main/jcg/gerrit/extensions/client/DiffPreferencesInfo.java
diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js
index 5ac846a..27cd989 100644
--- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js
+++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.js
@@ -86,6 +86,14 @@
return this._fetchSharedCacheURL('/config/server/info');
},
+ getVersion: function() {
+ return this._fetchSharedCacheURL('/config/server/version');
+ },
+
+ getDiffPreferences: function() {
+ return this._fetchSharedCacheURL('/accounts/self/preferences.diff');
+ },
+
getAccount: function() {
return this._fetchSharedCacheURL('/accounts/self/detail');
},