a959d2d908
* create generate key form * disable key bits unless key type selected * add create method to adapter, update serializer to remove type * refactor key parameters component * convert to typescript * refactor routes to add controller breadcrumbs * remove unnecessary attr * revert typescript changes * add validations to key type * fix tests * cleanup breadcrumbs * update tests, change all bit types to strings * add form test
21 lines
619 B
JavaScript
21 lines
619 B
JavaScript
import ApplicationSerializer from '../application';
|
|
|
|
export default class PkiKeySerializer extends ApplicationSerializer {
|
|
primaryKey = 'key_id';
|
|
attrs = {
|
|
type: { serialize: false },
|
|
};
|
|
|
|
// rehydrate each keys model so all model attributes are accessible from the LIST response
|
|
normalizeItems(payload) {
|
|
if (payload.data) {
|
|
if (payload.data?.keys && Array.isArray(payload.data.keys)) {
|
|
return payload.data.keys.map((key) => ({ key_id: key, ...payload.data.key_info[key] }));
|
|
}
|
|
Object.assign(payload, payload.data);
|
|
delete payload.data;
|
|
}
|
|
return payload;
|
|
}
|
|
}
|