From 8077a41f429d080592c44830bc3f444815100a06 Mon Sep 17 00:00:00 2001 From: Kenia <19161242+kaxcode@users.noreply.github.com> Date: Thu, 21 May 2020 13:46:15 -0400 Subject: [PATCH] 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 --- ui-v2/app/components/list-collection/index.hbs | 13 +++++++++++-- ui-v2/app/helpers/service/exists.js | 11 +++++++++++ ui-v2/app/styles/components/composite-row.scss | 2 +- .../templates/dc/services/show/upstreams.hbs | 6 ++++++ .../integration/helpers/service/exists-test.js | 17 +++++++++++++++++ 5 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 ui-v2/app/helpers/service/exists.js create mode 100644 ui-v2/tests/integration/helpers/service/exists-test.js diff --git a/ui-v2/app/components/list-collection/index.hbs b/ui-v2/app/components/list-collection/index.hbs index 9e077dd6ee..80349e0808 100644 --- a/ui-v2/app/components/list-collection/index.hbs +++ b/ui-v2/app/components/list-collection/index.hbs @@ -1,6 +1,15 @@ - +
  • {{~#each _cells as |cell|~}} -
  • {{yield cell.item cell.index }}
  • +
  • + {{yield cell.item cell.index }} +
  • {{~/each~}}
    \ No newline at end of file diff --git a/ui-v2/app/helpers/service/exists.js b/ui-v2/app/helpers/service/exists.js new file mode 100644 index 0000000000..e611b59cea --- /dev/null +++ b/ui-v2/app/helpers/service/exists.js @@ -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); diff --git a/ui-v2/app/styles/components/composite-row.scss b/ui-v2/app/styles/components/composite-row.scss index 814b082610..c4299dc60b 100644 --- a/ui-v2/app/styles/components/composite-row.scss +++ b/ui-v2/app/styles/components/composite-row.scss @@ -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) { diff --git a/ui-v2/app/templates/dc/services/show/upstreams.hbs b/ui-v2/app/templates/dc/services/show/upstreams.hbs index 5665ac4847..372b868685 100644 --- a/ui-v2/app/templates/dc/services/show/upstreams.hbs +++ b/ui-v2/app/templates/dc/services/show/upstreams.hbs @@ -7,9 +7,15 @@

    {{#let item.Service.Namespace as |nspace|}} + {{#if (service/exists item)}} {{item.Name}} + {{else}} +

    + {{item.Name}} +

    + {{/if}}