Prevent settings URL evaluation before router initialization

The registration dialog makes use of the router's abstracted settings
URL independently of any of its configuration. Consequently, the dialog
evaluates the URL immediately when instantiated by the gr-app element.
Because gr-app initializes the router in its ready lifecycle callback,
this evaluation occurs before the router is ready to provide the URL.

With this change, the settings URL is evaluated by gr-app after it
directly initializes the router, and the resulting string is passed-down
into the registration dialog element.

Bug: Issue 7837
Change-Id: Ief4daaaa6925f1109487ddb6cee0578e647526d4
diff --git a/polygerrit-ui/app/elements/gr-app.html b/polygerrit-ui/app/elements/gr-app.html
index 7b279c7..ef93794 100644
--- a/polygerrit-ui/app/elements/gr-app.html
+++ b/polygerrit-ui/app/elements/gr-app.html
@@ -211,6 +211,7 @@
     </gr-overlay>
     <gr-overlay id="registration" with-backdrop>
       <gr-registration-dialog
+          settings-url="[[_settingsUrl]]"
           on-account-detail-update="_handleAccountDetailUpdate"
           on-close="_handleRegistrationDialogClose">
       </gr-registration-dialog>
diff --git a/polygerrit-ui/app/elements/gr-app.js b/polygerrit-ui/app/elements/gr-app.js
index 722fff8..e98aaac 100644
--- a/polygerrit-ui/app/elements/gr-app.js
+++ b/polygerrit-ui/app/elements/gr-app.js
@@ -84,6 +84,7 @@
         type: String,
         computed: '_computePluginScreenName(params)',
       },
+      _settingsUrl: String,
     },
 
     listeners: {
@@ -122,6 +123,10 @@
         this._version = version;
       });
 
+      // Note: this is evaluated here to ensure that it only happens after the
+      // router has been initialized. @see Issue 7837
+      this._settingsUrl = Gerrit.Nav.getUrlForSettings();
+
       this.$.reporting.appStarted();
       this._viewState = {
         changeView: {
diff --git a/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.html b/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.html
index 0cbd1f6..1b3d9d4 100644
--- a/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.html
+++ b/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.html
@@ -94,7 +94,7 @@
         <hr>
         <p>
           More configuration options for Gerrit may be found in the
-          <a on-tap="close" href$="[[_computeSettingsUrl(_account)]]">settings</a>.
+          <a on-tap="close" href$="[[settingsUrl]]">settings</a>.
         </p>
       </main>
       <footer>
diff --git a/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.js b/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.js
index 406d16c..dace2ca 100644
--- a/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.js
+++ b/polygerrit-ui/app/elements/settings/gr-registration-dialog/gr-registration-dialog.js
@@ -30,6 +30,7 @@
      */
 
     properties: {
+      settingsUrl: String,
       /** @type {?} */
       _account: {
         type: Object,
@@ -89,9 +90,5 @@
     _computeSaveDisabled(name, username, email, saving) {
       return !name || !username || !email || saving;
     },
-
-    _computeSettingsUrl() {
-      return Gerrit.Nav.getUrlForSettings();
-    },
   });
 })();