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