ui: Fixup displaying a Nspace default policy when expanding the preview pane (#12316)

pull/11138/head
John Cowen 3 years ago committed by GitHub
parent 717621698d
commit 360cf89ea5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,3 @@
```release-note:bug
ui: Ensure we always display the Policy default preview in the Namespace editing form
```

@ -2,22 +2,12 @@ import Serializer from './application';
import { get } from '@ember/object'; import { get } from '@ember/object';
import { PRIMARY_KEY, SLUG_KEY } from 'consul-ui/models/nspace'; import { PRIMARY_KEY, SLUG_KEY } from 'consul-ui/models/nspace';
export default class NspaceSerializer extends Serializer { const normalizeACLs = item => {
primaryKey = PRIMARY_KEY;
slugKey = SLUG_KEY;
respondForQuery(respond, query, data, modelClass) {
return super.respondForQuery(
cb =>
respond((headers, body) =>
cb(
headers,
body.map(function(item) {
item.Namespace = '*';
item.Datacenter = query.dc;
if (get(item, 'ACLs.PolicyDefaults')) { if (get(item, 'ACLs.PolicyDefaults')) {
item.ACLs.PolicyDefaults = item.ACLs.PolicyDefaults.map(function(item) { item.ACLs.PolicyDefaults = item.ACLs.PolicyDefaults.map(function(item) {
if (typeof item.template === 'undefined') {
item.template = ''; item.template = '';
}
return item; return item;
}); });
} }
@ -33,6 +23,22 @@ export default class NspaceSerializer extends Serializer {
} }
}); });
return item; return item;
};
export default class NspaceSerializer extends Serializer {
primaryKey = PRIMARY_KEY;
slugKey = SLUG_KEY;
respondForQuery(respond, query, data, modelClass) {
return super.respondForQuery(
cb =>
respond((headers, body) =>
cb(
headers,
body.map(function(item) {
item.Namespace = '*';
item.Datacenter = query.dc;
return normalizeACLs(item);
}) })
) )
), ),
@ -46,7 +52,7 @@ export default class NspaceSerializer extends Serializer {
respond((headers, body) => { respond((headers, body) => {
body.Datacenter = serialized.dc; body.Datacenter = serialized.dc;
body.Namespace = '*'; body.Namespace = '*';
return cb(headers, body); return cb(headers, normalizeACLs(body));
}), }),
serialized, serialized,
data data
@ -59,7 +65,7 @@ export default class NspaceSerializer extends Serializer {
respond((headers, body) => { respond((headers, body) => {
body.Datacenter = serialized.dc; body.Datacenter = serialized.dc;
body.Namespace = '*'; body.Namespace = '*';
return cb(headers, body); return cb(headers, normalizeACLs(body));
}), }),
serialized, serialized,
data data
@ -68,7 +74,7 @@ export default class NspaceSerializer extends Serializer {
respondForUpdateRecord(respond, serialized, data) { respondForUpdateRecord(respond, serialized, data) {
return respond((headers, body) => { return respond((headers, body) => {
return body; return normalizeACLs(body);
}); });
} }
} }

Loading…
Cancel
Save