From 8b58d81d64da2b916567aaa3accf9351e4b6b800 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Tue, 2 Feb 2021 10:03:46 +0000 Subject: [PATCH] ui: Adds unique-id helper (#9676) --- .../app/components/hashicorp-consul/index.hbs | 508 +++++++++--------- .../app/components/hashicorp-consul/index.js | 8 - .../consul-ui/app/helpers/unique-id.js | 10 + 3 files changed, 265 insertions(+), 261 deletions(-) create mode 100644 ui/packages/consul-ui/app/helpers/unique-id.js diff --git a/ui/packages/consul-ui/app/components/hashicorp-consul/index.hbs b/ui/packages/consul-ui/app/components/hashicorp-consul/index.hbs index 41df4d64b..83b097c39 100644 --- a/ui/packages/consul-ui/app/components/hashicorp-consul/index.hbs +++ b/ui/packages/consul-ui/app/components/hashicorp-consul/index.hbs @@ -1,274 +1,276 @@ - +{{#let (unique-id) as |guid|}} + - <:home-nav> - - Consul - - - + <:home-nav> + + Consul + + + - <:main-nav> -{{#if @dc}} -
    - {{#let (or this.nspaces @nspaces) as |nspaces|}} - {{#if (and (env 'CONSUL_NSPACES_ENABLED') (gt nspaces.length 0))}} -
  • - Namespace - - - {{@nspace.Name}} - - {{#if (is-href 'dc.nspaces')}} - -

    - Namespaces themselves are not namespaced, so switching will not change the current view. -

    -
    - {{/if}} - - {{#let components.MenuItem components.MenuSeparator as |MenuItem MenuSeparator|}} + <:main-nav> + {{#if @dc}} +
      + {{#let (or this.nspaces @nspaces) as |nspaces|}} + {{#if (and (env 'CONSUL_NSPACES_ENABLED') (gt nspaces.length 0))}} +
    • + Namespace + + + {{@nspace.Name}} + + {{#if (is-href 'dc.nspaces')}} + +

      + Namespaces themselves are not namespaced, so switching will not change the current view. +

      +
      + {{/if}} + + {{#let components.MenuItem components.MenuSeparator as |MenuItem MenuSeparator|}} + + {{#each (reject-by 'DeletedAt' nspaces) as |item|}} + + + {{item.Name}} + + + {{/each}} + {{#if this.canManageNspaces}} + + + + Manage Namespaces + + + {{/if}} + {{/let}} + +
      +
    • + {{/if}} + {{/let}} +
    • + Datacenter + + + {{@dc.Name}} + + + {{#let components.MenuItem components.MenuSeparator as |MenuItem MenuSeparator|}} - {{#each (reject-by 'DeletedAt' nspaces) as |item|}} - - - {{item.Name}} - - - {{/each}} - {{#if this.canManageNspaces}} - - - - Manage Namespaces - - - {{/if}} - {{/let}} - - -
    • + {{#each (sort-by 'Name' @dcs) as |item|}} + + + {{item.Name}} + {{#if item.Local}} + Local + {{/if}} + + + {{/each}} + {{/let}} + + + + +
    • + Services +
    • +
    • + Nodes +
    • +
    • + Key/Value +
    • +
    • + Intentions +
    • +
    • Access Controls
    • +
    • + Tokens +
    • +
    • + Policies +
    • +
    • + Roles +
    • +
    {{/if}} - {{/let}} -
  • - Datacenter - + + + + <:complementary-nav> +
      +
    • + - {{@dc.Name}} + Help {{#let components.MenuItem components.MenuSeparator as |MenuItem MenuSeparator|}} - - {{#each (sort-by 'Name' @dcs) as |item|}} - {{item.Name}} - {{#if item.Local}} - Local - {{/if}} + Documentation + + + + + HashiCorp Learn + + + + + + Provide Feedback - {{/each}} {{/let}} - -
    • -
    • - Services -
    • -
    • - Nodes -
    • -
    • - Key/Value -
    • -
    • - Intentions -
    • -
    • Access Controls
    • -
    • - Tokens -
    • -
    • - Policies -
    • -
    • - Roles -
    • -
    -{{/if}} - - - - <:complementary-nav> -
      -
    • - - - Help - - - {{#let components.MenuItem components.MenuSeparator as |MenuItem MenuSeparator|}} - - - Documentation - - - - - HashiCorp Learn - - - - - - Provide Feedback - - +
    • +
    • + Settings +
    • + {{#if (env 'CONSUL_ACLS_ENABLED')}} +
    • + + {{#let components.AuthForm components.AuthProfile as |AuthForm AuthProfile|}} + + + + + +

      Log in to Consul

      +
      + + + + + + + + +
      +
      + + + + +

      Log in with a different token

      +
      + + + + + + + + +
      + + + Logout + + + {{#let components.MenuItem components.MenuSeparator as |MenuItem MenuSeparator|}} + {{!TODO: It might be nice to use one of our recursive components here}} + {{#if authDialog.token.AccessorID}} +
    • + +
    • + + {{/if}} + + + Logout + + + {{/let}} + + + {{/let}} - - - -
    • - Settings -
    • -{{#if (env 'CONSUL_ACLS_ENABLED')}} -
    • - - {{#let components.AuthForm components.AuthProfile as |AuthForm AuthProfile|}} - - - - - -

      Log in to Consul

      -
      - - - - - - - - -
      -
      - - - - -

      Log in with a different token

      -
      - - - - - - - - -
      - - - Logout - - - {{#let components.MenuItem components.MenuSeparator as |MenuItem MenuSeparator|}} -{{!TODO: It might be nice to use one of our recursive components here}} -{{#if authDialog.token.AccessorID}} -
    • - -
    • - -{{/if}} - - - Logout - - - {{/let}} - - - - {{/let}} - - -{{/if}} -
    - + +
  • + {{/if}} +
+ - <:main> - {{yield}} - + <:main> + {{yield}} + - <:content-info> - - © {{env 'CONSUL_COPYRIGHT_YEAR'}} HashiCorp - -

- Consul {{env 'CONSUL_VERSION'}} -

- - Documentation - - {{{concat ''}}} - -
\ No newline at end of file + <:content-info> + + © {{env 'CONSUL_COPYRIGHT_YEAR'}} HashiCorp + +

+ Consul {{env 'CONSUL_VERSION'}} +

+ + Documentation + + {{{concat ''}}} + +
+{{/let}} \ No newline at end of file diff --git a/ui/packages/consul-ui/app/components/hashicorp-consul/index.js b/ui/packages/consul-ui/app/components/hashicorp-consul/index.js index 9865a03ca..48eface58 100644 --- a/ui/packages/consul-ui/app/components/hashicorp-consul/index.js +++ b/ui/packages/consul-ui/app/components/hashicorp-consul/index.js @@ -1,15 +1,7 @@ import Component from '@glimmer/component'; -import { inject as service } from '@ember/service'; import { action } from '@ember/object'; export default class HashiCorpConsul extends Component { - @service('dom') dom; - - constructor(args, owner) { - super(...arguments); - this.guid = this.dom.guid(this); - } - // TODO: Right now this is the only place where we need permissions // but we are likely to need it elsewhere, so probably need a nice helper get canManageNspaces() { diff --git a/ui/packages/consul-ui/app/helpers/unique-id.js b/ui/packages/consul-ui/app/helpers/unique-id.js new file mode 100644 index 000000000..93b16b49c --- /dev/null +++ b/ui/packages/consul-ui/app/helpers/unique-id.js @@ -0,0 +1,10 @@ +import Helper from '@ember/component/helper'; +import { inject as service } from '@ember/service'; + +export default class UniqueIdHelper extends Helper { + @service('dom') dom; + + compute(params, hash) { + return this.dom.guid({}); + } +}