Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: ConsulKind explanatory tooltip panels #8048

Merged
merged 8 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 91 additions & 9 deletions ui-v2/app/components/consul-kind/index.hbs
Original file line number Diff line number Diff line change
@@ -1,11 +1,93 @@
{{#if item.Kind}}
{{#if (has-block)}}
{{yield
(component 'consul-kind' item=item)
}}
{{else}}
<span data-test-kind={{item.Kind}} class="consul-kind gateway">
<span>{{titleize (humanize item.Kind)}}</span>
</span>
{{/if}}
{{#let (titleize (humanize item.Kind)) as |Name|}}
{{#if (has-block)}}
{{yield
(component 'consul-kind' item=item withInfo=withInfo)
}}
{{else}}
{{#if withInfo}}
<dl class="tooltip-panel">
<dt>
<span data-test-kind={{item.Kind}} class="consul-kind gateway">
<span>{{Name}}</span>
</span>
</dt>
<dd>
<MenuPanel @position="left">
<BlockSlot @name="header">
{{#if (eq item.Kind 'ingress-gateway')}}
Ingress gateways enable ingress traffic from services outside the Consul service mesh to services inside the Consul service mesh.
{{else if (eq item.Kind 'terminating-gateway')}}
Terminating gateways allow connect-enabled services in Consul service mesh to communicate with services outside the service mesh.
{{else}}
Mesh gateways enable routing of Connect traffic between different Consul datacenters.
{{/if}}
</BlockSlot>
<BlockSlot @name="menu">
<li role="separator">
{{#if (eq item.Kind 'ingress-gateway')}}
About Ingress gateways
{{else if (eq item.Kind 'terminating-gateway')}}
About Terminating gateways
{{else}}
About Mesh gateways
{{/if}}
</li>
{{#let (from-entries
(array 'ingress-gateway' '/consul/developer-mesh/ingress-gateways')
(array 'terminating-gateway' '/consul/developer-mesh/understand-terminating-gateways')
(array 'mesh-gateway' '/consul/developer-mesh/connect-gateways')
) as |link|}}
<li role="none" class="learn-link">
<a tabindex="-1" role="menuitem" href={{concat (env 'CONSUL_DOCS_LEARN_URL') (get link item.Kind)}} rel="noopener noreferrer" target="_blank">
Learn guides
</a>
</li>
{{/let}}
{{#let (from-entries
(array 'ingress-gateway' '/connect/ingress_gateway.html')
(array 'terminating-gateway' '/connect/terminating_gateway.html')
(array 'mesh-gateway' '/connect/mesh_gateway.html')
) as |link|}}
<li role="none" class="docs-link">
<a tabindex="-1" role="menuitem" href={{concat (env 'CONSUL_DOCS_URL') (get link item.Kind)}} rel="noopener noreferrer" target="_blank">
Documentation
</a>
</li>
<li role="separator">
Other gateway types
</li>
{{#if (not-eq item.Kind 'mesh-gateway')}}
<li role="none" class="docs-link">
<a tabindex="-1" role="menuitem" href={{concat (env 'CONSUL_DOCS_URL') (get link 'mesh-gateway')}} rel="noopener noreferrer" target="_blank">
Mesh gateways
</a>
</li>
{{/if}}
{{#if (not-eq item.Kind 'terminating-gateway')}}
<li role="none" class="docs-link">
<a tabindex="-1" role="menuitem" href={{concat (env 'CONSUL_DOCS_URL') (get link 'terminating-gateway')}} rel="noopener noreferrer" target="_blank">
Terminating gateways
</a>
</li>
{{/if}}
{{#if (not-eq item.Kind 'ingress-gateway')}}
<li role="none" class="docs-link">
<a tabindex="-1" role="menuitem" href={{concat (env 'CONSUL_DOCS_URL') (get link 'ingress-gateway')}} rel="noopener noreferrer" target="_blank">
Ingress gateways
</a>
</li>
{{/if}}
{{/let}}
</BlockSlot>
</MenuPanel>
</dd>
</dl>
{{else}}
<span data-test-kind={{item.Kind}} class="consul-kind gateway">
<span>{{Name}}</span>
</span>
{{/if}}
{{/if}}
{{/let}}
{{/if}}
2 changes: 1 addition & 1 deletion ui-v2/app/components/hashicorp-consul/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{{#if dc}}
<ul>
{{#if (and (env 'CONSUL_NSPACES_ENABLED') (gt nspaces.length 0))}}
<li data-test-nspace-menu>
<li class="nspaces" data-test-nspace-menu>
{{#if (and (eq nspaces.length 1) (not canManageNspaces)) }}
<span data-test-nspace-selected={{nspace.Name}}>{{nspace.Name}}</span>
{{ else }}
Expand Down
15 changes: 15 additions & 0 deletions ui-v2/app/components/menu-panel/index.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{yield}}
<div class="menu-panel {{position}}">
<YieldSlot @name="controls">
{{yield}}
</YieldSlot>
{{#yield-slot name="header"}}
<div>{{yield}}</div>
{{else}}
{{/yield-slot}}
<ul role="menu" ...attributes>
<YieldSlot @name="menu">
{{yield}}
</YieldSlot>
</ul>
</div>
7 changes: 7 additions & 0 deletions ui-v2/app/components/menu-panel/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Component from '@ember/component';

import Slotted from 'block-slots';

export default Component.extend(Slotted, {
tagName: '',
});
29 changes: 15 additions & 14 deletions ui-v2/app/components/popover-menu/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,22 @@
</YieldSlot>
</button>
</ToggleButton>
<div class={{position}}>
<input type="checkbox" id={{concat 'popover-menu-' guid '-'}} />
{{#each submenus as |sub|}}
<input type="checkbox" id={{concat 'popover-menu-' guid '-' sub}} />
{{/each}}
{{#yield-slot name='header'}}
<div>
{{yield}}
</div>
{{else}}
{{/yield-slot}}
<ul role="menu" id={{ariaControls}} aria-labelledby={{ariaLabelledBy}} aria-expanded={{ariaExpanded}}>
<MenuPanel @position={{position}} id={{ariaControls}} aria-labelledby={{ariaLabelledBy}} aria-expanded={{ariaExpanded}}>
<BlockSlot @name="controls">
<input type="checkbox" id={{concat 'popover-menu-' guid '-'}} />
{{#each submenus as |sub|}}
<input type="checkbox" id={{concat 'popover-menu-' guid '-' sub}} />
{{/each}}
</BlockSlot>
{{#if hasHeader}}
<BlockSlot @name="header">
{{#yield-slot name="header"}}{{yield}}{{else}}{{/yield-slot}}
</BlockSlot>
{{/if}}
<BlockSlot @name="menu">
<YieldSlot @name="menu" @params={{block-params (concat "popover-menu-" guid "-") send keypressClick this.toggle.click}}>
{{yield}}
</YieldSlot>
</ul>
</div>
</BlockSlot>
</MenuPanel>
</AriaMenu>
4 changes: 4 additions & 0 deletions ui-v2/app/components/popover-menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import Component from '@ember/component';
import { inject as service } from '@ember/service';
import Slotted from 'block-slots';
import { set } from '@ember/object';

export default Component.extend(Slotted, {
tagName: '',
Expand All @@ -16,6 +17,9 @@ export default Component.extend(Slotted, {
this._super(...arguments);
this.guid = this.dom.guid(this);
},
willRender: function() {
set(this, 'hasHeader', this._isRegistered('header'));
},
actions: {
change: function(e) {
if (!e.target.checked) {
Expand Down
5 changes: 5 additions & 0 deletions ui-v2/app/helpers/from-entries.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { helper } from '@ember/component/helper';

export default helper(function fromEntries(params /*, hash*/) {
return Object.fromEntries(params);
});
1 change: 1 addition & 0 deletions ui-v2/app/styles/base/components/buttons/skin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@extend %user-select-none;
cursor: pointer;
white-space: nowrap;
text-decoration: none;
}
%button:disabled,
%internal-button:disabled {
Expand Down
13 changes: 9 additions & 4 deletions ui-v2/app/styles/base/components/menu-panel/layout.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
%menu-panel {
position: absolute;
overflow: hidden;
}
%menu-panel [type='checkbox'] {
display: none;
Expand All @@ -15,8 +14,14 @@
/* or be hardcoded */
/* min-height: 143px; */
}
%menu-panel [role='menuitem']::after {
float: right;
%menu-panel [role='menuitem'] {
display: flex;
justify-content: space-between;
}
%menu-panel [role='menuitem']:after {
@extend %as-pseudo;
display: block !important;
background-position: center right !important;
}
%menu-panel-sub-panel {
position: absolute;
Expand Down Expand Up @@ -70,7 +75,7 @@
}
%menu-panel-header {
padding: 10px;
padding-left: 36px;
white-space: normal;
}
/* here the !important is only needed for what seems to be a difference */
/* with the CSS before and after compression */
Expand Down
10 changes: 5 additions & 5 deletions ui-v2/app/styles/base/components/menu-panel/skin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
border-top: $decor-border-100;
border-color: $gray-300;
}
%menu-panel-header {
background-color: $gray-050;

%menu-panel .docs-link a::after {
@extend %with-docs-mask, %as-pseudo;
}
%menu-panel-header::before {
@extend %with-info-circle-fill-color-icon, %as-pseudo;
font-size: 1.1em;
%menu-panel .learn-link a::after {
@extend %with-learn-mask, %as-pseudo;
}
%menu-panel .is-active > *::after {
@extend %with-check-plain-mask, %as-pseudo;
Expand Down
1 change: 1 addition & 0 deletions ui-v2/app/styles/base/components/popover-menu/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
%popover-menu + label > * {
@extend %toggle-button;
}
%more-popover-menu-panel,
%popover-menu-panel {
@extend %menu-panel;
}
2 changes: 1 addition & 1 deletion ui-v2/app/styles/base/components/popover-menu/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@extend %toggle-button;
}
%more-popover-menu-panel {
@extend %menu-panel;
overflow: hidden;
width: 192px;
}
%more-popover-menu + label + div {
Expand Down
2 changes: 2 additions & 0 deletions ui-v2/app/styles/components/app-view/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
display: flex;
align-items: center;
white-space: nowrap;
position: relative;
z-index: 1;
}
%app-view-actions {
margin-left: auto;
Expand Down
2 changes: 2 additions & 0 deletions ui-v2/app/styles/components/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
@import './list-collection';
@import './grid-collection';
@import './popover-select';
@import './tooltip-panel';
@import './menu-panel';

/**/

Expand Down
2 changes: 1 addition & 1 deletion ui-v2/app/styles/components/main-header-horizontal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@extend %with-docs-icon, %as-pseudo;
}
%main-nav-horizontal .feedback-link a::after {
@extend %with-logo-github-monochrome-icon, %as-pseudo;
@extend %with-logo-github-monochrome-mask, %as-pseudo;
}
%main-header-horizontal::before {
background-color: var(--swatch-brand-600, $black);
Expand Down
9 changes: 9 additions & 0 deletions ui-v2/app/styles/components/main-nav-horizontal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
%secondary-nav {
@extend %main-nav-horizontal;
}
%primary-nav .nspaces .menu-panel > div {
background-color: $gray-050;
padding-left: 36px;
}
%primary-nav .nspaces .menu-panel > div::before {
@extend %with-info-circle-fill-mask, %as-pseudo;
color: $blue-500;
font-size: 1.1em;
}

%main-header-horizontal > div {
@extend %main-nav-horizontal-panel;
Expand Down
3 changes: 3 additions & 0 deletions ui-v2/app/styles/components/menu-panel.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.menu-panel {
@extend %menu-panel;
}
4 changes: 4 additions & 0 deletions ui-v2/app/styles/components/tooltip-panel.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@import './tooltip-panel/index';
.tooltip-panel {
@extend %tooltip-panel;
}
2 changes: 2 additions & 0 deletions ui-v2/app/styles/components/tooltip-panel/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@import './skin';
@import './layout';
19 changes: 19 additions & 0 deletions ui-v2/app/styles/components/tooltip-panel/layout.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
%tooltip-panel {
margin: 0 !important;
}
%tooltip-panel dd > div {
top: auto !important;
}
%tooltip-panel dt {
cursor: pointer;
}
%tooltip-panel dd {
display: none;
position: relative;
}
%tooltip-panel:hover dd {
display: block;
}
%tooltip-panel dd > div {
width: 250px;
}
13 changes: 13 additions & 0 deletions ui-v2/app/styles/components/tooltip-panel/skin.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* This is the top chevron */
%tooltip-panel dd > div::before {
@extend %as-pseudo;
width: 12px;
height: 12px;
background: white;
border-top: 1px solid $gray-300;
border-right: 1px solid $gray-300;
transform: rotate(-45deg);
position: absolute;
left: 8px;
top: -7px;
}
12 changes: 6 additions & 6 deletions ui-v2/app/templates/dc/services/show.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@
{{item.Service.Service}}
</h1>
<ConsulExternalSource @item={{item.Service}} />
<ConsulKind @item={{item.Service}} />
<ConsulKind @item={{item.Service}} @withInfo={{true}} />
johncowen marked this conversation as resolved.
Show resolved Hide resolved
</BlockSlot>
<BlockSlot @name="nav">
{{#if (not-eq item.Service.Kind 'mesh-gateway')}}
<TabNav @items={{
compact
(array
(hash label="Instances" href=(href-to "dc.services.show.instances") selected=(is-href "dc.services.show.instances"))
(if (eq item.Service.Kind 'terminating-gateway')
(if (eq item.Service.Kind 'terminating-gateway')
(hash label="Linked Services" href=(href-to "dc.services.show.services") selected=(is-href "dc.services.show.services"))
'')
(if (eq item.Service.Kind 'ingress-gateway')
(if (eq item.Service.Kind 'ingress-gateway')
(hash label="Upstreams" href=(href-to "dc.services.show.upstreams") selected=(is-href "dc.services.show.upstreams"))
'')
(if (not item.Service.Kind)
(if (not item.Service.Kind)
(hash label="Intentions" href=(href-to "dc.services.show.intentions") selected=(is-href "dc.services.show.intentions"))
'')
(if chain
(if chain
(hash label="Routing" href=(href-to "dc.services.show.routing") selected=(is-href "dc.services.show.routing"))
'')
(if (not item.Service.Kind)
(if (not item.Service.Kind)
(hash label="Tags" href=(href-to "dc.services.show.tags") selected=(is-href "dc.services.show.tags"))
'')
)
Expand Down