import React from 'react';
import { Row, Col } from 'react-styled-flexboxgrid';
import forceArray from 'force-array';
import get from 'lodash.get';
import {
FormGroup,
Input,
FormLabel,
ViewContainer,
StatusLoader,
Select
} from 'joyent-ui-toolkit';
import Item from './item';
export default ({
instances = [],
selected = [],
loading,
handleChange = () => null,
onAction = () => null,
handleSubmit,
...rest
}) => {
const allowedActions = {
stop: selected.some(({ state }) => state === 'RUNNING'),
start: selected.some(({ state }) => state !== 'RUNNING'),
reboot: true,
resize:
selected.length === 1 && selected.every(({ brand }) => brand === 'KVM'),
enableFw: selected.some(({ firewall_enabled }) => !firewall_enabled),
disableFw: selected.some(({ firewall_enabled }) => firewall_enabled),
createSnap: true,
startSnap:
selected.length === 1 &&
selected.every(({ snapshots = [] }) => snapshots.length)
};
const handleActions = ({ target }) =>
onAction({
name: target.value,
items: selected
});
const _instances = forceArray(instances);
const items = _instances.map((instance, i, all) => (