From c6c1b9f13aa29bb4412fd97129aafaa4929190df Mon Sep 17 00:00:00 2001 From: John Cowen Date: Fri, 10 Dec 2021 14:41:08 +0000 Subject: [PATCH] ui: Change partitions to expect `[]` from the API (#11791) --- .changelog/11791.txt | 3 ++ .../consul-ui/app/serializers/partition.js | 2 +- ui/packages/consul-ui/mock-api/v1/partitions | 50 +++++++++---------- .../integration/serializers/partition-test.js | 2 +- 4 files changed, 29 insertions(+), 28 deletions(-) create mode 100644 .changelog/11791.txt diff --git a/.changelog/11791.txt b/.changelog/11791.txt new file mode 100644 index 000000000..cbd6076cb --- /dev/null +++ b/.changelog/11791.txt @@ -0,0 +1,3 @@ +```release-note:bugfix +ui: Change partitions to expect [] from the listing API +``` diff --git a/ui/packages/consul-ui/app/serializers/partition.js b/ui/packages/consul-ui/app/serializers/partition.js index 8be29799b..067d98a1b 100644 --- a/ui/packages/consul-ui/app/serializers/partition.js +++ b/ui/packages/consul-ui/app/serializers/partition.js @@ -11,7 +11,7 @@ export default class PartitionSerializer extends Serializer { respond((headers, body) => { return cb( headers, - body.Partitions.map(item => { + body.map(item => { item.Partition = '*'; item.Namespace = '*'; return item; diff --git a/ui/packages/consul-ui/mock-api/v1/partitions b/ui/packages/consul-ui/mock-api/v1/partitions index 712149962..ae01a7b3c 100644 --- a/ui/packages/consul-ui/mock-api/v1/partitions +++ b/ui/packages/consul-ui/mock-api/v1/partitions @@ -1,30 +1,28 @@ -{ - "Partitions": [ - { - "Name": "default", - "Description": "Builtin Default Partition" - } +[ + { + "Name": "default", + "Description": "Builtin Default Partition" + } ${range( - env( - 'CONSUL_PARTITION_COUNT', - Math.floor( - ( - Math.random() * env('CONSUL_PARTITION_MAX', 10) - ) + parseInt(env('CONSUL_PARTITION_MIN', 1)) - ) - ) - 1 + env( + 'CONSUL_PARTITION_COUNT', + Math.floor( + ( + Math.random() * env('CONSUL_PARTITION_MAX', 10) + ) + parseInt(env('CONSUL_PARTITION_MIN', 1)) + ) + ) - 1 ).map(i => ` ${i === 0 ? ` - , + , ` : ``} - { - "Name": "${fake.hacker.noun()}-partition-${i}", - ${fake.random.boolean() ? ` - "Description": "${fake.lorem.sentence()}", - ` : ``} - "CreateIndex": 12, - "ModifyIndex": 16 - } - `)} - ] -} + { + "Name": "${fake.hacker.noun()}-partition-${i}", +${fake.random.boolean() ? ` + "Description": "${fake.lorem.sentence()}", +` : ``} + "CreateIndex": 12, + "ModifyIndex": 16 + } +`)} +] diff --git a/ui/packages/consul-ui/tests/integration/serializers/partition-test.js b/ui/packages/consul-ui/tests/integration/serializers/partition-test.js index c2b14f6e1..272e36f81 100644 --- a/ui/packages/consul-ui/tests/integration/serializers/partition-test.js +++ b/ui/packages/consul-ui/tests/integration/serializers/partition-test.js @@ -13,7 +13,7 @@ module('Integration | Serializer | partition', function(hooks) { url: `/v1/partitions?dc=${dc}`, }; return get(request.url).then(function(payload) { - const expected = payload.Partitions.map(item => + const expected = payload.map(item => Object.assign({}, item, { Datacenter: dc, Namespace: '*',