import React from 'react'; import { Row, Col } from 'react-styled-flexboxgrid'; import forceArray from 'force-array'; import find from 'lodash.find'; import moment from 'moment'; import { FormGroup, Input, FormLabel, ViewContainer, StatusLoader, Select, Message, MessageTitle, MessageDescription, Button, QueryBreakpoints, Table, TableThead, TableTr, TableTh, TableTbody, TableTd, Checkbox, P } from 'joyent-ui-toolkit'; const { SmallOnly, Medium } = QueryBreakpoints; const Item = ({ name, state, created }) => ( {name} {moment.unix(created).fromNow()} ); export default ({ snapshots = [], selected = [], loading, error, handleChange = () => null, onAction = () => null, handleSubmit, submitting = false, pristine = true, ...rest }) => { const allowedActions = { delete: selected.length > 0, start: selected.length === 1 }; const handleActions = ev => { ev.stopPropagation(); ev.preventDefault(); onAction({ name: ev.target.value, items: selected }); }; const _snapshots = forceArray(snapshots); const _loading = !_snapshots.length && loading && ( ); const items = _snapshots.map(snapshot => { const { name } = snapshot; const isSelected = Boolean(find(selected, ['name', name])); const isSubmitting = isSelected && submitting; return { ...snapshot, isSubmitting, isSelected }; }); const _error = error && !submitting && ( Ooops! {error} ); const _table = !items.length ? null : (

Name

Created

{items.map(snapshot => )}
); return (
handleSubmit(ctx => handleChange(ctx))} onSubmit={handleSubmit} > Filter snapshots Sort {_loading} {_error} {_table}
); };