From 4a760429890c63d74f89500981187b5ea4597264 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Thu, 24 Sep 2020 16:07:13 +0100 Subject: [PATCH] ui: Correct readonly L7 Intentions API calls (#8725) * Disable ability to select destination if not creating * Add a LegacyID for intentions that don't have them * Use `/exact/` endpoint for reading single intentions * Fix up test for new API interaction * Upgrade consul-api-double * Comment out tests using destination for the moment Also, removed any intention related things from the old page-navigation tests --- ui-v2/app/adapters/intention.js | 13 ++- .../consul-intention-form/fieldsets/index.hbs | 10 ++- .../consul-intention-form/index.hbs | 1 + ui-v2/app/models/intention.js | 1 + ui-v2/app/serializers/intention.js | 20 ++++- .../dc/intentions/filtered-select.feature | 4 +- .../dc/intentions/form-select.feature | 2 +- .../tests/acceptance/page-navigation.feature | 16 ---- .../integration/adapters/intention-test.js | 11 ++- .../integration/serializers/intention-test.js | 14 +++- .../services/repository/intention-test.js | 79 ------------------- ui-v2/yarn.lock | 6 +- 12 files changed, 61 insertions(+), 116 deletions(-) delete mode 100644 ui-v2/tests/integration/services/repository/intention-test.js diff --git a/ui-v2/app/adapters/intention.js b/ui-v2/app/adapters/intention.js index 5cef02a3f..9f76f58be 100644 --- a/ui-v2/app/adapters/intention.js +++ b/ui-v2/app/adapters/intention.js @@ -1,6 +1,5 @@ import Adapter, { DATACENTER_QUERY_PARAM as API_DATACENTER_KEY } from './application'; import { FOREIGN_KEY as DATACENTER_KEY } from 'consul-ui/models/dc'; -import { SLUG_KEY } from 'consul-ui/models/intention'; // Intentions use SourceNS and DestinationNS properties for namespacing // so we don't need to add the `?ns=` anywhere here @@ -26,8 +25,13 @@ export default Adapter.extend({ if (typeof id === 'undefined') { throw new Error('You must specify an id'); } + const [SourceNS, SourceName, DestinationNS, DestinationName] = id + .split(':') + .map(decodeURIComponent); return request` - GET /v1/connect/intentions/${id}?${{ dc }} + GET /v1/connect/intentions/exact?source=${SourceNS + + '/' + + SourceName}&destination=${DestinationNS + '/' + DestinationName}&${{ dc }} Cache-Control: no-store ${{ index }} @@ -51,7 +55,7 @@ export default Adapter.extend({ }, requestForUpdateRecord: function(request, serialized, data) { return request` - PUT /v1/connect/intentions/${data[SLUG_KEY]}?${{ [API_DATACENTER_KEY]: data[DATACENTER_KEY] }} + PUT /v1/connect/intentions/${data.LegacyID}?${{ [API_DATACENTER_KEY]: data[DATACENTER_KEY] }} ${{ SourceNS: serialized.SourceNS, @@ -60,13 +64,14 @@ export default Adapter.extend({ DestinationName: serialized.DestinationName, SourceType: serialized.SourceType, Action: serialized.Action, + Meta: serialized.Meta, Description: serialized.Description, }} `; }, requestForDeleteRecord: function(request, serialized, data) { return request` - DELETE /v1/connect/intentions/${data[SLUG_KEY]}?${{ + DELETE /v1/connect/intentions/${data.LegacyID}?${{ [API_DATACENTER_KEY]: data[DATACENTER_KEY], }} `; diff --git a/ui-v2/app/components/consul-intention-form/fieldsets/index.hbs b/ui-v2/app/components/consul-intention-form/fieldsets/index.hbs index f3b21e9b6..867b33d13 100644 --- a/ui-v2/app/components/consul-intention-form/fieldsets/index.hbs +++ b/ui-v2/app/components/consul-intention-form/fieldsets/index.hbs @@ -43,7 +43,9 @@ {{nspace.Name}} {{/if}} - Search for an existing namespace, or enter any Namespace name. + {{#if create}} + Search for an existing namespace, or enter any Namespace name. + {{/if}} {{/if}} @@ -52,6 +54,7 @@ {{#if (env 'CONSUL_NSPACES_ENABLED')}}