From 2bdc98552a4f860c45b902ffc56c70363a254699 Mon Sep 17 00:00:00 2001 From: Kenia <19161242+kaxcode@users.noreply.github.com> Date: Wed, 10 Nov 2021 16:54:12 -0500 Subject: [PATCH] ui: Add Consul API Gateway as an external source (#11371) --- .changelog/11371.txt | 3 + .../consul/external-source/index.hbs | 59 +++++++++++++------ .../consul/intention/list/table/index.hbs | 2 +- .../consul-ui/app/components/pill/index.scss | 3 +- .../app/components/popover-menu/layout.scss | 2 +- .../app/components/popover-select/index.scss | 6 +- .../app/components/topology-metrics/index.hbs | 2 + .../app/helpers/service/external-source.js | 7 ++- .../app/templates/dc/services/instance.hbs | 2 +- .../app/templates/dc/services/show.hbs | 2 +- ui/packages/consul-ui/mock-api/v1/connect/_ | 2 +- .../mock-api/v1/connect/intentions/_ | 2 +- .../mock-api/v1/connect/intentions/exact | 2 +- .../consul-ui/mock-api/v1/health/service/_ | 2 +- .../consul-ui/mock-api/v1/internal/ui/node/_ | 2 +- .../mock-api/v1/internal/ui/services | 2 +- .../dc/services/show/topology/metrics.feature | 22 +++++++ .../consul-ui/translations/common/en-us.yaml | 1 + 18 files changed, 93 insertions(+), 30 deletions(-) create mode 100644 .changelog/11371.txt diff --git a/.changelog/11371.txt b/.changelog/11371.txt new file mode 100644 index 000000000..eff8f65a6 --- /dev/null +++ b/.changelog/11371.txt @@ -0,0 +1,3 @@ +```release-note:feature +ui: Adding support of Consul API Gateway as an external source. +``` \ No newline at end of file diff --git a/ui/packages/consul-ui/app/components/consul/external-source/index.hbs b/ui/packages/consul-ui/app/components/consul/external-source/index.hbs index 38f446386..a2ee22a00 100644 --- a/ui/packages/consul-ui/app/components/consul/external-source/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/external-source/index.hbs @@ -1,21 +1,46 @@ {{#if @item}} {{#let (service/external-source @item) as |externalSource|}} - {{#if externalSource}} - - {{#if @label}} - {{@label}} - {{else}} - {{#if (eq externalSource 'aws')}} - Registered via {{uppercase externalSource}} - {{else}} - Registered via {{capitalize externalSource}} - {{/if}} - {{/if}} - - {{/if}} + {{#if (and @withInfo (eq externalSource 'consul-api-gateway'))}} +
+
+ + Registered via {{t (concat "common.brand." externalSource)}} + +
+
+ + + API Gateways manage north-south traffic from external services to services in the Datacenter. For more information, read our documentation. + + +
  • + About {{t (concat "common.brand." externalSource)}} +
  • + +
    +
    +
    +
    + {{else if externalSource}} + + {{#if @label}} + {{@label}} + {{else}} + Registered via {{t (concat "common.brand." externalSource)}} + {{/if}} + + {{/if}} {{/let}} {{/if}} diff --git a/ui/packages/consul-ui/app/components/consul/intention/list/table/index.hbs b/ui/packages/consul-ui/app/components/consul/intention/list/table/index.hbs index 25044226e..761dbe603 100644 --- a/ui/packages/consul-ui/app/components/consul/intention/list/table/index.hbs +++ b/ui/packages/consul-ui/app/components/consul/intention/list/table/index.hbs @@ -65,7 +65,7 @@ as |item index|> {{/if}} -{{#if (or (can "write intention" item=item) (can "view CRD intention" item=item))}} +{{#if (and (or (can "write intention" item=item) (can "view CRD intention" item=item)) (not-eq item.Meta.external-source 'consul-api-gateway'))}} {{@service.Service.Service}} + {{#if (not-eq @service.Service.Meta.external-source 'consul-api-gateway')}} {{#if @hasMetricsProvider}} Configure dashboard {{/if}} + {{/if}}
    - + {{#if (eq proxy.ServiceProxy.Mode 'transparent')}} diff --git a/ui/packages/consul-ui/app/templates/dc/services/show.hbs b/ui/packages/consul-ui/app/templates/dc/services/show.hbs index a406a8573..568e82dbe 100644 --- a/ui/packages/consul-ui/app/templates/dc/services/show.hbs +++ b/ui/packages/consul-ui/app/templates/dc/services/show.hbs @@ -112,7 +112,7 @@ as |items item dc|}}

    - + diff --git a/ui/packages/consul-ui/mock-api/v1/connect/_ b/ui/packages/consul-ui/mock-api/v1/connect/_ index 0e7cec685..773dbc6bd 100644 --- a/ui/packages/consul-ui/mock-api/v1/connect/_ +++ b/ui/packages/consul-ui/mock-api/v1/connect/_ @@ -96,7 +96,7 @@ ${fake.helpers.randomize([ "Precedence": ${i + 1}, ${ fake.random.number({min: 1, max: 10}) > 2 ? ` "Meta": { - "external-source": "${fake.helpers.randomize(['kubernetes'])}" + "external-source": "${fake.helpers.randomize(['kubernetes', 'consul-api-gateway'])}" }, ` : `` } "CreatedAt": "2018-05-21T16:41:27.977155457Z", diff --git a/ui/packages/consul-ui/mock-api/v1/connect/intentions/_ b/ui/packages/consul-ui/mock-api/v1/connect/intentions/_ index d739883eb..40c1abdd4 100644 --- a/ui/packages/consul-ui/mock-api/v1/connect/intentions/_ +++ b/ui/packages/consul-ui/mock-api/v1/connect/intentions/_ @@ -81,7 +81,7 @@ ${fake.helpers.randomize([ "Precedence": ${fake.random.number({min: 1, max: 100})}, ${ !legacy && fake.random.number({min: 1, max: 10}) > 2 ? ` "Meta": { - "external-source": "${fake.helpers.randomize(['kubernetes'])}" + "external-source": "${fake.helpers.randomize(['kubernetes', 'consul-api-gateway'])}" }, ` : `` } "CreatedAt": "2018-05-21T16:41:27.977155457Z", diff --git a/ui/packages/consul-ui/mock-api/v1/connect/intentions/exact b/ui/packages/consul-ui/mock-api/v1/connect/intentions/exact index 72d7633e2..40825c210 100644 --- a/ui/packages/consul-ui/mock-api/v1/connect/intentions/exact +++ b/ui/packages/consul-ui/mock-api/v1/connect/intentions/exact @@ -83,7 +83,7 @@ ${fake.helpers.randomize([ "Precedence": ${fake.random.number({min: 1, max: 100})}, ${ !legacy && fake.random.number({min: 1, max: 10}) > 2 ? ` "Meta": { - "external-source": "${fake.helpers.randomize(['kubernetes'])}" + "external-source": "${fake.helpers.randomize(['kubernetes', 'consul-api-gateway'])}" }, ` : `` } "CreatedAt": "2018-05-21T16:41:27.977155457Z", diff --git a/ui/packages/consul-ui/mock-api/v1/health/service/_ b/ui/packages/consul-ui/mock-api/v1/health/service/_ index 6c108c76c..3427304ae 100644 --- a/ui/packages/consul-ui/mock-api/v1/health/service/_ +++ b/ui/packages/consul-ui/mock-api/v1/health/service/_ @@ -81,7 +81,7 @@ ${typeof location.search.partition !== 'undefined' ? ` ${ fake.random.number({min: 1, max: 10}) > 2 ? ` "Meta": { "consul-dashboard-url": "${fake.internet.protocol()}://${fake.internet.domainName()}/?id={{Service}}", - "external-source": "${fake.helpers.randomize(['vault', 'consul', 'nomad', 'terraform', 'kubernetes', 'aws', ''])}" + "external-source": "${fake.helpers.randomize(['consul-api-gateway', 'vault', 'consul', 'nomad', 'terraform', 'kubernetes', 'aws', ''])}" }, ` : ` "Meta": null, diff --git a/ui/packages/consul-ui/mock-api/v1/internal/ui/node/_ b/ui/packages/consul-ui/mock-api/v1/internal/ui/node/_ index d75f7a47e..a89e38293 100644 --- a/ui/packages/consul-ui/mock-api/v1/internal/ui/node/_ +++ b/ui/packages/consul-ui/mock-api/v1/internal/ui/node/_ @@ -60,7 +60,7 @@ return ` ], ${ fake.random.number({min: 1, max: 10}) > 2 ? ` "Meta": { - "external-source": "${fake.helpers.randomize(['consul', 'nomad', 'terraform', 'kubernetes', ''])}" + "external-source": "${fake.helpers.randomize(['consul-api-gateway', 'consul', 'nomad', 'terraform', 'kubernetes', ''])}" }, ` : `` } "Address":"", diff --git a/ui/packages/consul-ui/mock-api/v1/internal/ui/services b/ui/packages/consul-ui/mock-api/v1/internal/ui/services index 52b34d27a..66b7d9fd7 100644 --- a/ui/packages/consul-ui/mock-api/v1/internal/ui/services +++ b/ui/packages/consul-ui/mock-api/v1/internal/ui/services @@ -82,7 +82,7 @@ ${ fake.random.number({min: 1, max: 10}) > 2 ? ` range(fake.random.number({min: 1, max: 1})).map( function(item, i) { - return `"${fake.helpers.randomize(['vault', 'nomad', 'terraform', 'kubernetes', 'aws', ''])}"`; + return `"${fake.helpers.randomize(['consul-api-gateway', 'vault', 'nomad', 'terraform', 'kubernetes', 'aws', ''])}"`; } ) } diff --git a/ui/packages/consul-ui/tests/acceptance/dc/services/show/topology/metrics.feature b/ui/packages/consul-ui/tests/acceptance/dc/services/show/topology/metrics.feature index 77fda8cdf..403830924 100644 --- a/ui/packages/consul-ui/tests/acceptance/dc/services/show/topology/metrics.feature +++ b/ui/packages/consul-ui/tests/acceptance/dc/services/show/topology/metrics.feature @@ -48,3 +48,25 @@ Feature: dc / services / show / topology / metrics service: web --- And I see the "[data-test-sparkline]" element + Scenario: Metrics enabled but serivce source is Consul API Gateway + Given 1 datacenter model with the value "datacenter" + And the local datacenter is "datacenter" + And 1 service model from yaml + --- + - Service: + Name: web + Kind: ~ + Meta: + external-source: consul-api-gateway + --- + And ui_config from yaml + --- + metrics_proxy_enabled: true + metrics_provider: 'prometheus' + --- + When I visit the service page for yaml + --- + dc: datacenter + service: web + --- + And I don't see the "[data-test-sparkline]" element diff --git a/ui/packages/consul-ui/translations/common/en-us.yaml b/ui/packages/consul-ui/translations/common/en-us.yaml index af5ce6889..cefd9f949 100644 --- a/ui/packages/consul-ui/translations/common/en-us.yaml +++ b/ui/packages/consul-ui/translations/common/en-us.yaml @@ -1,5 +1,6 @@ brand: consul: Consul + consul-api-gateway: Consul API Gateway terraform: Terraform nomad: Nomad vault: Vault