ui: reuse BucketList for intention view pages (#11765)

This commit is contained in:
John Cowen 2021-12-13 15:00:51 +00:00 committed by GitHub
parent b9e1dcde1c
commit 4734d0989c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 83 additions and 13 deletions

View File

@ -11,22 +11,41 @@ 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 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`) `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 Showing the service name is a tiny bit awkward (different boolean type,
omit the `@nspace` argument. doesn't care about difference) and could be improved but we only use it for
the read only view of intentions.
At the time of writing, this is not currently used across the entire UI 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. (specifically in intentions and maybe other areas) but eventually should be.
```hbs preview-template ```hbs preview-template
<DataSource <figure>
@src={{uri "/partition/default/dc-1/gateways/for-service/service-name"}} as |source|> <figcaption>Show everything</figcaption>
<Consul::Bucket::List <Consul::Bucket::List
@item={{object-at 0 source.data}} @item={{hash
Namespace="different-nspace"
Partition="different-partition"
Service="service-name"
}}
@nspace={{'nspace'}}
@partition={{'partition'}}
@service={{true}}
/>
</figure>
<figure>
<figcaption>Show just the top-level buckets</figcaption>
<Consul::Bucket::List
@item={{hash
Namespace="different-nspace"
Partition="different-partition"
}}
@nspace={{'nspace'}} @nspace={{'nspace'}}
@partition={{'partition'}} @partition={{'partition'}}
/> />
</DataSource> </figure>
``` ```
## Arguments ## Arguments
@ -36,6 +55,7 @@ At the time of writing, this is not currently used across the entire UI
| `item` | `array` | | A Consul object that could have both a `Partition` and a `Namespace` property | | `item` | `array` | | A Consul object that could have both a `Partition` and a `Namespace` property |
| `nspace` | `string` | | The name of the current namespace | | `nspace` | `string` | | The name of the current namespace |
| `partition` | `string` | | The name of the current partition | | `partition` | `string` | | The name of the current partition |
| `service` | `boolean` | | Whether to show the service name on the end or not. Please note you must also pass a item.Service for it to show. We flag this incase an API request has a Service property but you don't want to show it |
## See ## See

View File

@ -19,11 +19,23 @@
<dd> <dd>
{{@item.Namespace}} {{@item.Namespace}}
</dd> </dd>
{{#if (and @service @item.Service)}}
<dt
class="service"
>
Service
</dt>
<dd>
{{@item.Service}}
</dd>
{{/if}}
</dl> </dl>
{{/if}} {{/if}}
{{else if (and @nspace (can 'use nspace'))}} {{else if (and @nspace (can 'use nspace'))}}
{{#if (not-eq @item.Namespace @nspace)}} {{#if (not-eq @item.Namespace @nspace)}}
<dl> <dl class="consul-bucket-list">
<dt <dt
class="nspace" class="nspace"
{{tooltip}} {{tooltip}}
@ -33,7 +45,16 @@
<dd> <dd>
{{@item.Namespace}} {{@item.Namespace}}
</dd> </dd>
{{#if (and @service @item.Service)}}
<dt
class="service"
>
Service
</dt>
<dd>
{{@item.Service}}
</dd>
{{/if}}
</dl> </dl>
{{/if}} {{/if}}
{{/if}} {{/if}}

View File

@ -8,15 +8,22 @@
.nspace::before { .nspace::before {
@extend %with-folder-outline-mask, %as-pseudo; @extend %with-folder-outline-mask, %as-pseudo;
} }
.service {
@extend %visually-hidden;
}
.service + dd {
font-weight: var(--typo-weight-semibold);
}
/* potential for some sort of %composite-kv thing here */ /* potential for some sort of %composite-kv thing here */
.partition + dd::after { dd:not(:last-child)::after {
display: inline-block; display: inline-block;
content: '/'; content: '/';
margin: 0 3px; margin: 0 3px;
/*TODO: In isolation this is not needed */ /*TODO: In isolation this is not needed */
margin-right: 6px; margin-right: 6px;
} }
.partition + dd + .nspace { .service + dd,
dd + dt {
margin-left: 0 !important; margin-left: 0 !important;
} }
/**/ /**/

View File

@ -4,11 +4,29 @@
<dl> <dl>
<dt>Destination</dt> <dt>Destination</dt>
<dd> <dd>
{{item.DestinationName}}{{#if (can "use partitions")}} / {{item.DestinationPartition}}{{/if}}{{#if (can "use nspaces")}} / {{item.DestinationNS}}{{/if}} <Consul::Bucket::List
@item={{hash
Namespace=item.DestinationNS
Partition=item.DestinationPartition
Service=item.DestinationName
}}
@nspace="-"
@partition="-"
@service={{true}}
/>
</dd> </dd>
<dt>Source</dt> <dt>Source</dt>
<dd> <dd>
{{item.SourceName}}{{#if (can "use partitions")}} / {{item.SourcePartition}}{{/if}}{{#if (can "use nspaces")}} / {{item.SourceNS}}{{/if}} <Consul::Bucket::List
@item={{hash
Namespace=item.SourceNS
Partition=item.SourcePartition
Service=item.SourceName
}}
@nspace="-"
@partition="-"
@service={{true}}
/>
</dd> </dd>
{{#if item.Action}} {{#if item.Action}}
<dt>Action</dt> <dt>Action</dt>

View File

@ -6,6 +6,10 @@
%definition-table > dl { %definition-table > dl {
margin-bottom: 1.4em; margin-bottom: 1.4em;
} }
%definition-table dd > * { /* TODO: We currently have one instance of nested dls */
/* and that is for nesting a bucket list */
/* we should probably think about changing this to possibly inline flex */
/* or individually styling the contents */
%definition-table > dl > dd > *:not(dl) {
display: inline-block; display: inline-block;
} }