mirror of https://github.com/status-im/consul.git
ui: Fixup displaying a Nspace default policy when expanding the preview pane (#12316)
This commit is contained in:
parent
717621698d
commit
360cf89ea5
|
@ -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 { PRIMARY_KEY, SLUG_KEY } from 'consul-ui/models/nspace';
|
||||
|
||||
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;
|
||||
const normalizeACLs = item => {
|
||||
if (get(item, 'ACLs.PolicyDefaults')) {
|
||||
item.ACLs.PolicyDefaults = item.ACLs.PolicyDefaults.map(function(item) {
|
||||
if (typeof item.template === 'undefined') {
|
||||
item.template = '';
|
||||
}
|
||||
return item;
|
||||
});
|
||||
}
|
||||
|
@ -33,6 +23,22 @@ export default class NspaceSerializer extends Serializer {
|
|||
}
|
||||
});
|
||||
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) => {
|
||||
body.Datacenter = serialized.dc;
|
||||
body.Namespace = '*';
|
||||
return cb(headers, body);
|
||||
return cb(headers, normalizeACLs(body));
|
||||
}),
|
||||
serialized,
|
||||
data
|
||||
|
@ -59,7 +65,7 @@ export default class NspaceSerializer extends Serializer {
|
|||
respond((headers, body) => {
|
||||
body.Datacenter = serialized.dc;
|
||||
body.Namespace = '*';
|
||||
return cb(headers, body);
|
||||
return cb(headers, normalizeACLs(body));
|
||||
}),
|
||||
serialized,
|
||||
data
|
||||
|
@ -68,7 +74,7 @@ export default class NspaceSerializer extends Serializer {
|
|||
|
||||
respondForUpdateRecord(respond, serialized, data) {
|
||||
return respond((headers, body) => {
|
||||
return body;
|
||||
return normalizeACLs(body);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue