import React, { Component, Fragment } from 'react'; import { Margin, Padding } from 'styled-components-spacing'; import { graphql, compose } from 'react-apollo'; import ReduxForm from 'declarative-redux-form'; import { connect } from 'react-redux'; import { SubmissionError, destroy } from 'redux-form'; import { set, destroyAll } from 'react-redux-values'; import Flex, { FlexItem } from 'styled-flex-component'; import intercept from 'apr-intercept'; import get from 'lodash.get'; import styled from 'styled-components'; import { Name, Image, Package, Networks, Tags, Metadata, UserScript, Firewall, CNS, Affinity, generatePayload, Footer } from 'joyent-ui-instance-steps'; import { Provider as ResourceSteps } from 'joyent-ui-resource-step'; import { Anchor, H3, ViewContainer, Button } from 'joyent-ui-toolkit'; import { Forms, Values } from '@root/constants'; import parseError from '@state/parse-error'; import CreateInstanceMutation from '@graphql/create-instance.gql'; const { IC_F } = Forms; const { IC_SHOW_CLI } = Values; const names = { name: 'IC_NAME', image: 'IC_IMAGE', package: 'IC_PACKAGE', networks: 'IC_NETWORKS', tags: 'IC_TAGS', metadata: 'IC_METADATA', 'user-script': 'IC_USERSCRIPT', firewall: 'IC_FIREWALL', cns: 'IC_CNS', affinity: 'IC_AFFINITY' }; class CreateInstance extends Component { constructor(...args) { super(...args); this.isValids = {}; } setIsValid = name => ref => { if (!ref) { return; } const { isValid } = ref; if (!isValid) { return; } this.isValids = Object.assign({}, this.isValids, { [name]: isValid }); }; isFormValid = () => { const { steps } = this.props; return Object.keys(this.isValids).every(name => this.isValids[name](steps[name] || {}) ); }; isStepValid = step => { const { steps } = this.props; const fn = this.isValids[step]; const values = steps[step]; if (!fn || !values) { return true; } return fn(values); }; render() { const { match, steps, showCli = false, handleDefocus, handleToggleShowCli, handleSubmit, disabled } = this.props; const { params } = match; const { step } = params; const { name, image, package: pkg, networks, tags, metadata, firewall, cns, affinity } = steps; const Mask = styled.div` top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.25); position: absolute; display: ${showCli ? 'block' : 'none'}; `; return (

Create Instance

{({ handleSubmit, submitting }) => (
)}
handleToggleShowCli(!showCli)} > View CLI Details
{showCli ? (