import React, { Fragment } from 'react';
import { Field } from 'redux-form';
import titleCase from 'title-case';
import distanceInWordsToNow from 'date-fns/distance_in_words_to_now';
import remcalc from 'remcalc';
import {
FormGroup,
StatusLoader,
Table,
TableThead,
TableTr,
TableTh,
TableTbody,
TableTd,
Checkbox,
KeyValue,
Popover,
PopoverContainer,
PopoverTarget,
PopoverItem,
ActionsIcon,
DotIcon
} from 'joyent-ui-toolkit';
import Empty from '@components/empty';
const stateColor = {
QUEUED: 'primary',
CREATED: 'green'
};
const loadingState = {
start: 'Starting...',
remove: 'Removing...'
};
export const Item = ({ name, state, created, onStart, onRemove, mutating }) => (
{!mutating ? (
{name}
{' '}
{titleCase(state)}
{distanceInWordsToNow(created)}
Start
Remove
) : (
)}
);
export const AddForm = props => (
);
export default ({
snapshots = [],
selected = [],
error,
handleChange = () => null,
onAction = () => null,
submitting = false,
sortBy = 'name',
sortOrder = 'desc',
onSortBy = () => null,
allSelected = false,
toggleSelectAll = () => null,
onStart,
onRemove,
...rest
}) => (
onSortBy('name', sortOrder)}
sortOrder={sortOrder}
showSort={sortBy === 'name'}
left
middle
actionable
>
Name
onSortBy('state', sortOrder)}
sortOrder={sortOrder}
showSort={sortBy === 'state'}
left
middle
actionable
>
Status
onSortBy('created', sortOrder)}
sortOrder={sortOrder}
showSort={sortBy === 'created'}
left
middle
actionable
>
Created
{snapshots.length
? snapshots.map(snapshot => (
- onStart(snapshot)}
onRemove={() => onRemove(snapshot)}
key={snapshot.id}
{...snapshot}
/>
))
: null}
{!snapshots.length ? You have no Snapshots : null}
);