diff --git a/ui/packages/consul-ui/app/models/dc.js b/ui/packages/consul-ui/app/models/dc.js index 1d8f321d05..5707de0cf8 100644 --- a/ui/packages/consul-ui/app/models/dc.js +++ b/ui/packages/consul-ui/app/models/dc.js @@ -8,6 +8,7 @@ export default class Datacenter extends Model { @attr('string') uid; @attr('string') Name; @attr('boolean') Local; + @attr('string') DefaultACLPolicy; @attr('boolean', { defaultValue: () => true }) MeshEnabled; } diff --git a/ui/packages/consul-ui/app/serializers/dc.js b/ui/packages/consul-ui/app/serializers/dc.js index 23780b5ad2..e942d50d01 100644 --- a/ui/packages/consul-ui/app/serializers/dc.js +++ b/ui/packages/consul-ui/app/serializers/dc.js @@ -8,17 +8,21 @@ export default class DcSerializer extends Serializer { respondForQuery(respond, query) { return respond(function(headers, body) { - return body; + return { + body, + headers, + }; }); } normalizePayload(payload, id, requestType) { switch (requestType) { case 'query': - return payload.map(item => { + return payload.body.map(item => { return { Local: this.env.var('CONSUL_DATACENTER_LOCAL') === item, [this.primaryKey]: item, + DefaultACLPolicy: payload.headers['x-consul-default-acl-policy'], }; }); } diff --git a/ui/packages/consul-ui/mock-api/v1/catalog/.config b/ui/packages/consul-ui/mock-api/v1/catalog/.config new file mode 100644 index 0000000000..10929c4ce0 --- /dev/null +++ b/ui/packages/consul-ui/mock-api/v1/catalog/.config @@ -0,0 +1,7 @@ +--- +"*": + GET: + "*": + headers: + response: + X-Consul-Default-Acl-Policy: ${fake.helpers.randomize(['allow', 'deny'])} diff --git a/ui/packages/consul-ui/tests/integration/serializers/dc-test.js b/ui/packages/consul-ui/tests/integration/serializers/dc-test.js index 891c9d8c23..aa4e6bea5a 100644 --- a/ui/packages/consul-ui/tests/integration/serializers/dc-test.js +++ b/ui/packages/consul-ui/tests/integration/serializers/dc-test.js @@ -9,7 +9,10 @@ module('Integration | Serializer | dc', function(hooks) { url: `/v1/catalog/datacenters`, }; return get(request.url).then(function(payload) { - const expected = payload; + const expected = { + body: payload, + headers: {}, + }; const actual = serializer.respondForQuery(function(cb) { const headers = {}; const body = payload;