From 74ccbc57066325a58d3dba39e756d21f6a25d320 Mon Sep 17 00:00:00 2001 From: Michael Klein Date: Thu, 14 Jul 2022 20:32:53 +0200 Subject: [PATCH] ui: remove with-peers query param (#13756) * Don't request nodes/services `with-peers` anymore This will be automatic - no need for the query-param anymore. * Return peering data based on feature flag mock-api services/nodes * Update tests to reflect removed with-peers query-param * setup cookie for turning peer feature flag on in mock-api in testing * Add missing `S` for renamed PEERING feature-flag cookie --- ui/packages/consul-ui/app/adapters/node.js | 14 -------------- ui/packages/consul-ui/app/adapters/service.js | 14 -------------- .../consul-ui/mock-api/v1/internal/ui/nodes | 2 +- .../consul-ui/mock-api/v1/internal/ui/services | 2 +- .../acceptance/dc/intentions/navigation.feature | 2 +- .../tests/acceptance/dc/nodes/index.feature | 2 +- .../tests/acceptance/dc/services/list.feature | 2 +- .../tests/acceptance/page-navigation.feature | 2 +- .../tests/acceptance/token-header.feature | 4 ++-- ui/packages/consul-ui/tests/helpers/set-cookies.js | 3 +++ .../tests/integration/adapters/node-test.js | 2 +- .../tests/integration/adapters/service-test.js | 2 +- 12 files changed, 13 insertions(+), 38 deletions(-) diff --git a/ui/packages/consul-ui/app/adapters/node.js b/ui/packages/consul-ui/app/adapters/node.js index 6e30108c7a..de3f3c2956 100644 --- a/ui/packages/consul-ui/app/adapters/node.js +++ b/ui/packages/consul-ui/app/adapters/node.js @@ -1,5 +1,4 @@ import Adapter from './application'; -import { inject as service } from '@ember/service'; // TODO: Update to use this.formatDatacenter() @@ -11,25 +10,12 @@ import { inject as service } from '@ember/service'; // to the node. export default class NodeAdapter extends Adapter { - @service abilities; - - get peeringQuery() { - const query = {}; - - if (this.abilities.can('use peers')) { - query['with-peers'] = true; - } - - return query; - } - requestForQuery(request, { dc, ns, partition, index, id, uri }) { return request` GET /v1/internal/ui/nodes?${{ dc }} X-Request-ID: ${uri} ${{ - ...this.peeringQuery, ns, partition, index, diff --git a/ui/packages/consul-ui/app/adapters/service.js b/ui/packages/consul-ui/app/adapters/service.js index 7507c41b6b..ea69f0927e 100644 --- a/ui/packages/consul-ui/app/adapters/service.js +++ b/ui/packages/consul-ui/app/adapters/service.js @@ -1,19 +1,6 @@ import Adapter from './application'; -import { inject as service } from '@ember/service'; export default class ServiceAdapter extends Adapter { - @service abilities; - - get peeringQuery() { - const query = {}; - - if (this.abilities.can('use peers')) { - query['with-peers'] = true; - } - - return query; - } - requestForQuery(request, { dc, ns, partition, index, gateway, uri }) { if (typeof gateway !== 'undefined') { return request` @@ -33,7 +20,6 @@ export default class ServiceAdapter extends Adapter { X-Request-ID: ${uri} ${{ - ...this.peeringQuery, ns, partition, index, diff --git a/ui/packages/consul-ui/mock-api/v1/internal/ui/nodes b/ui/packages/consul-ui/mock-api/v1/internal/ui/nodes index 30557b6435..8b63b7997d 100644 --- a/ui/packages/consul-ui/mock-api/v1/internal/ui/nodes +++ b/ui/packages/consul-ui/mock-api/v1/internal/ui/nodes @@ -17,7 +17,7 @@ { "ID":"${fake.random.uuid()}", "Node":"node-${i}", - ${location.search["with-peers"] ? peerNameString : ''} + ${env('CONSUL_PEERINGS_ENABLE') ? peerNameString : ''} "Address":"${fake.internet.ip()}", "TaggedAddresses":{ "lan":"${fake.internet.ip()}", diff --git a/ui/packages/consul-ui/mock-api/v1/internal/ui/services b/ui/packages/consul-ui/mock-api/v1/internal/ui/services index a9d0c98cc1..1a4a732503 100644 --- a/ui/packages/consul-ui/mock-api/v1/internal/ui/services +++ b/ui/packages/consul-ui/mock-api/v1/internal/ui/services @@ -53,7 +53,7 @@ ${typeof location.search.ns !== 'undefined' ? ` ${typeof location.search.partition !== 'undefined' ? ` "Partition": "${fake.helpers.randomize([env('CONSUL_PARTITION_EXPORTER', location.search.partition), location.search.partition])}", ` : ``} - ${location.search['with-peers'] ? peerNameString : ''} + ${env('CONSUL_PEERINGS_ENABLE') ? peerNameString : ''} "Tags": [ ${ range( diff --git a/ui/packages/consul-ui/tests/acceptance/dc/intentions/navigation.feature b/ui/packages/consul-ui/tests/acceptance/dc/intentions/navigation.feature index 8c749634de..4b1bd2318e 100644 --- a/ui/packages/consul-ui/tests/acceptance/dc/intentions/navigation.feature +++ b/ui/packages/consul-ui/tests/acceptance/dc/intentions/navigation.feature @@ -27,7 +27,7 @@ Feature: dc / intentions / navigation ID: 755b72bd-f5ab-4c92-90cc-bed0e7d8e9f0 --- When I click intention on the intentionList.intentions component - Then a GET request was made to "/v1/internal/ui/services?dc=dc-1&with-peers=true&ns=*" + Then a GET request was made to "/v1/internal/ui/services?dc=dc-1&ns=*" And I click "[data-test-back]" Then the url should be /dc-1/intentions Scenario: Clicking the create button and back again diff --git a/ui/packages/consul-ui/tests/acceptance/dc/nodes/index.feature b/ui/packages/consul-ui/tests/acceptance/dc/nodes/index.feature index a56758958c..735c222e9e 100644 --- a/ui/packages/consul-ui/tests/acceptance/dc/nodes/index.feature +++ b/ui/packages/consul-ui/tests/acceptance/dc/nodes/index.feature @@ -45,7 +45,7 @@ Feature: dc / nodes / index --- Then the url should be /dc-1/nodes And the title should be "Nodes - Consul" - And a GET request was made to "/v1/internal/ui/nodes?dc=dc-1&with-peers=true&ns=@namespace" + And a GET request was made to "/v1/internal/ui/nodes?dc=dc-1&ns=@namespace" Then I see 3 node models Scenario: Seeing the leader in node listing Given 3 node models from yaml diff --git a/ui/packages/consul-ui/tests/acceptance/dc/services/list.feature b/ui/packages/consul-ui/tests/acceptance/dc/services/list.feature index fe1682d251..60f6ed4b81 100644 --- a/ui/packages/consul-ui/tests/acceptance/dc/services/list.feature +++ b/ui/packages/consul-ui/tests/acceptance/dc/services/list.feature @@ -16,7 +16,7 @@ Feature: dc / services / list dc: dc-1 --- Then the url should be /dc-1/services - And a GET request was made to "/v1/internal/ui/services?dc=dc-1&with-peers=true&ns=@namespace" + And a GET request was made to "/v1/internal/ui/services?dc=dc-1&ns=@namespace" Then I see 3 service models diff --git a/ui/packages/consul-ui/tests/acceptance/page-navigation.feature b/ui/packages/consul-ui/tests/acceptance/page-navigation.feature index 62d259c76a..3c064b1de8 100644 --- a/ui/packages/consul-ui/tests/acceptance/page-navigation.feature +++ b/ui/packages/consul-ui/tests/acceptance/page-navigation.feature @@ -22,7 +22,7 @@ Feature: page-navigation Where: --------------------------------------------------------------------------------------------------- | Link | URL | Endpoint | - | nodes | /dc1/nodes | /v1/internal/ui/nodes?dc=dc1&with-peers=true&ns=@namespace | + | nodes | /dc1/nodes | /v1/internal/ui/nodes?dc=dc1&ns=@namespace | # FIXME # | kvs | /dc1/kv | /v1/kv/?keys&dc=dc1&separator=%2F&ns=@namespace | | tokens | /dc1/acls/tokens | /v1/acl/tokens?dc=dc1&ns=@namespace | diff --git a/ui/packages/consul-ui/tests/acceptance/token-header.feature b/ui/packages/consul-ui/tests/acceptance/token-header.feature index 9486114419..4fd73cd62c 100644 --- a/ui/packages/consul-ui/tests/acceptance/token-header.feature +++ b/ui/packages/consul-ui/tests/acceptance/token-header.feature @@ -11,7 +11,7 @@ Feature: token-header dc: dc1 --- Then the url should be /dc1/services - And a GET request was made to "/v1/internal/ui/services?dc=dc1&with-peers=true&ns=@namespace" from yaml + And a GET request was made to "/v1/internal/ui/services?dc=dc1&ns=@namespace" from yaml --- headers: X-Consul-Token: '' @@ -35,7 +35,7 @@ Feature: token-header dc: dc1 --- Then the url should be /dc1/services - And a GET request was made to "/v1/internal/ui/services?dc=dc1&with-peers=true&ns=@namespace" from yaml + And a GET request was made to "/v1/internal/ui/services?dc=dc1&ns=@namespace" from yaml --- headers: X-Consul-Token: [Token] diff --git a/ui/packages/consul-ui/tests/helpers/set-cookies.js b/ui/packages/consul-ui/tests/helpers/set-cookies.js index 053bd90907..1a02c4a10d 100644 --- a/ui/packages/consul-ui/tests/helpers/set-cookies.js +++ b/ui/packages/consul-ui/tests/helpers/set-cookies.js @@ -5,6 +5,9 @@ export default function(type, value, doc = document) { if (!doc.cookie.includes('CONSUL_ACLS_ENABLE=0')) { obj['CONSUL_ACLS_ENABLE'] = 1; } + if (!doc.cookie.includes('CONSUL_PEERINGS_ENABLE=0')) { + obj['CONSUL_PEERINGS_ENABLE'] = 1; + } switch (type) { case 'dc': key = 'CONSUL_DATACENTER_COUNT'; diff --git a/ui/packages/consul-ui/tests/integration/adapters/node-test.js b/ui/packages/consul-ui/tests/integration/adapters/node-test.js index 5904fb3f5c..32f1e8eacf 100644 --- a/ui/packages/consul-ui/tests/integration/adapters/node-test.js +++ b/ui/packages/consul-ui/tests/integration/adapters/node-test.js @@ -14,7 +14,7 @@ module('Integration | Adapter | node', function(hooks) { const adapter = this.owner.lookup('adapter:node'); const client = this.owner.lookup('service:client/http'); const request = client.requestParams.bind(client); - const expected = `GET /v1/internal/ui/nodes?dc=${dc}&with-peers=true${ + const expected = `GET /v1/internal/ui/nodes?dc=${dc}${ shouldHaveNspace(nspace) ? `&ns=${nspace}` : `` }`; const actual = adapter.requestForQuery(request, { diff --git a/ui/packages/consul-ui/tests/integration/adapters/service-test.js b/ui/packages/consul-ui/tests/integration/adapters/service-test.js index 853ecbff88..adf46258da 100644 --- a/ui/packages/consul-ui/tests/integration/adapters/service-test.js +++ b/ui/packages/consul-ui/tests/integration/adapters/service-test.js @@ -14,7 +14,7 @@ module('Integration | Adapter | service', function(hooks) { const adapter = this.owner.lookup('adapter:service'); const client = this.owner.lookup('service:client/http'); const request = client.requestParams.bind(client); - const expected = `GET /v1/internal/ui/services?dc=${dc}&with-peers=true${ + const expected = `GET /v1/internal/ui/services?dc=${dc}${ shouldHaveNspace(nspace) ? `&ns=${nspace}` : `` }`; let actual = adapter.requestForQuery(request, {