open-consul/ui-v2/app/utils/update-array-object.js
John Cowen 52a62f2b8d UI: New ACLs (#4789)
UI to accompany the new ACLs APIs
2018-10-19 08:45:05 -07:00

13 lines
398 B
JavaScript

import { get, set } from '@ember/object';
export default function(arr, item, prop, value) {
value = typeof value === 'undefined' ? get(item, prop) : value;
const current = arr.findBy(prop, value);
if (current) {
// TODO: This is reliant on changeset?
Object.keys(get(item, 'data')).forEach(function(prop) {
set(current, prop, get(item, prop));
});
return current;
}
}