From 35ccc2bc29097f1488d1f1a9c3e4b63c2831b383 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Wed, 17 Nov 2021 17:46:50 +0000 Subject: [PATCH] ui: Adding partitions + icons to upstreams/upstream instances (#11556) Adds a partition badge/label/visual to upstreams and upstream instances. --- .changelog/11556.txt | 3 ++ .../consul/intention/list/table/index.hbs | 4 ++ .../consul/upstream-instance/list/README.mdx | 39 ++++++++++++++++++ .../consul/upstream-instance/list/index.hbs | 16 +++++++- .../consul/upstream-instance/list/index.scss | 3 ++ .../consul/upstream/list/README.mdx | 40 +++++++++++++++++++ .../components/consul/upstream/list/index.hbs | 12 ++++++ .../consul/upstream/list/index.scss | 8 ++++ .../consul-ui/app/styles/components.scss | 1 + .../dc/services/instance/upstreams.hbs | 1 + 10 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 .changelog/11556.txt create mode 100644 ui/packages/consul-ui/app/components/consul/upstream-instance/list/README.mdx create mode 100644 ui/packages/consul-ui/app/components/consul/upstream/list/README.mdx create mode 100644 ui/packages/consul-ui/app/components/consul/upstream/list/index.scss diff --git a/.changelog/11556.txt b/.changelog/11556.txt new file mode 100644 index 0000000000..1b7fd6037e --- /dev/null +++ b/.changelog/11556.txt @@ -0,0 +1,3 @@ +```release-note:improvement +ui: Add upstream icons for upstreams and upstream instances +``` diff --git a/ui/packages/consul-ui/app/components/consul/intention/list/table/index.hbs b/ui/packages/consul-ui/app/components/consul/intention/list/table/index.hbs index 761dbe6036..beeb91cd60 100644 --- a/ui/packages/consul-ui/app/components/consul/intention/list/table/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/intention/list/table/index.hbs @@ -24,6 +24,7 @@ as |item index|> {{else}} {{item.SourceName}} {{/if}} + {{#if (or (can 'use nspaces') (can 'use partitions'))}} {{! TODO: slugify }} class={{concat 'nspace-' (or item.SourceNS 'default')}} >{{or item.SourceNS 'default'}} + {{/if}} @@ -44,6 +46,7 @@ as |item index|> {{else}} {{item.DestinationName}} {{/if}} + {{#if (or (can 'use nspaces') (can 'use partitions'))}} {{! TODO: slugify }} class={{concat 'nspace-' (or item.DestinationNS 'default')}} >{{or item.DestinationNS 'default'}} + {{/if}} diff --git a/ui/packages/consul-ui/app/components/consul/upstream-instance/list/README.mdx b/ui/packages/consul-ui/app/components/consul/upstream-instance/list/README.mdx new file mode 100644 index 0000000000..52cee1d4a0 --- /dev/null +++ b/ui/packages/consul-ui/app/components/consul/upstream-instance/list/README.mdx @@ -0,0 +1,39 @@ +# Consul::UpstreamInstance::List + +```hbs + + + +``` + +A presentational component for rendering Consul Upstream Instances. Upstreams +instances are a Consul Service Instance that specifically has a relationship +with an origin Service Instance. + +Currently you have to pass in the current dc, nspace and partition so that we +can figure out whether to show things that aren't in same 'bucket' that you are +currently in in the UI. + +## Arguments + +| Argument | Type | Default | Description | +| --- | --- | --- | --- | +| `items` | `array` | | An array of Upstreams | +| `dc` | `string` | | The slug of the current dc | +| `nspace` | `string` | | The slug of the current nspace | +| `partition` | `string` | | The slug of the current partition | + +## See + +- [Possible + Occurances](/hashicorp/consul/search?q=%22Consul%3A%3AUpstreamInstance%3A%3AList%22) +- [Template Source Code](./index.hbs) + +--- diff --git a/ui/packages/consul-ui/app/components/consul/upstream-instance/list/index.hbs b/ui/packages/consul-ui/app/components/consul/upstream-instance/list/index.hbs index 3b525336df..7c605bb1bf 100644 --- a/ui/packages/consul-ui/app/components/consul/upstream-instance/list/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/upstream-instance/list/index.hbs @@ -11,7 +11,21 @@

-{{#if (env 'CONSUL_NSPACES_ENABLED')}} +{{#if (can 'use partitions')}} + {{#if (not-eq item.DestinationType 'prepared_query')}} +
+
+ Admin Partition +
+
+ {{or item.DestinationPartition 'default'}} +
+
+ {{/if}} +{{/if}} +{{#if (can 'use nspaces')}} {{#if (not-eq item.DestinationType 'prepared_query')}}
+ + +``` + +A presentational component for rendering Consul Upstreams (not upstream +instances). Upstreams are a Consul Service that is specifically have a +relationship with an origin Service. The Upstream 'groups' are usually only used +for showing relationships for gateways. + +Currently you have to pass in the current dc, nspace and partition so that we +can figure out whether to show things that aren't in same 'bucket' that you are +currently in in the UI. + +## Arguments + +| Argument | Type | Default | Description | +| --- | --- | --- | --- | +| `items` | `array` | | An array of Upstreams | +| `dc` | `string` | | The slug of the current dc | +| `nspace` | `string` | | The slug of the current nspace | +| `partition` | `string` | | The slug of the current partition | + +## See + +- [Possible Occurances](/hashicorp/consul/search?q=%22Consul%3A%3AUpstream%3A%3AList%22) +- [Component Source Code](./index.js) +- [Template Source Code](./index.hbs) + +--- diff --git a/ui/packages/consul-ui/app/components/consul/upstream/list/index.hbs b/ui/packages/consul-ui/app/components/consul/upstream/list/index.hbs index 29d3720f6c..66324a9be4 100644 --- a/ui/packages/consul-ui/app/components/consul/upstream/list/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/upstream/list/index.hbs @@ -24,6 +24,18 @@ as |item index|> {{/if}}
+{{#if (and (can 'use partitions') (not-eq item.Partition @partition))}} +
+
+ Admin Partition +
+
+ {{item.Partition}} +
+
+{{/if}} @items={{collection.items}} @dc={{dc}} @nspace={{nspace}} + @partition={{partition}} />