-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: Create Linked Services Tab for Terminating Gateways (#7858)
* Fix to bottom border not applying to the correct <li> * Create Linked Services tab with styling and tests * Add internal endpoint gateway-services-nodes to the codebase with tests * Upgrade consul-api-double to version 2.15.0
- Loading branch information
Showing
23 changed files
with
399 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Adapter from './application'; | ||
|
||
export default Adapter.extend({ | ||
requestForQueryRecord: function(request, { dc, ns, index, id }) { | ||
if (typeof id === 'undefined') { | ||
throw new Error('You must specify an id'); | ||
} | ||
return request` | ||
GET /v1/internal/ui/gateway-services-nodes/${id}?${{ dc }} | ||
${{ | ||
...this.formatNspace(ns), | ||
index, | ||
}} | ||
`; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Model from 'ember-data/model'; | ||
import attr from 'ember-data/attr'; | ||
|
||
export const PRIMARY_KEY = 'uid'; | ||
export const SLUG_KEY = 'Name'; | ||
export default Model.extend({ | ||
[PRIMARY_KEY]: attr('string'), | ||
[SLUG_KEY]: attr('string'), | ||
Datacenter: attr('string'), | ||
Namespace: attr('string'), | ||
Services: attr(), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Route from '@ember/routing/route'; | ||
|
||
export default Route.extend({ | ||
model: function() { | ||
const parent = this.routeName | ||
.split('.') | ||
.slice(0, -1) | ||
.join('.'); | ||
return this.modelFor(parent); | ||
}, | ||
setupController: function(controller, model) { | ||
controller.setProperties(model); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import Serializer from './application'; | ||
import { PRIMARY_KEY, SLUG_KEY } from 'consul-ui/models/gateway'; | ||
|
||
export default Serializer.extend({ | ||
primaryKey: PRIMARY_KEY, | ||
slugKey: SLUG_KEY, | ||
respondForQueryRecord: function(respond, query) { | ||
return this._super(function(cb) { | ||
return respond(function(headers, body) { | ||
return cb(headers, { | ||
Name: query.id, | ||
Services: body, | ||
}); | ||
}); | ||
}, query); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import RepositoryService from 'consul-ui/services/repository'; | ||
|
||
const modelName = 'gateway'; | ||
export default RepositoryService.extend({ | ||
getModelName: function() { | ||
return modelName; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<div id="services" class="tab-section"> | ||
<div role="tabpanel"> | ||
{{#if (gt gateway.Services.length 0)}} | ||
<section> | ||
<p> | ||
The following services may receive traffic from external services through this gateway. Learn more about configuring gateways in our | ||
<a href={{env 'CONSUL_TERMINATING_GATEWAYS_URL'}} target="_blank">step-by-step guide.</a> | ||
|
||
</p> | ||
<ListCollection @cellHeight={{73}} @items={{gateway.Services}} class="gateway-services-list" as |item index|> | ||
<a data-test-service-name href={{href-to 'dc.services.show' item.Name}} class={{service/health-checks item}}> | ||
{{item.Name}} | ||
</a> | ||
<ul> | ||
{{#if (not-eq item.InstanceCount 0)}} | ||
<li> | ||
{{format-number item.InstanceCount}} {{pluralize item.InstanceCount 'Instance' without-count=true}} | ||
</li> | ||
{{/if}} | ||
<TagList @item={{item}} as |Tags|> | ||
<li> | ||
<Tags /> | ||
</li> | ||
</TagList> | ||
</ul> | ||
</ListCollection> | ||
</section> | ||
{{else}} | ||
<p> | ||
There are no linked services. | ||
</p> | ||
{{/if}} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
ui-v2/tests/acceptance/dc/services/show/gateway-services.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
@setupApplicationTest | ||
Feature: dc / services / gateway | ||
Background: | ||
Given 1 datacenter model with the value "dc1" | ||
And 1 node models | ||
And 1 service model from yaml | ||
--- | ||
- Service: | ||
Name: terminating-gateway-1 | ||
Kind: terminating-gateway | ||
--- | ||
Scenario: Seeing the Linked Services tab | ||
When I visit the service page for yaml | ||
--- | ||
dc: dc1 | ||
service: terminating-gateway-1 | ||
--- | ||
And the title should be "terminating-gateway-1 - Consul" | ||
And I see linkedServices on the tabs | ||
When I click linkedServices on the tabs | ||
And I see linkedServicesIsSelected on the tabs | ||
Scenario: Seeing the list of Linked Services | ||
Given 3 service models from yaml | ||
When I visit the service page for yaml | ||
--- | ||
dc: dc1 | ||
service: terminating-gateway-1 | ||
--- | ||
And the title should be "terminating-gateway-1 - Consul" | ||
When I click linkedServices on the tabs | ||
Then I see 3 service models | ||
|
||
|
||
|
10 changes: 10 additions & 0 deletions
10
ui-v2/tests/acceptance/steps/dc/services/show/gateway-services-steps.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
|
||
module('Integration | Adapter | gateway', function(hooks) { | ||
setupTest(hooks); | ||
const dc = 'dc-1'; | ||
const id = 'slug'; | ||
test('requestForQueryRecord returns the correct url/method', function(assert) { | ||
const adapter = this.owner.lookup('adapter:gateway'); | ||
const client = this.owner.lookup('service:client/http'); | ||
const expected = `GET /v1/internal/ui/gateway-services-nodes/${id}?dc=${dc}`; | ||
const actual = adapter.requestForQueryRecord(client.url, { | ||
dc: dc, | ||
id: id, | ||
}); | ||
assert.equal(actual, expected); | ||
}); | ||
test("requestForQueryRecord throws if you don't specify an id", function(assert) { | ||
const adapter = this.owner.lookup('adapter:gateway'); | ||
const client = this.owner.lookup('service:client/http'); | ||
assert.throws(function() { | ||
adapter.requestForQueryRecord(client.url, { | ||
dc: dc, | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { module, test } from 'qunit'; | ||
import { setupTest } from 'ember-qunit'; | ||
|
||
import { get } from 'consul-ui/tests/helpers/api'; | ||
import { | ||
HEADERS_SYMBOL as META, | ||
HEADERS_DATACENTER as DC, | ||
HEADERS_NAMESPACE as NSPACE, | ||
} from 'consul-ui/utils/http/consul'; | ||
|
||
module('Integration | Serializer | gateway', function(hooks) { | ||
setupTest(hooks); | ||
test('respondForQueryRecord returns the correct data for item endpoint', function(assert) { | ||
const serializer = this.owner.lookup('serializer:gateway'); | ||
const dc = 'dc-1'; | ||
const id = 'slug'; | ||
const nspace = 'default'; | ||
const request = { | ||
url: `/v1/internal/ui/gateway-services-nodes/${id}?dc=${dc}`, | ||
}; | ||
return get(request.url).then(function(payload) { | ||
const expected = { | ||
Datacenter: dc, | ||
[META]: { | ||
[DC.toLowerCase()]: dc, | ||
[NSPACE.toLowerCase()]: nspace, | ||
}, | ||
uid: `["${nspace}","${dc}","${id}"]`, | ||
Name: id, | ||
Namespace: nspace, | ||
Services: payload, | ||
}; | ||
const actual = serializer.respondForQueryRecord( | ||
function(cb) { | ||
const headers = {}; | ||
const body = payload; | ||
return cb(headers, body); | ||
}, | ||
{ | ||
dc: dc, | ||
id: id, | ||
} | ||
); | ||
assert.deepEqual(actual, expected); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.