From 2d25de2291f86b29ccea1b2e7c3a103800ef320b Mon Sep 17 00:00:00 2001 From: Kenia <19161242+kaxcode@users.noreply.github.com> Date: Thu, 26 Aug 2021 13:58:06 -0400 Subject: [PATCH] ui: Add support in Topology view for Routing Configurations (#10872) --- .changelog/10872.txt | 3 ++ .../topology-metrics/card/index.hbs | 19 ++++++++--- .../components/topology-metrics/card/index.js | 11 ++++++ .../topology-metrics/source-type/index.hbs | 5 +-- .../v1/internal/ui/service-topology/_ | 4 +-- .../show/topology/routing-config.feature | 34 +++++++++++++++++++ .../show/topology/routing-config-steps.js | 10 ++++++ .../translations/components/consul/en-us.yaml | 8 +++-- 8 files changed, 83 insertions(+), 11 deletions(-) create mode 100644 .changelog/10872.txt create mode 100644 ui/packages/consul-ui/app/components/topology-metrics/card/index.js create mode 100644 ui/packages/consul-ui/tests/acceptance/dc/services/show/topology/routing-config.feature create mode 100644 ui/packages/consul-ui/tests/acceptance/steps/dc/services/show/topology/routing-config-steps.js diff --git a/.changelog/10872.txt b/.changelog/10872.txt new file mode 100644 index 000000000..c5144bd05 --- /dev/null +++ b/.changelog/10872.txt @@ -0,0 +1,3 @@ +```release-note:feature +ui: Adding support in Topology view for Routing Configurations +``` \ No newline at end of file diff --git a/ui/packages/consul-ui/app/components/topology-metrics/card/index.hbs b/ui/packages/consul-ui/app/components/topology-metrics/card/index.hbs index b2343df9f..0e457b229 100644 --- a/ui/packages/consul-ui/app/components/topology-metrics/card/index.hbs +++ b/ui/packages/consul-ui/app/components/topology-metrics/card/index.hbs @@ -1,15 +1,16 @@ {{#if (eq @item.Name '* (All Services)')}} - +

{{@item.Name}}

{{else}} - {{#if (eq @item.Source 'proxy-registration')}} - + + {{/if}} + {{#if (eq @item.Source 'routing-config')}} + {{/if}}
{{#if (and (env 'CONSUL_NSPACES_ENABLED') (not-eq @item.Namespace @service.Namespace))}} @@ -33,6 +37,9 @@ {{/if}} + +{{#if (not-eq @item.Source 'routing-config')}} + {{#if (eq @item.Datacenter @dc)}} {{#let (service/health-percentage @item) as |percentage|}} {{#if (eq percentage '')}} @@ -60,6 +67,8 @@ Health +{{/if}} + {{/if}}
{{yield}} diff --git a/ui/packages/consul-ui/app/components/topology-metrics/card/index.js b/ui/packages/consul-ui/app/components/topology-metrics/card/index.js new file mode 100644 index 000000000..9821dcc92 --- /dev/null +++ b/ui/packages/consul-ui/app/components/topology-metrics/card/index.js @@ -0,0 +1,11 @@ +import Component from '@glimmer/component'; +import { get } from '@ember/object'; + +export default class TopologyMetrics extends Component { + // =methods + get hrefPath() { + const source = get(this.args.item, 'Source'); + + return source === 'routing-config' ? 'dc.routing-config' : 'dc.services.show.index'; + } +} diff --git a/ui/packages/consul-ui/app/components/topology-metrics/source-type/index.hbs b/ui/packages/consul-ui/app/components/topology-metrics/source-type/index.hbs index 6ffec49aa..84b8d4457 100644 --- a/ui/packages/consul-ui/app/components/topology-metrics/source-type/index.hbs +++ b/ui/packages/consul-ui/app/components/topology-metrics/source-type/index.hbs @@ -1,6 +1,7 @@ - {{t "components.consul.topology-metrics.source-type.text"}} + {{t (concat "components.consul.topology-metrics.source-type." @source ".text")}} \ No newline at end of file diff --git a/ui/packages/consul-ui/mock-api/v1/internal/ui/service-topology/_ b/ui/packages/consul-ui/mock-api/v1/internal/ui/service-topology/_ index bd2335c0a..bb810f7e7 100644 --- a/ui/packages/consul-ui/mock-api/v1/internal/ui/service-topology/_ +++ b/ui/packages/consul-ui/mock-api/v1/internal/ui/service-topology/_ @@ -78,7 +78,7 @@ ${ "ChecksPassing":${fake.random.number({min: 1, max: env('CONSUL_CHECK_COUNT', fake.random.number(10))})}, "ChecksWarning":${fake.random.number({min: 0, max: env('CONSUL_CHECK_COUNT', fake.random.number(10))})}, "ChecksCritical":${fake.random.number({min: 0, max: env('CONSUL_CHECK_COUNT', fake.random.number(10))})}, - "Source": "${fake.helpers.randomize(['proxy-registration', 'default-allow', 'wildcard-intention'])}", + "Source": "${fake.helpers.randomize(['routing-config', 'proxy-registration', 'default-allow', 'wildcard-intention'])}", "TransparentProxy": ${fake.random.boolean()}, "Intention": { "Allowed": ${allowed}, @@ -104,7 +104,7 @@ ${ "ChecksPassing":${fake.random.number({min: 1, max: env('CONSUL_CHECK_COUNT', fake.random.number(10))})}, "ChecksWarning":${fake.random.number({min: 0, max: env('CONSUL_CHECK_COUNT', fake.random.number(10))})}, "ChecksCritical":${fake.random.number({min: 0, max: env('CONSUL_CHECK_COUNT', fake.random.number(10))})}, - "Source": "${fake.helpers.randomize(['proxy-registration', 'specific-intention', 'default-allow', 'wildcard-intention'])}", + "Source": "${fake.helpers.randomize(['routing-config', 'proxy-registration', 'specific-intention', 'default-allow', 'wildcard-intention'])}", "TransparentProxy": ${fake.random.boolean()}, "Intention": { "Allowed": ${allowed}, diff --git a/ui/packages/consul-ui/tests/acceptance/dc/services/show/topology/routing-config.feature b/ui/packages/consul-ui/tests/acceptance/dc/services/show/topology/routing-config.feature new file mode 100644 index 000000000..43ff33555 --- /dev/null +++ b/ui/packages/consul-ui/tests/acceptance/dc/services/show/topology/routing-config.feature @@ -0,0 +1,34 @@ +@setupApplicationTest +Feature: dc / services / show / topology / routing-config + Background: + Given 1 datacenter model with the value "dc1" + And 1 node models + And 1 service model from yaml + --- + - Service: + Name: service-0 + ID: service-0-with-id + --- + And 1 topology model from yaml + --- + Upstreams: [] + Downstreams: + - Name: db + Namespace: @namespace + Datacenter: dc1 + Intention: {} + Source: routing-config + --- + When I visit the service page for yaml + --- + dc: dc1 + service: service-0 + --- + And I see topology on the tabs + Scenario: Given the Source is routing config, show Source Type + Then I see the text "Routing configuration" in "[data-test-topology-metrics-source-type]" + Scenario: Given the Source is routing config, redirect to Routing Config page + When I click "[data-test-topology-metrics-card]" + Then the url should be /dc1/routing-config/db + + diff --git a/ui/packages/consul-ui/tests/acceptance/steps/dc/services/show/topology/routing-config-steps.js b/ui/packages/consul-ui/tests/acceptance/steps/dc/services/show/topology/routing-config-steps.js new file mode 100644 index 000000000..f2aad107e --- /dev/null +++ b/ui/packages/consul-ui/tests/acceptance/steps/dc/services/show/topology/routing-config-steps.js @@ -0,0 +1,10 @@ +import steps from '../../../../steps'; + +// step definitions that are shared between features should be moved to the +// tests/acceptance/steps/steps.js file + +export default function(assert) { + return steps(assert).then('I should find a file', function() { + assert.ok(true, this.step); + }); +} diff --git a/ui/packages/consul-ui/translations/components/consul/en-us.yaml b/ui/packages/consul-ui/translations/components/consul/en-us.yaml index fba5a51f6..4bde6dc2e 100644 --- a/ui/packages/consul-ui/translations/components/consul/en-us.yaml +++ b/ui/packages/consul-ui/translations/components/consul/en-us.yaml @@ -117,8 +117,12 @@ intention: transparent-proxy: Transparent Proxy topology-metrics: source-type: - tooltip: This connection was defined in a proxy registration. - text: Defined in proxy registration + proxy-registration: + tooltip: This connection was defined in a proxy registration. + text: Defined in proxy registration + routing-config: + tooltip: This is not a registered Consul service. It’s a routing configuration that routes traffic to real services in Consul. + text: Routing configuration notice: limited-access: header: Limited Access