* refactor: 💡 convert brokered cred IDs array to simple attribute * fix: 🐛 missing test assertion * fix: 🐛 simplify computed * refactor: 💡 convert host sources array to simple attribute (#1260) * refactor: 💡 convert host source IDs array to simple attribute * fix: 🐛 host source tests * Refactor role fragment arrays (#1262) * refactor: 💡 convert grant strings to regular attribute * refactor: 💡 convert principals array to simple attribute * Update ui/admin/app/routes/scopes/scope/roles/role.js Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com> * fix: 🐛 remove unused import Co-authored-by: Zhihe Li <zhihe.li@hashicorp.com>
22 lines
519 B
JavaScript
22 lines
519 B
JavaScript
import Transform from '@ember-data/serializer/transform';
|
|
|
|
export default class PrincipalArrayTransform extends Transform {
|
|
deserialize(serialized) {
|
|
const stringValues = serialized || [];
|
|
return stringValues.map(({ id: principal_id, scope_id, type }) => ({
|
|
principal_id,
|
|
scope_id,
|
|
type,
|
|
}));
|
|
}
|
|
|
|
serialize(deserialized) {
|
|
const strings = deserialized || [];
|
|
return strings.map(({ principal_id: id, scope_id, type }) => ({
|
|
id,
|
|
scope_id,
|
|
type,
|
|
}));
|
|
}
|
|
}
|