open-vault/ui/app/serializers/namespace.js
Jordan Reimer 52fe56ec87
Eslint prefer-const (#17864)
* adds prefer-const to eslint config and runs fixer

* reverts unintended change
2022-11-09 15:15:31 -08:00

25 lines
794 B
JavaScript

import ApplicationSerializer from './application';
export default ApplicationSerializer.extend({
normalizeList(payload) {
const data = payload.data.keys
? payload.data.keys.map((key) => ({
path: key,
// remove the trailing slash from the id
id: key.replace(/\/$/, ''),
}))
: payload.data;
return data;
},
normalizeResponse(store, primaryModelClass, payload, id, requestType) {
const nullResponses = ['deleteRecord', 'createRecord'];
const cid = (id || payload.id || '').replace(/\/$/, '');
const normalizedPayload = nullResponses.includes(requestType)
? { id: cid, path: cid }
: this.normalizeList(payload);
return this._super(store, primaryModelClass, normalizedPayload, id, requestType);
},
});