From 3e43254801081546727780de5340398716515396 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Mon, 26 Oct 2020 14:12:16 -0400 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20move=20org=20scope?= =?UTF-8?q?=20nav=20to=20separate=20template?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/core/app/routes/scopes/scope.js | 17 ++++++++---- ui/core/app/templates/application.hbs | 26 +++---------------- .../templates/scopes/scope/-header-nav.hbs | 20 ++++++++++++++ 3 files changed, 36 insertions(+), 27 deletions(-) create mode 100644 ui/core/app/templates/scopes/scope/-header-nav.hbs diff --git a/ui/core/app/routes/scopes/scope.js b/ui/core/app/routes/scopes/scope.js index 58c145667..7af8591f0 100644 --- a/ui/core/app/routes/scopes/scope.js +++ b/ui/core/app/routes/scopes/scope.js @@ -35,13 +35,14 @@ export default class ScopesScopeRoute extends Route { } /** - * Set scope in application controller + * Adds the set of all org scopes to the controller, which is used by the + * scope navigation template. + * @param {Controller} controller */ - afterModel() { + setupController(controller) { + super.setupController(...arguments); const orgScopes = this.modelFor('scopes').filterBy('isOrg', true); - this.controllerFor('application').set('orgScopes', orgScopes); - const scope = this.modelFor('scopes.scope'); - this.controllerFor('application').set('scope', scope); + controller.setProperties({ orgScopes }); } /** @@ -53,6 +54,12 @@ export default class ScopesScopeRoute extends Route { renderTemplate(controller, model) { super.renderTemplate(...arguments); + this.render('scopes/scope/-header-nav', { + into: 'application', + outlet: 'header-nav', + model: model, + }); + this.render('scopes/scope/-sidebar', { into: 'scopes/scope', outlet: 'sidebar', diff --git a/ui/core/app/templates/application.hbs b/ui/core/app/templates/application.hbs index e8c486787..50a823972 100644 --- a/ui/core/app/templates/application.hbs +++ b/ui/core/app/templates/application.hbs @@ -8,28 +8,10 @@ {{#if this.session.isAuthenticated}} - - - {{#if this.session.data.authenticated.isGlobal}} - - {{t "titles.global"}} - - {{#each this.orgScopes as |scope|}} - - {{scope.displayName}} - - {{/each}} - {{else}} - {{#if this.scope}} - - {{this.scope.displayName}} - - {{/if}} - {{/if}} - + + + {{outlet "header-nav"}} + diff --git a/ui/core/app/templates/scopes/scope/-header-nav.hbs b/ui/core/app/templates/scopes/scope/-header-nav.hbs new file mode 100644 index 000000000..00484b51a --- /dev/null +++ b/ui/core/app/templates/scopes/scope/-header-nav.hbs @@ -0,0 +1,20 @@ + + {{#if this.session.data.authenticated.isGlobal}} + + {{t "titles.global"}} + + + {{#each this.orgScopes as |scope|}} + + {{scope.displayName}} + + {{/each}} + {{else}} + + {{this.model.displayName}} + + {{/if}} +