From 442df6d27d736e53c6dc00f68f8418727c767d93 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Mon, 6 Dec 2021 11:06:33 +0000 Subject: [PATCH] ui: Adds basic support for partition exports to Service listings (#11702) Also: * ui: Add cross partition linking and rollout BucketList (#11712) * ui: Add exported service partition to the source filter menu (#11727) --- .changelog/11702.txt | 3 + .../components/consul/bucket/list/README.mdx | 44 ++++++++++++ .../components/consul/bucket/list/index.hbs | 39 +++++++++++ .../components/consul/bucket/list/index.scss | 26 +++++++ .../components/consul/service/list/README.mdx | 28 ++++++++ .../components/consul/service/list/index.hbs | 32 +++++---- .../consul/service/search-bar/index.hbs | 22 ++++++ .../consul/upstream-instance/list/index.hbs | 68 ++++++++----------- .../components/consul/upstream/list/index.hbs | 43 ++++-------- .../app/components/popover-select/index.scss | 9 ++- .../app/filter/predicates/service.js | 5 +- ui/packages/consul-ui/app/models/service.js | 10 ++- .../consul-ui/app/styles/components.scss | 1 + .../app/templates/dc/services/index.hbs | 30 ++++++-- .../dc/services/instance/upstreams.hbs | 6 +- .../templates/dc/services/show/services.hbs | 3 +- .../templates/dc/services/show/upstreams.hbs | 6 +- .../consul-ui/mock-api/v1/health/service/_ | 3 +- .../v1/internal/ui/gateway-services-nodes/_ | 3 + .../mock-api/v1/internal/ui/services | 2 +- .../consul-ui/translations/common/en-us.yaml | 3 +- 21 files changed, 286 insertions(+), 100 deletions(-) create mode 100644 .changelog/11702.txt create mode 100644 ui/packages/consul-ui/app/components/consul/bucket/list/README.mdx create mode 100644 ui/packages/consul-ui/app/components/consul/bucket/list/index.hbs create mode 100644 ui/packages/consul-ui/app/components/consul/bucket/list/index.scss create mode 100644 ui/packages/consul-ui/app/components/consul/service/list/README.mdx diff --git a/.changelog/11702.txt b/.changelog/11702.txt new file mode 100644 index 000000000..bd3b4f239 --- /dev/null +++ b/.changelog/11702.txt @@ -0,0 +1,3 @@ +```release-note:feature +ui: Adds basic support for showing Services exported from another partition. +``` diff --git a/ui/packages/consul-ui/app/components/consul/bucket/list/README.mdx b/ui/packages/consul-ui/app/components/consul/bucket/list/README.mdx new file mode 100644 index 000000000..939b220e8 --- /dev/null +++ b/ui/packages/consul-ui/app/components/consul/bucket/list/README.mdx @@ -0,0 +1,44 @@ +# Consul::Bucket::List + +A presentational component for rendering a list of Consul 'buckets' +(a single partition and/or a single namepace). + +Please note this is not your usual "scrollable list component" more a list of +'buckets' that make up a partition / namespace combination. + +If only a the namespace is different to the currently selected namespace, then +the namespace will be displayed, whereas if the partition is different it will +show both the partition and namespace (as a namespace called 'team-1' in +`partition-1` is different to a namespace called 'team-1' in `partition-2`) + +If you don't need the nspace only support for the view you are building then +omit the `@nspace` argument. + +At the time of writing, this is not currently used across the entire UI +(specifically in intentions and maybe other areas) but eventually should be. + + +```hbs preview-template + + + +``` + +## Arguments + +| Argument/Attribute | Type | Default | Description | +| --- | --- | --- | --- | +| `item` | `array` | | A Consul object that could have both a `Partition` and a `Namespace` property | +| `nspace` | `string` | | The name of the current namespace | +| `partition` | `string` | | The name of the current partition | + +## See + +- [Template Source Code](./index.hbs) + +--- diff --git a/ui/packages/consul-ui/app/components/consul/bucket/list/index.hbs b/ui/packages/consul-ui/app/components/consul/bucket/list/index.hbs new file mode 100644 index 000000000..d9520749b --- /dev/null +++ b/ui/packages/consul-ui/app/components/consul/bucket/list/index.hbs @@ -0,0 +1,39 @@ +{{#if (and @partition (can 'use partitions'))}} + {{#if (not-eq @item.Partition @partition)}} +
+
+ Admin Partition +
+
+ {{@item.Partition}} +
+
+ Namespace +
+
+ {{@item.Namespace}} +
+
+ {{/if}} +{{else if (and @nspace (can 'use nspace'))}} + {{#if (not-eq @item.Namespace @nspace)}} +
+
+ Namespace +
+
+ {{@item.Namespace}} +
+
+ {{/if}} +{{/if}} + diff --git a/ui/packages/consul-ui/app/components/consul/bucket/list/index.scss b/ui/packages/consul-ui/app/components/consul/bucket/list/index.scss new file mode 100644 index 000000000..826ef4841 --- /dev/null +++ b/ui/packages/consul-ui/app/components/consul/bucket/list/index.scss @@ -0,0 +1,26 @@ +%consul-bucket-list { + & { + @extend %horizontal-kv-list; + } + .partition::before { + @extend %with-user-team-mask, %as-pseudo; + } + .nspace::before { + @extend %with-folder-outline-mask, %as-pseudo; + } + /* potential for some sort of %composite-kv thing here */ + .partition + dd::after { + display: inline-block; + content: '/'; + margin: 0 3px; + /*TODO: In isolation this is not needed */ + margin-right: 6px; + } + .partition + dd + .nspace { + margin-left: 0 !important; + } + /**/ +} +.consul-bucket-list { + @extend %consul-bucket-list; +} diff --git a/ui/packages/consul-ui/app/components/consul/service/list/README.mdx b/ui/packages/consul-ui/app/components/consul/service/list/README.mdx new file mode 100644 index 000000000..3ffb50404 --- /dev/null +++ b/ui/packages/consul-ui/app/components/consul/service/list/README.mdx @@ -0,0 +1,28 @@ +# Consul::Service::List + +A presentational component for rendering a list of Consul Services. + +```hbs preview-template + + + +``` + +## Arguments + +| Argument/Attribute | Type | Default | Description | +| --- | --- | --- | --- | +| `items` | `array` | | An array of Consul Services | +| `nspace` | `string` | | The name of the current namespace | +| `partition` | `string` | | The name of the current partition | + +## See + +- [Template Source Code](./index.hbs) + +--- diff --git a/ui/packages/consul-ui/app/components/consul/service/list/index.hbs b/ui/packages/consul-ui/app/components/consul/service/list/index.hbs index fd5eaa568..f7643af0f 100644 --- a/ui/packages/consul-ui/app/components/consul/service/list/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/service/list/index.hbs @@ -25,7 +25,18 @@ {{#if (gt item.InstanceCount 0)}} - + {{item.Name}} {{else}} @@ -35,20 +46,6 @@ {{/if}} -{{#if (and nspace (env 'CONSUL_NSPACES_ENABLED'))}} - {{#if (not-eq item.Namespace nspace)}} -
-
- - Namespace - -
-
- {{item.Namespace}} -
-
- {{/if}} -{{/if}} {{#if (and (not-eq item.InstanceCount 0) (and (not-eq item.Kind 'terminating-gateway') (not-eq item.Kind 'ingress-gateway'))) }} @@ -87,6 +84,11 @@ {{/if}} {{/if}} +
\ No newline at end of file diff --git a/ui/packages/consul-ui/app/components/consul/service/search-bar/index.hbs b/ui/packages/consul-ui/app/components/consul/service/search-bar/index.hbs index 4c487e9f3..3b300dbbc 100644 --- a/ui/packages/consul-ui/app/components/consul/service/search-bar/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/service/search-bar/index.hbs @@ -140,11 +140,33 @@ as |key value|}} {{#let components.Optgroup components.Option as |Optgroup Option|}} +{{#let + (reject-by 'Partition' @partition @partitions) +as |nonDefaultPartitions|}} +{{#if (gt nonDefaultPartitions.length 0)}} + + {{#each @partitions as |partition|}} + + {{/each}} + +{{/if}} +{{/let}} + +{{#if (gt @sources.length 0)}} + {{#each @sources as |source|}} {{/each}} + +{{/if}} {{/let}} 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 7c605bb1b..1894bba9e 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 @@ -5,40 +5,26 @@