diff --git a/ui/desktop/app/routes/origin.js b/ui/desktop/app/routes/origin.js index 9d3704e92..9e3df0ace 100644 --- a/ui/desktop/app/routes/origin.js +++ b/ui/desktop/app/routes/origin.js @@ -1,7 +1,9 @@ import Route from '@ember/routing/route'; import { inject as service } from '@ember/service'; +import { getOwner } from '@ember/application'; import { action } from '@ember/object'; import loading from 'ember-loading/decorator'; +import config from '../config/environment'; export default class OriginRoute extends Route { // =services @@ -20,6 +22,17 @@ export default class OriginRoute extends Route { return this.store.adapterFor('application'); } + /** + * Looks up the window object indirectly. + * @type {Window} + */ + get window() { + // The Ember way of accessing globals... + const document = getOwner(this).lookup('service:-document').documentElement; + // defaultView === window, but without using globals directly + return document.parentNode.defaultView; + } + // =methods /** @@ -36,7 +49,15 @@ export default class OriginRoute extends Route { */ setupController(controller) { super.setupController(...arguments); - const origin = this.origin.rendererOrigin; + let origin = this.origin.rendererOrigin; + // If origin is unset and this is a development environment, + // autoset the origin field of the UI for better DX. + // The controller URL is almost always the same as the current window when + // using mocks, and this makes development more rapid since developers + // do not need to fill an origin on every session. + if (!origin && config.autoOrigin) { + origin = this.window.location.origin; + } controller.setProperties({ origin }); } diff --git a/ui/desktop/app/templates/origin.hbs b/ui/desktop/app/templates/origin.hbs index 1421af91d..8fbae5380 100644 --- a/ui/desktop/app/templates/origin.hbs +++ b/ui/desktop/app/templates/origin.hbs @@ -15,7 +15,8 @@ @type="text" @value={{this.origin}} @label={{t "form.origin.label"}} - @helperText={{t "form.origin.description"}} /> + @helperText={{t "form.origin.description"}} + {{autofocus}} /> diff --git a/ui/desktop/app/templates/scopes/scope/authenticate/method.hbs b/ui/desktop/app/templates/scopes/scope/authenticate/method.hbs index 709c1f491..8cdf94c64 100644 --- a/ui/desktop/app/templates/scopes/scope/authenticate/method.hbs +++ b/ui/desktop/app/templates/scopes/scope/authenticate/method.hbs @@ -13,7 +13,8 @@ @name="identification" @type="text" @value={{this.identification}} - @label={{t "form.login_name.label"}} /> + @label={{t "form.login_name.label"}} + {{autofocus}} />