From 20d80ed8eb6fa2b6c15be8000b3b2d60a988974b Mon Sep 17 00:00:00 2001 From: Michael Klein Date: Mon, 10 Oct 2022 09:50:00 +0200 Subject: [PATCH] Implement imported services tab peers.edit --- .../app/templates/dc/peers/edit/imported.hbs | 132 +++++++++++++++++- .../vendor/consul-peerings/routes.js | 14 ++ ui/packages/consul-ui/app/adapters/service.js | 5 +- .../app/components/providers/search/index.js | 8 +- .../app/services/repository/service.js | 5 + 5 files changed, 160 insertions(+), 4 deletions(-) diff --git a/ui/packages/consul-peerings/app/templates/dc/peers/edit/imported.hbs b/ui/packages/consul-peerings/app/templates/dc/peers/edit/imported.hbs index a84ac2db3a..ebed120b43 100644 --- a/ui/packages/consul-peerings/app/templates/dc/peers/edit/imported.hbs +++ b/ui/packages/consul-peerings/app/templates/dc/peers/edit/imported.hbs @@ -1,3 +1,133 @@ -
This is imported services
+ + + + + + + + {{#let + (hash + value=(or sortBy "Status:asc") + change=(action (mut sortBy) value="target.selected") + ) + (hash + status=(hash + value=(if status (split status ",") undefined) + change=(action (mut status) value="target.selectedItems") + ) + kind=(hash + value=(if kind (split kind ",") undefined) + change=(action (mut kind) value="target.selectedItems") + ) + source=(hash + value=(if source (split source ",") undefined) + change=(action (mut source) value="target.selectedItems") + ) + searchproperty=(hash + value=(if + (not-eq searchproperty undefined) + (split searchproperty ",") + this.searchProperties + ) + change=(action (mut searchproperty) value="target.selectedItems") + default=this.searchProperties + ) + ) + (reject-by "Kind" "connect-proxy" api.data) + (or route.params.partition route.model.user.token.Partition "default") + (or route.params.nspace route.model.user.token.Namespace "default") + as |sort filters items partition nspace| + }} + + {{#if (gt items.length 0)}} + {{#let (collection items) as |items|}} + + {{/let}} + {{/if}} + + + + + + + +

+ No visible imported services from + {{route.model.peer.Name}} +

+
+ + {{#if items.length}} +
+ No services where found matching that search, or you may not + have access to view the services you are searching for. +
+ {{else}} +
Services must be exported from one peer to another to + enable service communication across two peers. There don't + seem to be any services imported from + {{route.model.peer.Name}} + yet, or you may not have + service:read + permissions to access to this view.
+ {{/if}} +
+ + + + +
+
+
+ {{/let}} +
+
\ No newline at end of file diff --git a/ui/packages/consul-peerings/vendor/consul-peerings/routes.js b/ui/packages/consul-peerings/vendor/consul-peerings/routes.js index 2cfc21e4e0..4357c60be5 100644 --- a/ui/packages/consul-peerings/vendor/consul-peerings/routes.js +++ b/ui/packages/consul-peerings/vendor/consul-peerings/routes.js @@ -29,6 +29,20 @@ imported: { _options: { path: "/imported-services", + queryParams: { + sortBy: "sort", + status: "status", + source: "source", + kind: "kind", + searchproperty: { + as: "searchproperty", + empty: [["Name", "Tags"]], + }, + search: { + as: "filter", + replace: true, + }, + }, }, }, exported: { diff --git a/ui/packages/consul-ui/app/adapters/service.js b/ui/packages/consul-ui/app/adapters/service.js index bc15702ada..c867dff064 100644 --- a/ui/packages/consul-ui/app/adapters/service.js +++ b/ui/packages/consul-ui/app/adapters/service.js @@ -1,7 +1,7 @@ import Adapter from './application'; export default class ServiceAdapter extends Adapter { - requestForQuery(request, { dc, ns, partition, index, gateway, uri }) { + requestForQuery(request, { dc, ns, partition, index, gateway, uri, peer }) { if (typeof gateway !== 'undefined') { return request` GET /v1/internal/ui/gateway-services-nodes/${gateway}?${{ dc }} @@ -16,13 +16,14 @@ export default class ServiceAdapter extends Adapter { `; } else { return request` - GET /v1/internal/ui/services?${{ dc }} + GET /v1/internal/ui/services?${{ dc, peer }} X-Request-ID: ${uri} ${{ ns, partition, index, + peer, }} `; } diff --git a/ui/packages/consul-ui/app/components/providers/search/index.js b/ui/packages/consul-ui/app/components/providers/search/index.js index 677a7365e5..281fd6f4fc 100644 --- a/ui/packages/consul-ui/app/components/providers/search/index.js +++ b/ui/packages/consul-ui/app/components/providers/search/index.js @@ -1,8 +1,14 @@ import Component from '@glimmer/component'; export default class SearchProvider extends Component { + // custom base route / router abstraction is doing weird things + get _search() { + return this.args.search || ''; + } + get items() { - const { items, search, searchProperties } = this.args; + const { items, searchProperties } = this.args; + const { _search: search } = this; if (search.length > 0) { const regex = new RegExp(`${search}`, 'ig'); diff --git a/ui/packages/consul-ui/app/services/repository/service.js b/ui/packages/consul-ui/app/services/repository/service.js index 5ce9439b46..269e4a20b8 100644 --- a/ui/packages/consul-ui/app/services/repository/service.js +++ b/ui/packages/consul-ui/app/services/repository/service.js @@ -12,6 +12,11 @@ export default class ServiceService extends RepositoryService { return super.findAll(...arguments); } + @dataSource('/:partition/:ns/:dc/services/:peer') + async findAllImportedServices() { + return super.findAll(...arguments); + } + @dataSource('/:partition/:ns/:dc/gateways/for-service/:gateway') findGatewayBySlug(params, configuration = {}) { if (typeof configuration.cursor !== 'undefined') {