import React from 'react'; import distanceInWordsToNow from 'date-fns/distance_in_words_to_now'; import { Row, Col } from 'joyent-react-styled-flexboxgrid'; import Flex, { FlexItem } from 'styled-flex-component'; import styled from 'styled-components'; import { Margin, Padding } from 'styled-components-spacing'; import titleCase from 'title-case'; import get from 'lodash.get'; import remcalc from 'remcalc'; import { Field } from 'redux-form'; import { ValueBreakpoints as breakpoints } from 'joyent-ui-toolkit'; import { Card, CardOutlet, Divider, Button, ButtonGroup, PopoverButton, PopoverItem as BasePopoverItem, H2 as BaseH2, Label as BaseLabel, CopiableField, QueryBreakpoints, DotIcon, DeleteIcon, StartIcon, StopIcon, EditIcon, Input, FormMeta, FormGroup } from 'joyent-ui-toolkit'; import GLOBAL from '@state/global'; const { SmallOnly, Medium } = QueryBreakpoints; const stateColor = { PROVISIONING: 'primary', RUNNING: 'green', STOPPING: 'grey', STOPPED: 'grey', DELETED: 'secondaryActive', FAILED: 'red' }; const Label = styled(BaseLabel)` font-weight: 200; `; const GreyLabel = styled(Label)` opacity: 0.5; padding-right: ${remcalc(3)}; `; const TrimedLabel = styled(Label)` overflow: hidden; white-space: nowrap; text-overflow: ellipsis; `; const Actionable = styled(Margin)` cursor: pointer; `; const VerticalDivider = styled.div` width: ${remcalc(1)}; background: ${props => props.theme.grey}; height: ${remcalc(24)}; display: flex; align-self: flex-end; margin: 0 ${remcalc(12)}; @media (max-width: ${remcalc(breakpoints.small.upper)}) { display: none; } `; const H2 = styled(BaseH2)` margin: 0; `; const PopoverItem = styled(BasePopoverItem)` padding-bottom: ${remcalc(11)}; `; export const Meta = ({ created, updated, state, brand, image, editingName, handleSubmit, editName, disabled, submitting, ...instance }) => [

{editingName ? (
) : ( {instance.name} )}

, {image && image.name ? titleCase(image.name) : 'Custom Image'} {brand === 'LX' ? 'Infrastructure container' : 'Hardware virtual machine'} {(instance.package || {}).name} {titleCase(state)} Created: Updated: ]; export default ({ instance = {}, starting = false, stopping = false, rebooting = false, removing = false, onAction, ...props }) => ( {instance.state === 'STOPPED' ? ( ) : ( )} instance.state === 'RUNNING' ? null : onAction('start') } > Start instance.state === 'STOPPED' ? null : onAction('reboot') } > Restart instance.state === 'STOPPED' ? null : onAction('stop') } > Stop {instance.image && instance.image.id && ( )} {get(instance, 'ips.public', []).map((ip, i, ips) => ( 1 ? i + 1 : ''}`} text={ip} /> ))} {get(instance, 'ips.private', []).map((ip, i, ips) => ( 1 ? i + 1 : ''}`} text={ip} /> ))} );