mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 01:15:22 +00:00
8bb2a39d86
* Improves re-usability of the SelectTargetsDropdown
18 lines
475 B
JavaScript
18 lines
475 B
JavaScript
import { flatMap } from 'lodash';
|
|
|
|
const filterTarget = (targetType) => {
|
|
return (target) => {
|
|
return target.target_type === targetType ? [target.id] : [];
|
|
};
|
|
};
|
|
|
|
export const formatSelectedTargetsForApi = (selectedTargets) => {
|
|
const targets = selectedTargets || [];
|
|
const hosts = flatMap(targets, filterTarget('hosts'));
|
|
const labels = flatMap(targets, filterTarget('labels'));
|
|
|
|
return { hosts, labels };
|
|
};
|
|
|
|
export default { formatSelectedTargetsForApi };
|