ui: Hides the Routing tab for a service proxy (#7195)

* Adds conditional in route to not make discovery-chain request if service kind is equal to `connect-proxy` or `mesh-gateway`

* Adds conditional in template to not show Routing tab if `chain` returns as null

* Creates a new acceptance test to test the Routing tab not being displayed for a service proxy

* Adds `tabs` to the services/show page object
This commit is contained in:
Kenia 2020-02-03 10:09:15 -05:00 committed by GitHub
parent b9e023dfe1
commit c706089c9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 65 additions and 8 deletions

View File

@ -1,6 +1,7 @@
import Route from '@ember/routing/route'; import Route from '@ember/routing/route';
import { inject as service } from '@ember/service'; import { inject as service } from '@ember/service';
import { hash } from 'rsvp'; import { hash } from 'rsvp';
import { get } from '@ember/object';
export default Route.extend({ export default Route.extend({
repo: service('repository/service'), repo: service('repository/service'),
@ -17,9 +18,15 @@ export default Route.extend({
const nspace = this.modelFor('nspace').nspace.substr(1); const nspace = this.modelFor('nspace').nspace.substr(1);
return hash({ return hash({
item: this.repo.findBySlug(params.name, dc, nspace), item: this.repo.findBySlug(params.name, dc, nspace),
chain: this.chainRepo.findBySlug(params.name, dc, nspace),
urls: this.settings.findBySlug('urls'), urls: this.settings.findBySlug('urls'),
dc: dc, dc: dc,
}).then(model => {
return hash({
chain: ['connect-proxy', 'mesh-gateway'].includes(get(model, 'item.Service.Kind'))
? null
: this.chainRepo.findBySlug(params.name, dc, nspace),
...model,
});
}); });
}, },
setupController: function(controller, model) { setupController: function(controller, model) {

View File

@ -29,7 +29,7 @@
items=(compact items=(compact
(array (array
'Instances' 'Instances'
'Routing' (if chain 'Routing' '')
'Tags' 'Tags'
) )
) )
@ -45,9 +45,9 @@
{{#each {{#each
(compact (compact
(array (array
(hash id=(slugify 'Instances') partial='dc/services/instances') (hash id=(slugify 'Instances') partial='dc/services/instances')
(hash id=(slugify 'Routing') partial='dc/services/routing') (if chain (hash id=(slugify 'Routing') partial='dc/services/routing') '')
(hash id=(slugify 'Tags') partial='dc/services/tags') (hash id=(slugify 'Tags') partial='dc/services/tags')
) )
) as |panel| ) as |panel|
}} }}

View File

@ -0,0 +1,37 @@
@setupApplicationTest
Feature: dc / services / Show Routing for Serivce
Scenario: Given a service, the Routing tab should display
Given 1 datacenter model with the value "dc1"
And 1 node models
And 1 service model from yaml
---
- Service:
Kind: consul
Name: service-0
ID: service-0-with-id
---
When I visit the service page for yaml
---
dc: dc1
service: service-0
---
And the title should be "service-0 - Consul"
And I see routing on the tabs
Scenario: Given a service proxy, the Routing tab should not display
Given 1 datacenter model with the value "dc1"
And 1 node models
And 1 service model from yaml
---
- Service:
Kind: connect-proxy
Name: service-0-proxy
ID: service-0-proxy-with-id
---
When I visit the service page for yaml
---
dc: dc1
service: service-0-proxy
---
And the title should be "service-0-proxy - Consul"
And I don't see routing on the tabs

View File

@ -0,0 +1,10 @@
import steps from '../../steps';
// step definitions that are shared between features should be moved to the
// tests/acceptance/steps/steps.js file
export default function(assert) {
return steps(assert).then('I should find a file', function() {
assert.ok(true, this.step);
});
}

View File

@ -67,8 +67,10 @@ const roleSelector = roleSelectorFactory(clickable, deletable, collection, alias
export default { export default {
index: create(index(visitable, collection)), index: create(index(visitable, collection)),
dcs: create(dcs(visitable, clickable, attribute, collection)), dcs: create(dcs(visitable, clickable, attribute, collection)),
services: create(services(visitable, clickable, attribute, collection, page, catalogFilter)), services: create(
service: create(service(visitable, attribute, collection, text, catalogFilter)), services(visitable, clickable, attribute, collection, page, catalogFilter, radiogroup)
),
service: create(service(visitable, attribute, collection, text, catalogFilter, radiogroup)),
instance: create(instance(visitable, attribute, collection, text, radiogroup)), instance: create(instance(visitable, attribute, collection, text, radiogroup)),
nodes: create(nodes(visitable, clickable, attribute, collection, catalogFilter)), nodes: create(nodes(visitable, clickable, attribute, collection, catalogFilter)),
node: create(node(visitable, deletable, clickable, attribute, collection, radiogroup)), node: create(node(visitable, deletable, clickable, attribute, collection, radiogroup)),

View File

@ -1,4 +1,4 @@
export default function(visitable, attribute, collection, text, filter) { export default function(visitable, attribute, collection, text, filter, radiogroup) {
return { return {
visit: visitable('/:dc/services/:service'), visit: visitable('/:dc/services/:service'),
externalSource: attribute('data-test-external-source', 'h1 span'), externalSource: attribute('data-test-external-source', 'h1 span'),
@ -8,6 +8,7 @@ export default function(visitable, attribute, collection, text, filter) {
dashboardAnchor: { dashboardAnchor: {
href: attribute('href', '[data-test-dashboard-anchor]'), href: attribute('href', '[data-test-dashboard-anchor]'),
}, },
tabs: radiogroup('tab', ['instances', 'routing', 'tags']),
filter: filter, filter: filter,
}; };
} }