ui: Adds partition support to Service and Node Identity templates (#11696)

This commit is contained in:
John Cowen 2021-12-06 10:33:44 +00:00 committed by GitHub
parent f27685cc40
commit 171cb0a247
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 173 additions and 27 deletions

3
.changelog/11696.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:feature
ui: Adds support for partitions to Service and Node Identity template visuals.
```

View File

@ -16,11 +16,7 @@ state: needs-love
Rules <a href="{{env 'CONSUL_DOCS_URL'}}/guides/acl.html#rule-specification" rel="help noopener noreferrer" target="_blank">(HCL Format)</a> Rules <a href="{{env 'CONSUL_DOCS_URL'}}/guides/acl.html#rule-specification" rel="help noopener noreferrer" target="_blank">(HCL Format)</a>
</:label> </:label>
<:content> <:content>
<!-- Plain text or something that renders data like the following --> {"content": "Initial Content"}
<Consul::ServiceIdentity::Template
@nspace={{nspace}}
@name={{item.Name}}
/>
</:content> </:content>
</CodeEditor> </CodeEditor>
``` ```

View File

@ -18,11 +18,20 @@
{{mode.name}} {{mode.name}}
</PowerSelect> </PowerSelect>
<div class="toolbar-separator"></div> <div class="toolbar-separator"></div>
<CopyButton @value={{value}} @name="value" /> <CopyButton
@value={{value}}
@name="value"
/>
{{/if}} {{/if}}
{{/if}} {{/if}}
</div> </div>
</div> </div>
</div> </div>
<IvyCodemirror @value={{value}} @name={{name}} @class={{class}} @options={{options}} @valueUpdated={{action onkeyup}} /> <IvyCodemirror
@value={{value}}
@name={{name}}
@class={{class}}
@options={{options}}
@valueUpdated={{action onkeyup}}
/>
<pre><code>{{#if (has-block "content")}}{{yield to="content"}}{{else}}{{value}}{{/if}}</code></pre> <pre><code>{{#if (has-block "content")}}{{yield to="content"}}{{else}}{{value}}{{/if}}</code></pre>

View File

@ -0,0 +1,27 @@
# Consul::Node::Identity::Template
The component is a text-only template that represents what a NodeIdentity
policy looks like. The policy generated here is **not** what is sent back to
the backend, instead its just a visual representation of what happens in the
backend when you save a NodeIdentity.
```hbs preview-template
<pre><code><Consul::NodeIdentity::Template
@partition={{'default-ier'}}
@name={{"Policy-Name"}}
/></code></pre>
```
## Arguments
| Argument/Attribute | Type | Default | Description |
| --- | --- | --- | --- |
| `partition` | `string` | `default` | The name of the current partition |
| `name` | `string` | | The name of the policy the will be used to
interpolate the various policy names |
## See
- [Template Source Code](./index.hbs)
---

View File

@ -1,4 +1,27 @@
{{#if (env "CONSUL_NSPACES_ENABLED")}} {{#if (can "use partitions")~}}
partition "{{or @partition 'default'}}" {
{{#if (can "use nspaces")}}
namespace "default" {
node "{{@name}}" {
policy = "write"
}
}
namespace_prefix "" {
service_prefix "" {
policy = "read"
}
}
{{else}}
node "{{@name}}" {
policy = "write"
}
service_prefix "" {
policy = "read"
}
{{/if}}
}
{{~else~}}
{{~#if (can "use nspaces")~}}
namespace "default" { namespace "default" {
node "{{@name}}" { node "{{@name}}" {
policy = "write" policy = "write"
@ -16,4 +39,5 @@ node "{{@name}}" {
service_prefix "" { service_prefix "" {
policy = "read" policy = "read"
} }
{{/if}} {{~/if~}}
{{~/if~}}

View File

@ -0,0 +1,29 @@
# Consul::ServiceIdentity::Template
The component is a text-only template that represents what a NodeIdentity
policy looks like. The policy generated here is **not** what is sent back to
the backend, instead its just a visual representation of what happens in the
backend when you save a NodeIdentity.
```hbs preview-template
<pre><code><Consul::ServiceIdentity::Template
@nspace={{'default-est'}}
@partition={{'default-ier'}}
@name={{"Policy-Name"}}
/></code></pre>
```
## Arguments
| Argument/Attribute | Type | Default | Description |
| --- | --- | --- | --- |
| `nspace` | `string` | `default` | The name of the current namespace |
| `partition` | `string` | `default` | The name of the current partition |
| `name` | `string` | | The name of the policy the will be used to
interpolate the various policy names |
## See
- [Template Source Code](./index.hbs)
---

View File

@ -1,5 +1,38 @@
{{#if (env "CONSUL_NSPACES_ENABLED")}} {{#if (can "use partitions")}}
namespace "{{@nspace}}" { partition "{{or @partition 'default'}}" {
{{#if (can 'use nspaces')}}
namespace "{{or @nspace 'default'}}" {
service "{{@name}}" {
policy = "write"
}
service "{{@name}}-sidecar-proxy" {
policy = "write"
}
service_prefix "" {
policy = "read"
}
node_prefix "" {
policy = "read"
}
}
{{else}}
service "{{@name}}" {
policy = "write"
}
service "{{@name}}-sidecar-proxy" {
policy = "write"
}
service_prefix "" {
policy = "read"
}
node_prefix "" {
policy = "read"
}
{{/if}}
}
{{else}}
{{#if (can 'use nspaces')}}
namespace "{{or @nspace 'default'}}" {
service "{{@name}}" { service "{{@name}}" {
policy = "write" policy = "write"
} }
@ -27,3 +60,4 @@ node_prefix "" {
policy = "read" policy = "read"
} }
{{/if}} {{/if}}
{{/if}}

View File

@ -20,3 +20,19 @@ p code {
@extend %inline-code; @extend %inline-code;
} }
``` ```
We also have a `%block-code` that is currently contained in the same CSS files here as it shares so much of this (this should potentially be thought about and reorganized at some stage)
At the time of writing we only use this in the docs for all `<pre><code>`s.
```hbs preview-template
<pre><code>{
"Code": true
}</code></pre>
```
```css
pre code {
@extend %block-code;
}
```

View File

@ -2,3 +2,7 @@
display: inline-block; display: inline-block;
padding: 0 4px; padding: 0 4px;
} }
%block-code {
display: block;
padding: 0 8px;
}

View File

@ -1,3 +1,4 @@
%block-code,
%inline-code { %inline-code {
border: 1px solid; border: 1px solid;
color: rgb(var(--tone-brand-600)); color: rgb(var(--tone-brand-600));

View File

@ -47,12 +47,11 @@
<:label> <:label>
Rules <a href="{{env 'CONSUL_DOCS_URL'}}/guides/acl.html#rule-specification" rel="help noopener noreferrer" target="_blank">(HCL Format)</a> Rules <a href="{{env 'CONSUL_DOCS_URL'}}/guides/acl.html#rule-specification" rel="help noopener noreferrer" target="_blank">(HCL Format)</a>
</:label> </:label>
<:content> <:content><Consul::ServiceIdentity::Template
<Consul::ServiceIdentity::Template
@nspace={{nspace}} @nspace={{nspace}}
@partition={{partition}}
@name={{item.Name}} @name={{item.Name}}
/> /></:content>
</:content>
</CodeEditor> </CodeEditor>
{{else if (eq item.template 'node-identity')}} {{else if (eq item.template 'node-identity')}}
<CodeEditor <CodeEditor
@ -64,11 +63,10 @@
<:label> <:label>
Rules <a href="{{env 'CONSUL_DOCS_URL'}}/guides/acl.html#rule-specification" rel="help noopener noreferrer" target="_blank">(HCL Format)</a> Rules <a href="{{env 'CONSUL_DOCS_URL'}}/guides/acl.html#rule-specification" rel="help noopener noreferrer" target="_blank">(HCL Format)</a>
</:label> </:label>
<:content> <:content><Consul::NodeIdentity::Template
<Consul::NodeIdentity::Template
@name={{item.Name}} @name={{item.Name}}
/> @partition={{partition}}
</:content> /></:content>
</CodeEditor> </CodeEditor>
{{else}} {{else}}
<CodeEditor <CodeEditor

View File

@ -125,6 +125,7 @@
<:content> <:content>
<Consul::ServiceIdentity::Template <Consul::ServiceIdentity::Template
@nspace={{nspace}} @nspace={{nspace}}
@partition={{partition}}
@name={{item.Name}} @name={{item.Name}}
/> />
</:content> </:content>
@ -140,6 +141,7 @@
<:content> <:content>
<Consul::NodeIdentity::Template <Consul::NodeIdentity::Template
@name={{item.Name}} @name={{item.Name}}
@partition={{partition}}
/> />
</:content> </:content>
</CodeEditor> </CodeEditor>

View File

@ -31,24 +31,24 @@
@extend %p3; @extend %p3;
text-align: center; text-align: center;
} }
[id^="docfy-demo-preview-color"] ul, [id^='docfy-demo-preview-color'] ul,
[id^="docfy-demo-preview-typography"] ul, [id^='docfy-demo-preview-typography'] ul,
[id^="docfy-demo-preview-icons"] ul { [id^='docfy-demo-preview-icons'] ul {
@extend %debug-grid; @extend %debug-grid;
} }
[id^="docfy-demo-preview-typography"] figure, [id^='docfy-demo-preview-typography'] figure,
[id^="docfy-demo-preview-icons"] figure { [id^='docfy-demo-preview-icons'] figure {
border: var(--decor-border-100); border: var(--decor-border-100);
border-color: rgb(var(--tone-gray-300)); border-color: rgb(var(--tone-gray-300));
height: 80px; height: 80px;
} }
[id^="docfy-demo-preview-icons"] figure::before { [id^='docfy-demo-preview-icons'] figure::before {
position: relative; position: relative;
top: 20px; top: 20px;
} }
[id^="docfy-demo-preview-color"] figure { [id^='docfy-demo-preview-color'] figure {
height: 40px; height: 40px;
} }
#docfy-demo-preview-color0 { #docfy-demo-preview-color0 {
@ -60,7 +60,7 @@
@extend %theme-dark; @extend %theme-dark;
} }
[id^="docfy-demo-preview-typography"] { [id^='docfy-demo-preview-typography'] {
.debug-h000 { .debug-h000 {
@extend %h000; @extend %h000;
} }
@ -248,6 +248,9 @@ html.with-route-announcer .route-title {
figcaption code { figcaption code {
@extend %inline-code; @extend %inline-code;
} }
pre code {
@extend %block-code;
}
figure > [type='text'] { figure > [type='text'] {
border: 1px solid rgb(var(--tone-gray-999)); border: 1px solid rgb(var(--tone-gray-999));
width: 100%; width: 100%;