ui: Make only existing services in Upstreams linkabled with hover effect (#7943)
* Create service/exist helper to be used in ListCollection list items * Make only existing services in Upstreams linkabled with hover effect
This commit is contained in:
parent
7eacae10f0
commit
3f1deac804
|
@ -1,6 +1,15 @@
|
|||
<EmberNativeScrollable @tagName="ul" @content-size={{_contentSize}} @scroll-left={{_scrollLeft}} @scroll-top={{_scrollTop}} @scrollChange={{action "scrollChange"}} @clientSizeChange={{action "clientSizeChange"}}>
|
||||
<EmberNativeScrollable
|
||||
@tagName="ul"
|
||||
@content-size={{_contentSize}}
|
||||
@scroll-left={{_scrollLeft}}
|
||||
@scroll-top={{_scrollTop}}
|
||||
@scrollChange={{action "scrollChange"}}
|
||||
@clientSizeChange={{action "clientSizeChange"}}
|
||||
>
|
||||
<li></li>
|
||||
{{~#each _cells as |cell|~}}
|
||||
<li onclick={{action 'click'}} style={{{cell.style}}}>{{yield cell.item cell.index }}</li>
|
||||
<li onclick={{action 'click'}} style={{{cell.style}}} class={{if (service/exists cell.item) 'linkable' }}>
|
||||
{{yield cell.item cell.index }}
|
||||
</li>
|
||||
{{~/each~}}
|
||||
</EmberNativeScrollable>
|
|
@ -0,0 +1,11 @@
|
|||
import { helper } from '@ember/component/helper';
|
||||
|
||||
export function serviceExists([item], hash) {
|
||||
if (typeof item.InstanceCount === 'undefined') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return item.InstanceCount > 0;
|
||||
}
|
||||
|
||||
export default helper(serviceExists);
|
|
@ -6,7 +6,7 @@
|
|||
@extend %composite-row;
|
||||
}
|
||||
/* hoverable rows */
|
||||
.consul-upstream-list > ul > li:not(:first-child),
|
||||
%composite-row.linkable,
|
||||
.consul-gateway-service-list > ul > li:not(:first-child),
|
||||
.consul-service-instance-list > ul > li:not(:first-child),
|
||||
.consul-service-list > ul > li:not(:first-child) {
|
||||
|
|
|
@ -7,9 +7,15 @@
|
|||
</p>
|
||||
{{#let item.Service.Namespace as |nspace|}}
|
||||
<ListCollection @items={{gateway.Services}} class="consul-upstream-list" as |item index|>
|
||||
{{#if (service/exists item)}}
|
||||
<a data-test-service-name href={{href-to 'dc.services.show' item.Name}}>
|
||||
{{item.Name}}
|
||||
</a>
|
||||
{{else}}
|
||||
<p data-test-service-name>
|
||||
{{item.Name}}
|
||||
</p>
|
||||
{{/if}}
|
||||
<ul>
|
||||
{{#if (env 'CONSUL_NSPACES_ENABLED')}}
|
||||
{{#if (not-eq item.Namespace nspace)}}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
import { module, test } from 'qunit';
|
||||
import { setupRenderingTest } from 'ember-qunit';
|
||||
import { render } from '@ember/test-helpers';
|
||||
import { hbs } from 'ember-cli-htmlbars';
|
||||
|
||||
module('Integration | Helper | service/exists', function(hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
// Replace this with your real tests.
|
||||
test('it renders', async function(assert) {
|
||||
this.set('inputValue', { InstanceCount: 3 });
|
||||
|
||||
await render(hbs`{{service/exists inputValue}}`);
|
||||
|
||||
assert.equal(this.element.textContent.trim(), 'true');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue