import React from 'react'; import distanceInWordsToNow from 'date-fns/distance_in_words_to_now'; import remcalc from 'remcalc'; import styled from 'styled-components'; import titleCase from 'title-case'; import { Link } from 'react-router-dom'; import { Field } from 'redux-form'; import Flex from 'styled-flex-component'; import { Anchor, FormGroup, Checkbox, Table, TableThead, TableTr, TableTh, TableTd, TableTbody, StatusLoader, Popover, PopoverContainer, PopoverTarget, PopoverItem, PopoverDivider, DotIcon, ActionsIcon } from 'joyent-ui-toolkit'; import GLOBAL from '@state/global'; const stateColor = { PROVISIONING: 'primary', RUNNING: 'green', STOPPING: 'grey', STOPPED: 'grey', DELETED: 'secondaryActive', FAILED: 'red' }; const A = styled(Anchor)` color: ${props => props.theme.text}; text-decoration: none; font-weight: ${props => props.theme.font.weight.semibold}; `; const ItemAnchor = styled(Anchor)` color: ${props => props.theme.text}; -webkit-text-fill-color: currentcolor; text-decoration: none; `; const Actions = styled(Flex)` width: ${remcalc(48)}; height: ${remcalc(48)}; min-width: ${remcalc(48)}; `; export const Item = ({ id = '', name, state = 'RUNNING', created, allowedActions = {}, mutating = false, onCreateImage, onStart, onStop, onReboot, onRemove, onClick }) => ( {name} {mutating ? ( ) : ( {' '} {titleCase(state)} )} {distanceInWordsToNow(created)} {id.substring(0, 7)} {!mutating ? ( Start Stop Reboot Create Image Remove ) : ( )} ); export default ({ sortBy = 'name', sortOrder = 'desc', submitting = false, allSelected = false, toggleSelectAll = () => null, onSortBy = () => null, children, noInstances }) => (
onSortBy('name')} sortOrder={sortOrder} showSort={sortBy === 'name'} left middle actionable > Name onSortBy('state')} sortOrder={sortOrder} showSort={sortBy === 'state'} left middle actionable > Status onSortBy('created')} sortOrder={sortOrder} showSort={sortBy === 'created'} left middle actionable > Created onSortBy('id')} sortOrder={sortOrder} showSort={sortBy === 'id'} left middle actionable > Short ID {children}
);