From f3efde38431851d98df661bcd770da65a856fc35 Mon Sep 17 00:00:00 2001
From: Kenia <19161242+kaxcode@users.noreply.github.com>
Date: Tue, 25 May 2021 11:02:38 -0400
Subject: [PATCH] ui: Create and use collapsible notices component (#10270)
* Create and use collapsible notices
* Refactor collapsible-notices
* Split up the topology acceptance tests
* Add acceptance tests for tproxy notices
* Add component file
* Adds additional TProxy notices tests
* Adds conditional to only show collapsable if more than 2 notices are present
* Adds changelog
* Refactorting the conditonal for collapsing the notices
* Renaming undefinedIntention to be notDefinedIntention
* Refactor tests
---
.changelog/10270.txt | 3 +
.../components/collapsible-notices/README.mdx | 66 +++++++++++
.../components/collapsible-notices/index.hbs | 10 ++
.../components/collapsible-notices/index.js | 3 +
.../components/collapsible-notices/index.scss | 31 +++++
ui/packages/consul-ui/app/models/topology.js | 24 ++--
.../consul-ui/app/styles/components.scss | 1 +
.../templates/dc/services/show/topology.hbs | 110 +++++++++++++-----
.../intentions.feature} | 27 +----
.../dc/services/show/topology/metrics.feature | 50 ++++++++
.../dc/services/show/topology/tproxy.feature | 101 ++++++++++++++++
.../intentions-steps.js} | 2 +-
.../services/show/topology/metrics-steps.js | 10 ++
.../dc/services/show/topology/tproxy-steps.js | 10 ++
ui/packages/consul-ui/tests/pages.js | 11 +-
.../consul-ui/tests/pages/dc/services/show.js | 25 +++-
.../translations/components/app/en-us.yaml | 3 +
17 files changed, 419 insertions(+), 68 deletions(-)
create mode 100644 .changelog/10270.txt
create mode 100644 ui/packages/consul-ui/app/components/collapsible-notices/README.mdx
create mode 100644 ui/packages/consul-ui/app/components/collapsible-notices/index.hbs
create mode 100644 ui/packages/consul-ui/app/components/collapsible-notices/index.js
create mode 100644 ui/packages/consul-ui/app/components/collapsible-notices/index.scss
rename ui/packages/consul-ui/tests/acceptance/dc/services/show/{topology.feature => topology/intentions.feature} (65%)
create mode 100644 ui/packages/consul-ui/tests/acceptance/dc/services/show/topology/metrics.feature
create mode 100644 ui/packages/consul-ui/tests/acceptance/dc/services/show/topology/tproxy.feature
rename ui/packages/consul-ui/tests/acceptance/steps/dc/services/show/{topology-steps.js => topology/intentions-steps.js} (86%)
create mode 100644 ui/packages/consul-ui/tests/acceptance/steps/dc/services/show/topology/metrics-steps.js
create mode 100644 ui/packages/consul-ui/tests/acceptance/steps/dc/services/show/topology/tproxy-steps.js
diff --git a/.changelog/10270.txt b/.changelog/10270.txt
new file mode 100644
index 0000000000..a5a5fe36eb
--- /dev/null
+++ b/.changelog/10270.txt
@@ -0,0 +1,3 @@
+```release-note:feature
+ui: Create a collapsible notices component for the Topology tab
+```
\ No newline at end of file
diff --git a/ui/packages/consul-ui/app/components/collapsible-notices/README.mdx b/ui/packages/consul-ui/app/components/collapsible-notices/README.mdx
new file mode 100644
index 0000000000..c6cc7f06e9
--- /dev/null
+++ b/ui/packages/consul-ui/app/components/collapsible-notices/README.mdx
@@ -0,0 +1,66 @@
+# CollapsibleNotices
+
+Used as a wrapper to collapse the details of ``.
+
+```hbs preview-template
+
+
+
+ Header
+
+
+
+ Body
+
+
+
+
+
+ Header
+
+
+
+ Body
+
+
+
+
+ Footer
+
+
+
+
+
+ Header
+
+
+
+ Body
+
+
+
+
+ Footer
+
+
+
+
+
+```
+
+## Arguments
+
+No arguments required. Wrap this component around the needed notices.
+
+## See
+
+- [Template Source Code](./index.hbs)
+
+---
\ No newline at end of file
diff --git a/ui/packages/consul-ui/app/components/collapsible-notices/index.hbs b/ui/packages/consul-ui/app/components/collapsible-notices/index.hbs
new file mode 100644
index 0000000000..0920ff97f5
--- /dev/null
+++ b/ui/packages/consul-ui/app/components/collapsible-notices/index.hbs
@@ -0,0 +1,10 @@
+
+
+ {{yield}}
+
+{{#if this.collapsed}}
+
+{{else}}
+
+{{/if}}
+
diff --git a/ui/packages/consul-ui/app/components/collapsible-notices/index.js b/ui/packages/consul-ui/app/components/collapsible-notices/index.js
new file mode 100644
index 0000000000..8b246f27e2
--- /dev/null
+++ b/ui/packages/consul-ui/app/components/collapsible-notices/index.js
@@ -0,0 +1,3 @@
+import Component from '@glimmer/component';
+
+export default class CollapsibleNotices extends Component {}
diff --git a/ui/packages/consul-ui/app/components/collapsible-notices/index.scss b/ui/packages/consul-ui/app/components/collapsible-notices/index.scss
new file mode 100644
index 0000000000..b33f8a57b1
--- /dev/null
+++ b/ui/packages/consul-ui/app/components/collapsible-notices/index.scss
@@ -0,0 +1,31 @@
+.collapsible-notices {
+ display: grid;
+ grid-template-columns: auto 168px;;
+ grid-template-rows: auto 55px;
+ grid-template-areas:
+ "notices notices"
+ ". toggle-button";
+ &.collapsed p {
+ display: none;
+ }
+ .notices {
+ grid-area: notices;
+ :last-child {
+ margin-bottom: 0;
+ }
+ }
+ button {
+ @extend %button;
+ color: $color-action;
+ float: right;
+ grid-area: toggle-button;
+ margin-top: 1em;
+ margin-bottom: 2em;
+ }
+ button.expand::before {
+ @extend %with-chevron-down-mask, %as-pseudo;
+ }
+ button.collapse::before {
+ @extend %with-chevron-up-mask, %as-pseudo;
+ }
+}
\ No newline at end of file
diff --git a/ui/packages/consul-ui/app/models/topology.js b/ui/packages/consul-ui/app/models/topology.js
index 29bfb448e0..feb384db62 100644
--- a/ui/packages/consul-ui/app/models/topology.js
+++ b/ui/packages/consul-ui/app/models/topology.js
@@ -19,23 +19,27 @@ export default class Topology extends Model {
@attr() Downstreams; // Service[],
@attr() meta; // {}
- @computed('Upstreams', 'Downstreams')
- get undefinedIntention() {
- let undefinedUpstream = false;
+ @computed('Downstreams')
+ get notDefinedIntention() {
let undefinedDownstream = false;
- undefinedUpstream =
- this.Upstreams.filter(
- item =>
- item.Source === 'specific-intention' && !item.TransparentProxy && item.Intention.Allowed
- ).length !== 0;
-
undefinedDownstream =
this.Downstreams.filter(
item =>
item.Source === 'specific-intention' && !item.TransparentProxy && item.Intention.Allowed
).length !== 0;
- return undefinedUpstream || undefinedDownstream;
+ return undefinedDownstream;
+ }
+
+ @computed('FilteredByACL', 'DefaultAllow', 'WildcardIntention', 'notDefinedIntention')
+ get collapsible() {
+ if (this.DefaultAllow && this.FilteredByACLs && this.notDefinedIntention) {
+ return true;
+ } else if (this.WildcardIntention && this.FilteredByACLs && this.notDefinedIntention) {
+ return true;
+ }
+
+ return false;
}
}
diff --git a/ui/packages/consul-ui/app/styles/components.scss b/ui/packages/consul-ui/app/styles/components.scss
index 725454482b..16aac17300 100644
--- a/ui/packages/consul-ui/app/styles/components.scss
+++ b/ui/packages/consul-ui/app/styles/components.scss
@@ -73,6 +73,7 @@
@import 'consul-ui/components/consul/auth-method';
@import 'consul-ui/components/role-selector';
+@import 'consul-ui/components/collapsible-notices';
@import 'consul-ui/components/topology-metrics';
@import 'consul-ui/components/topology-metrics/card';
@import 'consul-ui/components/topology-metrics/source-type';
diff --git a/ui/packages/consul-ui/app/templates/dc/services/show/topology.hbs b/ui/packages/consul-ui/app/templates/dc/services/show/topology.hbs
index 7807564db7..a0ab0167b0 100644
--- a/ui/packages/consul-ui/app/templates/dc/services/show/topology.hbs
+++ b/ui/packages/consul-ui/app/templates/dc/services/show/topology.hbs
@@ -21,44 +21,92 @@ as |route|>
+ {{else}}
+ {{#if topology.collapsible}}
+
+ {{#if topology.FilteredByACLs}}
+
+ {{/if}}
+ {{#if topology.DefaultAllow}}
+
+ {{/if}}
+ {{#if topology.WildcardIntention}}
+
+ {{/if}}
+ {{#if topology.notDefinedIntention}}
+
+ {{/if}}
+
{{else}}
{{#if topology.FilteredByACLs}}
-
- {{/if}}
- {{#if topology.DefaultAllow}}
-
- {{/if}}
- {{#if topology.WildcardIntention}}
-
- {{/if}}
- {{#if topology.undefinedIntention}}
-
- {{/if}}
+
+ {{/if}}
+ {{#if topology.DefaultAllow}}
+
+ {{/if}}
+ {{#if topology.WildcardIntention}}
+
+ {{/if}}
+ {{#if topology.notDefinedIntention}}
+
+ {{/if}}
+ {{/if}}
+
+
ul > li:not(:first-child)', {
name: text('[data-test-service-name]'),
diff --git a/ui/packages/consul-ui/translations/components/app/en-us.yaml b/ui/packages/consul-ui/translations/components/app/en-us.yaml
index a040ddaaae..251a49abe8 100644
--- a/ui/packages/consul-ui/translations/components/app/en-us.yaml
+++ b/ui/packages/consul-ui/translations/components/app/en-us.yaml
@@ -5,3 +5,6 @@ toggle_menu: Toggle Menu
# therefore potentially do not need the word 'navigation' adding to them
main: Main
complementary: Complementary
+collapsible-notices:
+ expand: Expand Banners
+ collapse: Collapse Banners
\ No newline at end of file