Skip to content

Commit

Permalink
Backport of Add some basic UI improvements for api-gateway services i…
Browse files Browse the repository at this point in the history
…nto release/1.15.x (#16533)

* backport of commit 06046ae

* backport of commit 884d72b

* backport of commit 9ff6b8b

* backport of commit 5a3e7ec

* backport of commit 38fec2d

* backport of commit 9844e07

---------

Co-authored-by: Andrew Stucki <[email protected]>
  • Loading branch information
hc-github-team-consul-core and Andrew Stucki authored Mar 3, 2023
1 parent 2f8de3c commit e69ed7a
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 94 deletions.
3 changes: 3 additions & 0 deletions .changelog/16508.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:improvement
ui: support filtering API gateways in the ui and displaying their documentation links
```
182 changes: 96 additions & 86 deletions ui/packages/consul-ui/app/components/consul/kind/index.hbs
Original file line number Diff line number Diff line change
@@ -1,89 +1,99 @@
{{#if item.Kind}}
{{#let (titleize (humanize item.Kind)) as |Name|}}
{{#if withInfo}}
<dl class="tooltip-panel">
<dt>
<span data-test-kind={{item.Kind}} class="consul-kind">
{{Name}}
</span>
</dt>
<dd>
<MenuPanel @position="left">
<BlockSlot @name="header">
{{#if (eq item.Kind 'ingress-gateway')}}
Ingress gateways enable ingress traffic from services outside the Consul service mesh to services inside the Consul service mesh.
{{else if (eq item.Kind 'terminating-gateway')}}
Terminating gateways allow connect-enabled services in Consul service mesh to communicate with services outside the service mesh.
{{else}}
Mesh gateways enable routing of Connect traffic between different Consul datacenters.
{{/if}}
</BlockSlot>
<BlockSlot @name="menu">
<li role="separator">
{{#if (eq item.Kind 'ingress-gateway')}}
About Ingress gateways
{{else if (eq item.Kind 'terminating-gateway')}}
About Terminating gateways
{{else}}
About Mesh gateways
{{/if}}
</li>
{{#let (from-entries (array
(array 'ingress-gateway' '/consul/developer-mesh/ingress-gateways')
(array 'terminating-gateway' '/consul/developer-mesh/understand-terminating-gateways')
(array 'mesh-gateway' '/consul/developer-mesh/connect-gateways')
)
) as |link|}}
<li role="none" class="learn-link">
<a tabindex="-1" role="menuitem" href={{concat (env 'CONSUL_DOCS_LEARN_URL') (get link item.Kind)}} rel="noopener noreferrer" target="_blank">
Learn guides
</a>
</li>
{{/let}}
{{#let (from-entries (array
(array 'ingress-gateway' '/connect/ingress-gateway')
(array 'terminating-gateway' '/connect/terminating-gateway')
(array 'mesh-gateway' '/connect/mesh-gateway')
)
) as |link|}}
<li role="none" class="docs-link">
<a tabindex="-1" role="menuitem" href={{concat (env 'CONSUL_DOCS_URL') (get link item.Kind)}} rel="noopener noreferrer" target="_blank">
Documentation
</a>
</li>
<li role="separator">
Other gateway types
</li>
{{#if (not-eq item.Kind 'mesh-gateway')}}
<li role="none" class="docs-link">
<a tabindex="-1" role="menuitem" href={{concat (env 'CONSUL_DOCS_URL') (get link 'mesh-gateway')}} rel="noopener noreferrer" target="_blank">
Mesh gateways
</a>
</li>
{{#if withInfo}}
<dl class="tooltip-panel">
<dt>
<span data-test-kind={{item.Kind}} class="consul-kind">
{{Name}}
</span>
</dt>
<dd>
<MenuPanel @position="left">
<BlockSlot @name="header">
{{#if (eq item.Kind 'ingress-gateway')}}
Ingress gateways enable ingress traffic from services outside the Consul service mesh to services inside the Consul service mesh.
{{else if (eq item.Kind 'terminating-gateway')}}
Terminating gateways allow connect-enabled services in Consul service mesh to communicate with services outside the service mesh.
{{else if (eq item.Kind 'api-gateway')}}
API gateways enable ingress traffic from services outside the Consul service mesh to services inside the Consul service mesh.
{{else}}
Mesh gateways enable routing of Connect traffic between different Consul datacenters.
{{/if}}
</BlockSlot>
<BlockSlot @name="menu">
<li role="separator">
{{#if (eq item.Kind 'ingress-gateway')}}
About Ingress gateways
{{else if (eq item.Kind 'terminating-gateway')}}
About Terminating gateways
{{else if (eq item.Kind 'api-gateway')}}
About API gateways
{{else}}
About Mesh gateways
{{/if}}
{{#if (not-eq item.Kind 'terminating-gateway')}}
<li role="none" class="docs-link">
<a tabindex="-1" role="menuitem" href={{concat (env 'CONSUL_DOCS_URL') (get link 'terminating-gateway')}} rel="noopener noreferrer" target="_blank">
Terminating gateways
</a>
</li>
{{/if}}
{{#if (not-eq item.Kind 'ingress-gateway')}}
<li role="none" class="docs-link">
<a tabindex="-1" role="menuitem" href={{concat (env 'CONSUL_DOCS_URL') (get link 'ingress-gateway')}} rel="noopener noreferrer" target="_blank">
Ingress gateways
</a>
</li>
{{/if}}
{{/let}}
</BlockSlot>
</MenuPanel>
</dd>
</dl>
{{else}}
<span data-test-kind={{item.Kind}} class="consul-kind">
{{Name}}
</span>
{{/if}}
{{/let}}
</li>
{{#let (from-entries (array
(array 'ingress-gateway' '/consul/developer-mesh/ingress-gateways')
(array 'terminating-gateway' '/consul/developer-mesh/understand-terminating-gateways')
(array 'mesh-gateway' '/consul/developer-mesh/connect-gateways')
)
) as |link|}}
<li role="none" class="learn-link">
<a tabindex="-1" role="menuitem" href={{concat (env 'CONSUL_DOCS_LEARN_URL') (get link item.Kind)}} rel="noopener noreferrer" target="_blank">
Learn guides
</a>
</li>
{{/let}}
{{#let (from-entries (array
(array 'ingress-gateway' '/connect/gateways/ingress-gateway')
(array 'terminating-gateway' '/connect/gateways/terminating-gateway')
(array 'api-gateway' '/connect/gateways/api-gateway')
(array 'mesh-gateway' '/connect/gateways/mesh-gateway')
)
) as |link|}}
<li role="none" class="docs-link">
<a tabindex="-1" role="menuitem" href={{concat (env 'CONSUL_DOCS_URL') (get link item.Kind)}} rel="noopener noreferrer" target="_blank">
Documentation
</a>
</li>
<li role="separator">
Other gateway types
</li>
{{#if (not-eq item.Kind 'mesh-gateway')}}
<li role="none" class="docs-link">
<a tabindex="-1" role="menuitem" href={{concat (env 'CONSUL_DOCS_URL') (get link 'mesh-gateway')}} rel="noopener noreferrer" target="_blank">
Mesh gateways
</a>
</li>
{{/if}}
{{#if (not-eq item.Kind 'terminating-gateway')}}
<li role="none" class="docs-link">
<a tabindex="-1" role="menuitem" href={{concat (env 'CONSUL_DOCS_URL') (get link 'terminating-gateway')}} rel="noopener noreferrer" target="_blank">
Terminating gateways
</a>
</li>
{{/if}}
{{#if (not-eq item.Kind 'ingress-gateway')}}
<li role="none" class="docs-link">
<a tabindex="-1" role="menuitem" href={{concat (env 'CONSUL_DOCS_URL') (get link 'ingress-gateway')}} rel="noopener noreferrer" target="_blank">
Ingress gateways
</a>
</li>
{{/if}}
{{#if (not-eq item.Kind 'api-gateway')}}
<li role="none" class="docs-link">
<a tabindex="-1" role="menuitem" href={{concat (env 'CONSUL_DOCS_URL') (get link 'api-gateway')}} rel="noopener noreferrer" target="_blank">
API gateways
</a>
</li>
{{/if}}
{{/let}}
</BlockSlot>
</MenuPanel>
</dd>
</dl>
{{else}}
<span data-test-kind={{item.Kind}} class="consul-kind">
{{Name}}
</span>
{{/if}}
{{/if}}
14 changes: 14 additions & 0 deletions ui/packages/consul-ui/app/components/consul/kind/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
import Component from '@ember/component';
import { computed } from '@ember/object';
import { titleize } from 'ember-cli-string-helpers/helpers/titleize';
import { humanize } from 'ember-cli-string-helpers/helpers/humanize';

const normalizedGatewayLabels = {
'api-gateway': 'API Gateway',
'mesh-gateway': 'Mesh Gateway',
'ingress-gateway': 'Ingress Gateway',
'terminating-gateway': 'Terminating Gateway',
};

export default Component.extend({
tagName: '',
Name: computed('item.Kind', function () {
const name = normalizedGatewayLabels[this.item.Kind];
return name ? name : titleize(humanize(this.item.Kind));
}),
});
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
{{t 'common.consul.service'}}
</Option>
<Optgroup @label={{t 'common.consul.gateway'}}>
{{#each (array 'ingress-gateway' 'terminating-gateway' 'mesh-gateway') as |kind|}}
{{#each (array 'api-gateway' 'ingress-gateway' 'terminating-gateway' 'mesh-gateway') as |kind|}}
<Option @value={{kind}} @selected={{includes kind @filter.kind.value}}>
{{t (concat 'common.consul.' kind)}}
</Option>
Expand Down
1 change: 1 addition & 0 deletions ui/packages/consul-ui/app/filter/predicates/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import setHelpers from 'mnemonist/set';

export default {
kind: {
'api-gateway': (item, value) => item.Kind === value,
'ingress-gateway': (item, value) => item.Kind === value,
'terminating-gateway': (item, value) => item.Kind === value,
'mesh-gateway': (item, value) => item.Kind === value,
Expand Down
10 changes: 7 additions & 3 deletions ui/packages/consul-ui/app/models/service-instance.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,13 @@ export default class ServiceInstance extends Model {

@computed('Service.Kind')
get IsProxy() {
return ['connect-proxy', 'mesh-gateway', 'ingress-gateway', 'terminating-gateway'].includes(
this.Service.Kind
);
return [
'connect-proxy',
'mesh-gateway',
'ingress-gateway',
'terminating-gateway',
'api-gateway',
].includes(this.Service.Kind);
}

// IsOrigin means that the service can have associated up or down streams,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ${[0].map(
() => {
let prevKind;
let name;
const gateways = ['mesh-gateway', 'ingress-gateway', 'terminating-gateway'];
const gateways = ['mesh-gateway', 'ingress-gateway', 'terminating-gateway', 'api-gateway'];
return `
[
${
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/consul-ui/mock-api/v1/internal/ui/services
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ${[0].map(
() => {
let prevKind;
let name;
const gateways = ['mesh-gateway', 'ingress-gateway', 'terminating-gateway'];
const gateways = ['mesh-gateway', 'ingress-gateway', 'terminating-gateway', 'api-gateway'];
return `
[
${
Expand Down
10 changes: 8 additions & 2 deletions ui/packages/consul-ui/tests/acceptance/dc/services/index.feature
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Feature: dc / services / index: List Services
---
Scenario: Viewing the service list page with gateways
Given 1 datacenter model with the value "dc-1"
And 3 service models from yaml
And 4 service models from yaml
---
- Name: Service-0-proxy
Kind: 'connect-proxy'
Expand All @@ -88,6 +88,11 @@ Feature: dc / services / index: List Services
ChecksPassing: 0
ChecksWarning: 0
ChecksCritical: 1
- Name: Service-3-api-gateway
Kind: 'api-gateway'
ChecksPassing: 0
ChecksWarning: 0
ChecksCritical: 1
---

When I visit the services page for yaml
Expand All @@ -96,11 +101,12 @@ Feature: dc / services / index: List Services
---
Then the url should be /dc-1/services
And the title should be "Services - Consul"
Then I see 2 service models
Then I see 3 service models
And I see kind on the services like yaml
---
- ingress-gateway
- terminating-gateway
- api-gateway
---
Scenario: View a Service in mesh
Given 1 datacenter model with the value "dc-1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Feature: dc / services / show / services
| Name | Kind |
| service | ~ |
| ingress-gateway | ingress-gateway |
| api-gateway | api-gateway |
| mesh-gateway | mesh-gateway |
---------------------------------------------

Expand Down
1 change: 1 addition & 0 deletions ui/packages/consul-ui/translations/common/en-us.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ consul:
ingress-gateway: Ingress Gateway
terminating-gateway: Terminating Gateway
mesh-gateway: Mesh Gateway
api-gateway: API Gateway
status: Health Status
service.meta: Service Meta
node.meta: Node Meta
Expand Down

0 comments on commit e69ed7a

Please sign in to comment.