From d1c879e06c2bd4dbb895f695bde06dd1ae56bc33 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Mon, 10 Aug 2020 09:26:02 +0100 Subject: [PATCH] ui: Rework popover-menu auto closing (#8340) * ui: Move more menu subcomponents deeper down into popovermenu * ui: Simplify aria-menu component+remove auto menu close on route change * Add ember-string-fns * Use new PopoverMenu sub components and fix up tests * Fix up wrong closing let * Remove dcs from the service show page now we have it in the navigation --- ui-v2/app/components/aria-menu/index.hbs | 8 +- ui-v2/app/components/aria-menu/index.js | 4 - .../app/components/hashicorp-consul/index.hbs | 150 ++++++++++++------ .../components/hashicorp-consul/pageobject.js | 5 +- .../components/more-popover-menu/index.hbs | 12 +- ui-v2/app/components/popover-menu/index.hbs | 106 ++++++++----- .../menu-item}/index.hbs | 13 +- .../menu-item}/index.js | 0 .../popover-menu/menu-separator/index.hbs | 4 + .../popover-menu/menu-separator/index.js | 7 + ui-v2/app/components/popover-select/index.hbs | 29 ++-- ui-v2/app/components/popover-select/index.js | 2 + ui-v2/package.json | 1 + ui-v2/tests/acceptance/dc/error.feature | 2 +- .../acceptance/dc/services/dc-switch.feature | 6 +- .../acceptance/dc/services/error.feature | 2 +- .../dc/services/show/dc-switch.feature | 2 +- ui-v2/tests/pages.js | 13 +- ui-v2/tests/pages/dc/services/index.js | 3 - ui-v2/tests/pages/dc/services/show.js | 16 +- ui-v2/yarn.lock | 7 + 21 files changed, 233 insertions(+), 159 deletions(-) rename ui-v2/app/components/{more-popover-menu/action => popover-menu/menu-item}/index.hbs (74%) rename ui-v2/app/components/{more-popover-menu/action => popover-menu/menu-item}/index.js (100%) create mode 100644 ui-v2/app/components/popover-menu/menu-separator/index.hbs create mode 100644 ui-v2/app/components/popover-menu/menu-separator/index.js diff --git a/ui-v2/app/components/aria-menu/index.hbs b/ui-v2/app/components/aria-menu/index.hbs index 8fa3ad5aed..9693a44edc 100644 --- a/ui-v2/app/components/aria-menu/index.hbs +++ b/ui-v2/app/components/aria-menu/index.hbs @@ -1,8 +1,10 @@ {{yield (action 'change') (action 'keypress') - (concat 'component-aria-menu-trigger-' guid) - (concat 'component-aria-menu-menu-' guid) - (if expanded 'true' undefined) (action 'keypressClick') + (hash + labelledBy=(concat 'component-aria-menu-trigger-' guid) + controls=(concat 'component-aria-menu-menu-' guid) + expanded=(if expanded 'true' undefined) + ) }} \ No newline at end of file diff --git a/ui-v2/app/components/aria-menu/index.js b/ui-v2/app/components/aria-menu/index.js index 78eca1e94f..6643c2bb6f 100644 --- a/ui-v2/app/components/aria-menu/index.js +++ b/ui-v2/app/components/aria-menu/index.js @@ -39,7 +39,6 @@ const MENU_ITEMS = '[role^="menuitem"]'; export default Component.extend({ tagName: '', dom: service('dom'), - router: service('router'), guid: '', expanded: false, orientation: 'vertical', @@ -56,9 +55,6 @@ export default Component.extend({ this.$menu = this.dom.element(`#${COMPONENT_ID}menu-${this.guid}`); const labelledBy = this.$menu.getAttribute('aria-labelledby'); this.$trigger = this.dom.element(`#${labelledBy}`); - this._routelisteners.add(this.router, { - routeWillChange: () => this.actions.close.apply(this, [{}]), - }); }, willDestroyElement: function() { this._super(...arguments); diff --git a/ui-v2/app/components/hashicorp-consul/index.hbs b/ui-v2/app/components/hashicorp-consul/index.hbs index c9fb5bdd83..4433ea5538 100644 --- a/ui-v2/app/components/hashicorp-consul/index.hbs +++ b/ui-v2/app/components/hashicorp-consul/index.hbs @@ -17,7 +17,7 @@ {{#if (and (eq nspaces.length 1) (not canManageNspaces)) }} {{nspace.Name}} {{ else }} - + {{nspace.Name}} @@ -29,25 +29,39 @@ {{/if}} -
  • - Namespaces - -
  • + {{#let components.MenuItem components.MenuSeparator as |MenuItem MenuSeparator|}} + + + Namespaces + + + {{#each (reject-by 'DeletedAt' nspaces) as |item|}} -
  • - {{item.Name}} -
  • + + + {{item.Name}} + + {{/each}} {{#if canManageNspaces }} -
  • -
  • - Manage namespaces -
  • + + + + Manage Namespaces + + {{/if}} + {{/let}}
    {{/if}} @@ -57,24 +71,34 @@ {{#if (or (not dcs) (eq dcs.length 1)) }} {{dc.Name}} {{ else }} - + {{dc.Name}} -
  • - Datacenters - -
  • + {{#let components.MenuItem components.MenuSeparator as |MenuItem MenuSeparator|}} + + + Datacenters + + + {{#each (sort-by 'Name' dcs) as |item|}} -
  • - {{item.Name}} -
  • + + + {{item.Name}} + + {{/each}} + {{/let}}
    @@ -101,21 +125,38 @@