mirror of
https://github.com/status-im/consul.git
synced 2025-01-22 03:29:43 +00:00
ui: wan federation message dc-dropdown (#13753)
* Only display dc dropdown when more than one dc is available * Add wan federation message to dc dropdown * Add test for conditionally displaying dc dropdown * Move single datacenter indicator into datacenter selector * Add `DATACENTERS` seperator dc dropdown * "fix" unnecessary margin-top in dc dropdown
This commit is contained in:
parent
cd513aeead
commit
cdf40a6ae6
@ -2,49 +2,60 @@
|
|||||||
class="dcs"
|
class="dcs"
|
||||||
data-test-datacenter-menu
|
data-test-datacenter-menu
|
||||||
>
|
>
|
||||||
<DisclosureMenu
|
{{#if (gt @dcs.length 1)}}
|
||||||
aria-label="Datacenter"
|
<DisclosureMenu
|
||||||
@items={{sort-by 'Primary:desc' 'Local:desc' 'Name:asc' @dcs}}
|
aria-label="Datacenter"
|
||||||
as |disclosure|>
|
@items={{sort-by 'Primary:desc' 'Local:desc' 'Name:asc' @dcs}}
|
||||||
<disclosure.Action
|
data-test-datacenter-disclosure-menu
|
||||||
{{on 'click' disclosure.toggle}}
|
as |disclosure|>
|
||||||
>
|
<disclosure.Action
|
||||||
{{@dc.Name}}
|
{{on 'click' disclosure.toggle}}
|
||||||
</disclosure.Action>
|
>
|
||||||
<disclosure.Menu as |panel|>
|
{{@dc.Name}}
|
||||||
<DataSource
|
</disclosure.Action>
|
||||||
@src={{uri '/*/*/*/datacenters'}}
|
<disclosure.Menu as |panel|>
|
||||||
@onchange={{action (mut @dcs) value="data"}}
|
<DataSource
|
||||||
/>
|
@src={{uri '/*/*/*/datacenters'}}
|
||||||
<panel.Menu as |menu|>
|
@onchange={{action (mut @dcs) value="data"}}
|
||||||
{{#each menu.items as |item|}}
|
/>
|
||||||
<menu.Item
|
<p class="dcs-message">
|
||||||
aria-current={{if (eq @dc.Name item.Name) 'true'}}
|
Datacenters shown in this dropdown are available through WAN Federation.
|
||||||
class={{class-map
|
</p>
|
||||||
(array 'is-local' item.Local)
|
<panel.Menu as |menu|>
|
||||||
(array 'is-primary' item.Primary)
|
<menu.Separator>
|
||||||
}}
|
DATACENTERS
|
||||||
>
|
</menu.Separator>
|
||||||
<menu.Action
|
{{#each menu.items as |item|}}
|
||||||
{{on 'click' disclosure.close}}
|
<menu.Item
|
||||||
@href={{href-to '.' params=(hash
|
aria-current={{if (eq @dc.Name item.Name) 'true'}}
|
||||||
dc=item.Name
|
class={{class-map
|
||||||
partition=undefined
|
(array 'is-local' item.Local)
|
||||||
nspace=(if (gt @nspace.length 0) @nspace undefined)
|
(array 'is-primary' item.Primary)
|
||||||
)}}
|
}}
|
||||||
>
|
>
|
||||||
{{item.Name}}
|
<menu.Action
|
||||||
{{#if item.Primary}}
|
{{on 'click' disclosure.close}}
|
||||||
<span>Primary</span>
|
@href={{href-to '.' params=(hash
|
||||||
{{/if}}
|
dc=item.Name
|
||||||
{{#if item.Local}}
|
partition=undefined
|
||||||
<span>Local</span>
|
nspace=(if (gt @nspace.length 0) @nspace undefined)
|
||||||
{{/if}}
|
)}}
|
||||||
</menu.Action>
|
>
|
||||||
</menu.Item>
|
{{item.Name}}
|
||||||
{{/each}}
|
{{#if item.Primary}}
|
||||||
</panel.Menu>
|
<span>Primary</span>
|
||||||
</disclosure.Menu>
|
{{/if}}
|
||||||
</DisclosureMenu>
|
{{#if item.Local}}
|
||||||
|
<span>Local</span>
|
||||||
|
{{/if}}
|
||||||
|
</menu.Action>
|
||||||
|
</menu.Item>
|
||||||
|
{{/each}}
|
||||||
|
</panel.Menu>
|
||||||
|
</disclosure.Menu>
|
||||||
|
</DisclosureMenu>
|
||||||
|
{{else}}
|
||||||
|
<li class="dc-name" data-test-datacenter-single>{{@dcs.firstObject.Name}}</li>
|
||||||
|
{{/if}}
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
@ -87,12 +87,12 @@
|
|||||||
|
|
||||||
<:main-nav>
|
<:main-nav>
|
||||||
<ul>
|
<ul>
|
||||||
<Consul::Datacenter::Selector
|
<Consul::Datacenter::Selector
|
||||||
@dc={{@dc}}
|
@dc={{@dc}}
|
||||||
@partition={{@partition}}
|
@partition={{@partition}}
|
||||||
@nspace={{@nspace}}
|
@nspace={{@nspace}}
|
||||||
@dcs={{@dcs}}
|
@dcs={{@dcs}}
|
||||||
/>
|
/>
|
||||||
<Consul::Partition::Selector
|
<Consul::Partition::Selector
|
||||||
@dc={{@dc}}
|
@dc={{@dc}}
|
||||||
@partition={{@partition}}
|
@partition={{@partition}}
|
||||||
|
@ -2,6 +2,12 @@
|
|||||||
nav .dcs {
|
nav .dcs {
|
||||||
@extend %main-nav-vertical-hoisted;
|
@extend %main-nav-vertical-hoisted;
|
||||||
left: 100px;
|
left: 100px;
|
||||||
|
|
||||||
|
.dcs-message {
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-bottom: 1px solid rgb(var(--tone-gray-400));
|
||||||
|
max-width: fit-content;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
nav .dcs li.is-primary span,
|
nav .dcs li.is-primary span,
|
||||||
nav .dcs li.is-local span {
|
nav .dcs li.is-local span {
|
||||||
@ -44,6 +50,11 @@
|
|||||||
top: 2px;
|
top: 2px;
|
||||||
margin-left: 2px;
|
margin-left: 2px;
|
||||||
}
|
}
|
||||||
|
.dc-name {
|
||||||
|
color: rgb(var(--tone-gray-600));
|
||||||
|
padding: 3.25px 0px;
|
||||||
|
font-weight: var(--typo-weight-semibold)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.hashicorp-consul {
|
.hashicorp-consul {
|
||||||
@extend %hashicorp-consul;
|
@extend %hashicorp-consul;
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
display: block;
|
display: block;
|
||||||
padding: 7px 25px;
|
padding: 7px 25px;
|
||||||
}
|
}
|
||||||
%main-nav-vertical [role='separator'] {
|
%main-nav-vertical > ul > [role='separator'] {
|
||||||
margin-top: 0.7rem;
|
margin-top: 0.7rem;
|
||||||
padding-bottom: 0;
|
padding-bottom: 0;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,49 @@
|
|||||||
|
import { module, test } from 'qunit';
|
||||||
|
import { setupRenderingTest } from 'ember-qunit';
|
||||||
|
import hbs from 'htmlbars-inline-precompile';
|
||||||
|
import { render } from '@ember/test-helpers';
|
||||||
|
|
||||||
|
module('Integration | Component | consul datacenter selector', function(hooks) {
|
||||||
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
|
test('it does not display a dropdown when only one dc is available', async function(assert) {
|
||||||
|
const dcs = [
|
||||||
|
{
|
||||||
|
Name: 'dc-1',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
this.set('dcs', dcs);
|
||||||
|
this.set('dc', dcs[0]);
|
||||||
|
|
||||||
|
await render(hbs`<Consul::Datacenter::Selector @dcs={{this.dcs}} @dc={{this.dc}} />`);
|
||||||
|
|
||||||
|
assert
|
||||||
|
.dom('[data-test-datacenter-disclosure-menu]')
|
||||||
|
.doesNotExist('datacenter dropdown is not displayed in nav');
|
||||||
|
|
||||||
|
assert
|
||||||
|
.dom('[data-test-datacenter-single]')
|
||||||
|
.hasText('dc-1', 'Datecenter name is displayed in nav');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('it does displays a dropdown when more than one dc is available', async function(assert) {
|
||||||
|
const dcs = [
|
||||||
|
{
|
||||||
|
Name: 'dc-1',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Name: 'dc-2',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
this.set('dcs', dcs);
|
||||||
|
this.set('dc', dcs[0]);
|
||||||
|
|
||||||
|
await render(hbs`<Consul::Datacenter::Selector @dcs={{this.dcs}} @dc={{this.dc}} />`);
|
||||||
|
|
||||||
|
assert
|
||||||
|
.dom('[data-test-datacenter-single]')
|
||||||
|
.doesNotExist('we are displaying more than just the name of the first dc');
|
||||||
|
|
||||||
|
assert.dom('[data-test-datacenter-disclosure-menu]').exists('datacenter dropdown is displayed');
|
||||||
|
});
|
||||||
|
});
|
@ -1,6 +1,7 @@
|
|||||||
import { module, skip } from 'qunit';
|
import { module, skip, test } from 'qunit';
|
||||||
import { setupRenderingTest } from 'ember-qunit';
|
import { setupRenderingTest } from 'ember-qunit';
|
||||||
import hbs from 'htmlbars-inline-precompile';
|
import hbs from 'htmlbars-inline-precompile';
|
||||||
|
import { render } from '@ember/test-helpers';
|
||||||
|
|
||||||
module('Integration | Component | hashicorp consul', function(hooks) {
|
module('Integration | Component | hashicorp consul', function(hooks) {
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user