diff --git a/.changelog/11280.txt b/.changelog/11280.txt new file mode 100644 index 000000000..38cdedf9c --- /dev/null +++ b/.changelog/11280.txt @@ -0,0 +1,3 @@ +```release-note:feature +ui: Topology - New views for scenarios where no dependencies exist or ACLs are disabled +``` \ 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 0e457b229..1a6417cf5 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,5 +1,9 @@ -{{#if (eq @item.Name '* (All Services)')}} - +{{#if (eq @item.Datacenter '')}} +

{{@item.Name}}

@@ -12,7 +16,7 @@ (href-to this.hrefPath @item.Datacenter @item.Name params=(hash nspace=@item.Namespace)) (href-to this.hrefPath @item.Name) }} - data-permission={{service/intention-permissions @item}} + data-permission={{service/card-permissions @item}} id="{{@item.Namespace}}{{@item.Name}}" >

diff --git a/ui/packages/consul-ui/app/components/topology-metrics/down-lines/index.hbs b/ui/packages/consul-ui/app/components/topology-metrics/down-lines/index.hbs index c617a182c..c27c6d028 100644 --- a/ui/packages/consul-ui/app/components/topology-metrics/down-lines/index.hbs +++ b/ui/packages/consul-ui/app/components/topology-metrics/down-lines/index.hbs @@ -84,7 +84,7 @@ {{#let (not (can 'update intention for service' item=@service.Service)) as |disabled|}} {{#each @items as |item|}} - {{#if (or (not item.Intention.Allowed) item.Intention.HasPermissions)}} + {{#if (and (not-eq item.Datacenter '') (or (not item.Intention.Allowed) item.Intention.HasPermissions))}} - {{else if (and item.Intention.Allowed (not item.TransparentProxy) (eq item.Source 'specific-intention'))}} + {{else if (and (not-eq item.Datacenter '') item.Intention.Allowed (not item.TransparentProxy) (eq item.Source 'specific-intention'))}} -{{#if (gt @topology.Downstreams.length 0)}} +{{#if (gt this.downstreams.length 0)}}

+ {{#if (not this.emptyColumn)}}

{{@dc.Name}}

@@ -16,7 +17,8 @@
- {{#each @topology.Downstreams as |item|}} + {{/if}} + {{#each this.downstreams as |item|}}
diff --git a/ui/packages/consul-ui/app/components/topology-metrics/index.js b/ui/packages/consul-ui/app/components/topology-metrics/index.js index d7d17236f..45d835804 100644 --- a/ui/packages/consul-ui/app/components/topology-metrics/index.js +++ b/ui/packages/consul-ui/app/components/topology-metrics/index.js @@ -1,8 +1,11 @@ import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { action, get } from '@ember/object'; +import { inject as service } from '@ember/service'; export default class TopologyMetrics extends Component { + @service('env') env; + // =attributes @tracked centerDimensions; @tracked downView; @@ -66,19 +69,58 @@ export default class TopologyMetrics extends Component { }); } + emptyColumn() { + const noDependencies = get(this.args.topology, 'noDependencies'); + return !this.env.var('CONSUL_ACLS_ENABLED') || noDependencies; + } + + get downstreams() { + const downstreams = get(this.args.topology, 'Downstreams') || []; + const items = [...downstreams]; + const noDependencies = get(this.args.topology, 'noDependencies'); + + if (!this.env.var('CONSUL_ACLS_ENABLED') && noDependencies) { + items.push({ + Name: 'Downstreams unknown.', + Empty: true, + Datacenter: '', + Namespace: '', + }); + } else if (downstreams.length === 0) { + items.push({ + Name: 'No downstreams.', + Datacenter: '', + Namespace: '', + }); + } + + return items; + } + get upstreams() { const upstreams = get(this.args.topology, 'Upstreams') || []; const items = [...upstreams]; const defaultACLPolicy = get(this.args.dc, 'DefaultACLPolicy'); const wildcardIntention = get(this.args.topology, 'wildcardIntention'); - if (defaultACLPolicy === 'allow' || wildcardIntention) { + const noDependencies = get(this.args.topology, 'noDependencies'); + + if (!this.env.var('CONSUL_ACLS_ENABLED') && noDependencies) { + items.push({ + Name: 'Upstreams unknown.', + Datacenter: '', + Namespace: '', + }); + } else if (defaultACLPolicy === 'allow' || wildcardIntention) { items.push({ Name: '* (All Services)', Datacenter: '', Namespace: '', - Intention: { - Allowed: true, - }, + }); + } else if (upstreams.length === 0) { + items.push({ + Name: 'No upstreams.', + Datacenter: '', + Namespace: '', }); } return items; @@ -112,10 +154,21 @@ export default class TopologyMetrics extends Component { } // Calculate viewBox dimensions - this.downView = document.getElementById('downstream-lines').getBoundingClientRect(); + const downstreamLines = document.getElementById('downstream-lines').getBoundingClientRect(); const upstreamLines = document.getElementById('upstream-lines').getBoundingClientRect(); const upstreamColumn = document.getElementById('upstream-column'); + if (this.emptyColumn) { + this.downView = { + x: downstreamLines.x, + y: downstreamLines.y, + width: downstreamLines.width, + height: downstreamLines.height + 10, + }; + } else { + this.downView = downstreamLines; + } + if (upstreamColumn) { this.upView = { x: upstreamLines.x, diff --git a/ui/packages/consul-ui/app/components/topology-metrics/skin.scss b/ui/packages/consul-ui/app/components/topology-metrics/skin.scss index 92d907c89..afd24a606 100644 --- a/ui/packages/consul-ui/app/components/topology-metrics/skin.scss +++ b/ui/packages/consul-ui/app/components/topology-metrics/skin.scss @@ -65,7 +65,8 @@ stroke: rgb(var(--tone-gray-300)); stroke-width: 2; } - path[data-permission='not-defined'] { + path[data-permission='not-defined'], + path[data-permission='empty'] { stroke-dasharray: 4; } path[data-permission='deny'] { diff --git a/ui/packages/consul-ui/app/components/topology-metrics/up-lines/index.hbs b/ui/packages/consul-ui/app/components/topology-metrics/up-lines/index.hbs index 33b9e59e4..2f3748280 100644 --- a/ui/packages/consul-ui/app/components/topology-metrics/up-lines/index.hbs +++ b/ui/packages/consul-ui/app/components/topology-metrics/up-lines/index.hbs @@ -83,7 +83,7 @@ {{/if}} {{#each @items as |item|}} - {{#if (or (not item.Intention.Allowed) item.Intention.HasPermissions)}} + {{#if (and (not-eq item.Datacenter '') (or (not item.Intention.Allowed) item.Intention.HasPermissions))}} loader.data as |nspace dc items topology|}}
- {{#if (and (eq topology.Upstreams.length 0) (eq topology.Downstreams.length 0) (not-eq dc.DefaultACLPolicy 'allow') (not topology.wildcardIntention))}} - - -

- No dependencies -

-
- -

- This service has neither downstreams nor upstreams, which means that no services are configured to connect with it. Add upstreams and intentions to ensure this service is connected with the rest of your service mesh. -

-
- -
- - - {{else}} - {{#let (collapsible-notices topology.FilteredByACLs (eq dc.DefaultACLPolicy 'allow') topology.wildcardIntention topology.notDefinedIntention) as |collapsible| }} {{#if topology.FilteredByACLs}} @@ -85,6 +65,26 @@ as |nspace dc items topology|}} @action={{true}} /> {{/if}} + {{#if (and topology.noDependencies (can 'use acls'))}} + + {{/if}} + {{#if (and topology.noDependencies (not (can 'use acls')))}} + + {{/if}} {{/let}} {{/if}} - - {{/if}}
{{/let}} diff --git a/ui/packages/consul-ui/tests/acceptance/steps/dc/services/show/topology/empty-steps.js b/ui/packages/consul-ui/tests/acceptance/steps/dc/services/show/topology/empty-steps.js new file mode 100644 index 000000000..f2aad107e --- /dev/null +++ b/ui/packages/consul-ui/tests/acceptance/steps/dc/services/show/topology/empty-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/tests/integration/helpers/service/intention-permissions-test.js b/ui/packages/consul-ui/tests/integration/helpers/service/card-permissions-test.js similarity index 76% rename from ui/packages/consul-ui/tests/integration/helpers/service/intention-permissions-test.js rename to ui/packages/consul-ui/tests/integration/helpers/service/card-permissions-test.js index 6219c04de..5ea7544bb 100644 --- a/ui/packages/consul-ui/tests/integration/helpers/service/intention-permissions-test.js +++ b/ui/packages/consul-ui/tests/integration/helpers/service/card-permissions-test.js @@ -3,7 +3,7 @@ import { setupRenderingTest } from 'ember-qunit'; import { render } from '@ember/test-helpers'; import { hbs } from 'ember-cli-htmlbars'; -module('Integration | Helper | service/intention-permissions', function(hooks) { +module('Integration | Helper | service/card-permissions', function(hooks) { setupRenderingTest(hooks); // TODO: Replace this with your real tests. @@ -15,7 +15,7 @@ module('Integration | Helper | service/intention-permissions', function(hooks) { }, }); - await render(hbs`{{service/intention-permissions inputValue}}`); + await render(hbs`{{service/card-permissions inputValue}}`); assert.equal(this.element.textContent.trim(), 'allow'); }); diff --git a/ui/packages/consul-ui/tests/pages/dc/services/show.js b/ui/packages/consul-ui/tests/pages/dc/services/show.js index 52910c3da..8914eb9dd 100644 --- a/ui/packages/consul-ui/tests/pages/dc/services/show.js +++ b/ui/packages/consul-ui/tests/pages/dc/services/show.js @@ -48,6 +48,12 @@ export default function( notDefinedIntention: { see: isPresent('[data-test-notice="not-defined-intention"]'), }, + noDependencies: { + see: isPresent('[data-test-notice="no-dependencies"]'), + }, + aclsDisabled: { + see: isPresent('[data-test-notice="acls-disabled"]'), + }, }; page.tabs.upstreamsTab = { services: collection('.consul-upstream-list > ul > li:not(:first-child)', { 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 fdc946617..03f3cd84c 100644 --- a/ui/packages/consul-ui/translations/components/consul/en-us.yaml +++ b/ui/packages/consul-ui/translations/components/consul/en-us.yaml @@ -143,6 +143,14 @@ topology-metrics: footer: name: Edit intentions URL: dc.services.show.intentions + no-dependencies: + header: No dependencies + body: The service you are viewing currently has no dependencies. You will only see metrics for the current service until dependencies are added. + footer: Read the documentation + acls-disabled: + header: Enable ACLs + body: This connect-native service may have dependencies, but Consul isn't aware of them when ACLs are disabled. Enable ACLs to make this view more useful. + footer: Read the documentation popover: l7: header: Layer 7 permissions