From c0abe1e406272221f745d2150e6d657c9a8c3614 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Thu, 1 Oct 2020 09:33:22 +0100 Subject: [PATCH] ui: Outlet Loading (#8779) Moves all Route/model hook loading to use Outlet components which listen on route change. --- ui-v2/app/components/app-view/index.hbs | 174 +++++++++--------- ui-v2/app/components/app-view/index.js | 41 +---- ui-v2/app/components/empty-state/index.hbs | 2 +- .../app/components/empty-state/pageobject.js | 6 + .../components/hashicorp-consul/pageobject.js | 3 +- ui-v2/app/components/list-collection/index.js | 6 +- ui-v2/app/components/outlet/index.hbs | 15 ++ ui-v2/app/components/outlet/index.js | 140 ++++++++++++++ ui-v2/app/components/role-selector/index.hbs | 1 + ui-v2/app/components/role-selector/index.scss | 9 + .../components/tabular-collection/index.js | 2 +- ui-v2/app/routes/application.js | 23 +-- ui-v2/app/routes/dc.js | 3 +- ui-v2/app/routes/dc/acls.js | 2 +- ui-v2/app/routes/dc/acls/create.js | 4 +- ui-v2/app/routes/dc/acls/edit.js | 4 +- ui-v2/app/routes/dc/acls/index.js | 4 +- ui-v2/app/routes/dc/acls/policies/edit.js | 2 + ui-v2/app/routes/dc/acls/policies/index.js | 4 +- ui-v2/app/routes/dc/acls/roles/edit.js | 1 + ui-v2/app/routes/dc/acls/roles/index.js | 4 +- ui-v2/app/routes/dc/acls/tokens/edit.js | 2 + ui-v2/app/routes/dc/acls/tokens/index.js | 4 +- ui-v2/app/routes/dc/index.js | 2 +- ui-v2/app/routes/dc/intentions/edit.js | 3 +- ui-v2/app/routes/dc/intentions/index.js | 3 +- ui-v2/app/routes/dc/kv/edit.js | 3 +- ui-v2/app/routes/dc/kv/folder.js | 1 - ui-v2/app/routes/dc/kv/index.js | 4 +- ui-v2/app/routes/dc/nodes/index.js | 3 +- ui-v2/app/routes/dc/nodes/show.js | 4 +- .../app/routes/dc/nodes/show/healthchecks.js | 3 +- ui-v2/app/routes/dc/nodes/show/index.js | 2 +- ui-v2/app/routes/dc/nodes/show/metadata.js | 3 +- ui-v2/app/routes/dc/nodes/show/rtt.js | 3 +- ui-v2/app/routes/dc/nodes/show/services.js | 3 +- ui-v2/app/routes/dc/nodes/show/sessions.js | 25 ++- ui-v2/app/routes/dc/nspaces/edit.js | 4 +- ui-v2/app/routes/dc/nspaces/index.js | 4 +- ui-v2/app/routes/dc/services/index.js | 3 +- ui-v2/app/routes/dc/services/instance.js | 3 +- .../routes/dc/services/instance/addresses.js | 3 +- .../dc/services/instance/exposedpaths.js | 3 +- .../dc/services/instance/healthchecks.js | 3 +- .../app/routes/dc/services/instance/index.js | 2 +- .../routes/dc/services/instance/metadata.js | 3 +- .../app/routes/dc/services/instance/proxy.js | 3 +- .../routes/dc/services/instance/upstreams.js | 3 +- ui-v2/app/routes/dc/services/notfound.js | 2 +- ui-v2/app/routes/dc/services/show.js | 3 +- ui-v2/app/routes/dc/services/show/index.js | 2 +- .../app/routes/dc/services/show/instances.js | 3 +- .../app/routes/dc/services/show/intentions.js | 9 +- .../dc/services/show/intentions/edit.js | 3 +- .../dc/services/show/intentions/index.js | 3 +- ui-v2/app/routes/dc/services/show/routing.js | 3 +- ui-v2/app/routes/dc/services/show/services.js | 3 +- ui-v2/app/routes/dc/services/show/tags.js | 3 +- .../app/routes/dc/services/show/upstreams.js | 3 +- ui-v2/app/routes/index.js | 2 +- ui-v2/app/routes/notfound.js | 2 +- ui-v2/app/routes/nspace.js | 2 +- ui-v2/app/routes/settings.js | 3 +- ui-v2/app/routing/route.js | 15 ++ ui-v2/app/routing/single.js | 3 +- ui-v2/app/services/feedback.js | 5 - ui-v2/app/styles/components.scss | 1 + ui-v2/app/styles/components/app-view.scss | 4 +- .../app/styles/components/app-view/index.scss | 4 +- ui-v2/app/styles/components/loader.scss | 5 +- ui-v2/app/styles/layout.scss | 2 +- ui-v2/app/styles/routes/dc/acls/index.scss | 23 +-- ui-v2/app/styles/routes/dc/kv/index.scss | 6 +- ui-v2/app/styles/routes/dc/nodes/index.scss | 2 +- .../app/styles/routes/dc/services/index.scss | 4 +- ui-v2/app/templates/application.hbs | 6 +- ui-v2/app/templates/dc.hbs | 6 +- ui-v2/app/templates/dc/acls/edit.hbs | 2 +- ui-v2/app/templates/dc/acls/index.hbs | 2 +- ui-v2/app/templates/dc/acls/policies/edit.hbs | 2 - .../app/templates/dc/acls/policies/index.hbs | 2 - ui-v2/app/templates/dc/acls/roles/edit.hbs | 2 - ui-v2/app/templates/dc/acls/roles/index.hbs | 2 - ui-v2/app/templates/dc/acls/tokens/edit.hbs | 2 - ui-v2/app/templates/dc/acls/tokens/index.hbs | 2 - ui-v2/app/templates/dc/intentions/edit.hbs | 2 +- ui-v2/app/templates/dc/intentions/index.hbs | 2 +- ui-v2/app/templates/dc/kv/edit.hbs | 2 +- ui-v2/app/templates/dc/kv/index.hbs | 2 +- ui-v2/app/templates/dc/nodes/index.hbs | 2 +- ui-v2/app/templates/dc/nodes/show.hbs | 9 +- .../app/templates/dc/nodes/show/sessions.hbs | 1 + ui-v2/app/templates/dc/nspaces/edit.hbs | 2 +- ui-v2/app/templates/dc/nspaces/index.hbs | 2 +- ui-v2/app/templates/dc/services/index.hbs | 2 +- ui-v2/app/templates/dc/services/instance.hbs | 6 +- ui-v2/app/templates/dc/services/show.hbs | 8 +- .../templates/dc/services/show/intentions.hbs | 6 +- ui-v2/app/templates/nspace.hbs | 6 +- ui-v2/app/templates/settings.hbs | 2 +- ui-v2/tests/acceptance/login-errors.feature | 4 +- .../tests/acceptance/page-navigation.feature | 1 - ui-v2/tests/pages.js | 4 +- 103 files changed, 467 insertions(+), 296 deletions(-) create mode 100644 ui-v2/app/components/empty-state/pageobject.js create mode 100644 ui-v2/app/components/outlet/index.hbs create mode 100644 ui-v2/app/components/outlet/index.js create mode 100644 ui-v2/app/components/role-selector/index.scss create mode 100644 ui-v2/app/routing/route.js diff --git a/ui-v2/app/components/app-view/index.hbs b/ui-v2/app/components/app-view/index.hbs index cdc4c49b4..e7e1a542d 100644 --- a/ui-v2/app/components/app-view/index.hbs +++ b/ui-v2/app/components/app-view/index.hbs @@ -1,90 +1,90 @@ -{{yield}} -
-{{#each flashMessages.queue as |flash|}} - - {{#if flash.dom}} - {{{flash.dom}}} - {{else}} - {{#let (lowercase component.flashType) (lowercase flash.action) as |status type|}} - {{! flashes automatically ucfirst the type }} - - - {{/let}} - {{/if}} - -{{/each}} -
-
- {{#if authorized}} - - {{/if}} -
- - {{yield}} - -
- {{#if authorized}} - - - {{yield}} - - {{/if}} -
-
- - {{yield}} - -
-
- {{#if authorized}} - - - {{yield}} - - {{/if}} -
-
- {{#if (not enabled) }} - {{yield}} - {{else if (not authorized)}} - {{yield}} +
+ {{yield}} +
+ {{#each flashMessages.queue as |flash|}} + + {{#if flash.dom}} + {{{flash.dom}}} {{else}} - {{yield}} + {{#let (lowercase component.flashType) (lowercase flash.action) as |status type|}} + {{! flashes automatically ucfirst the type }} + + + {{/let}} {{/if}} + + {{/each}} +
+
+ {{#if authorized}} + + {{/if}} +
+ + {{yield}} + +
+ {{#if authorized}} + + + {{yield}} + + {{/if}} +
+
+ + {{yield}} + +
+
+ {{#if authorized}} + + + {{yield}} + + {{/if}} +
+
+ {{#if (not enabled) }} + {{yield}} + {{else}} + {{yield}} + {{/if}} +
diff --git a/ui-v2/app/components/app-view/index.js b/ui-v2/app/components/app-view/index.js index 7fce237ea..ee99672aa 100644 --- a/ui-v2/app/components/app-view/index.js +++ b/ui-v2/app/components/app-view/index.js @@ -1,46 +1,7 @@ import Component from '@ember/component'; import SlotsMixin from 'block-slots'; -import { inject as service } from '@ember/service'; -import templatize from 'consul-ui/utils/templatize'; export default Component.extend(SlotsMixin, { + tagName: '', authorized: true, enabled: true, - classNames: ['app-view'], - classNameBindings: ['enabled::disabled', 'authorized::unauthorized'], - dom: service('dom'), - didReceiveAttrs: function() { - this._super(...arguments); - // right now only manually added classes are hoisted to - const $root = this.dom.root(); - if (this.loading) { - $root.classList.add('loading'); - } else { - $root.classList.remove('loading'); - } - let cls = this['class'] || ''; - if (cls) { - // its possible for 'layout' templates to change after insert - // check for these specific layouts and clear them out - const receivedClasses = new Set(templatize(cls.split(' '))); - const difference = new Set([...$root.classList].filter(item => !receivedClasses.has(item))); - [...difference].forEach(function(item, i) { - if (templatize(['edit', 'show', 'list']).indexOf(item) !== -1) { - $root.classList.remove(item); - } - }); - $root.classList.add(...receivedClasses); - } - }, - didInsertElement: function() { - this._super(...arguments); - this.didReceiveAttrs(); - }, - didDestroyElement: function() { - this._super(...arguments); - const cls = this['class'] + ' loading'; - if (cls) { - const $root = this.dom.root(); - $root.classList.remove(...templatize(cls.split(' '))); - } - }, }); diff --git a/ui-v2/app/components/empty-state/index.hbs b/ui-v2/app/components/empty-state/index.hbs index c4c255826..e90dbdeb9 100644 --- a/ui-v2/app/components/empty-state/index.hbs +++ b/ui-v2/app/components/empty-state/index.hbs @@ -14,7 +14,7 @@
{{yield}} {{#if (and (env 'CONSUL_ACLS_ENABLED') allowLogin)}} -