import React from 'react'
import Form from 'react-formal'
import {
Alert,
Button,
Col, ControlLabel,
Form as BsForm, FormControl, FormGroup as BsFormGroup,
HelpBlock,
} from 'react-bootstrap'
import {APPS, APPS_BY_RELEASE} from './metadata'
import schema, { serialize } from './schema';
import SelectApps from './SelectApps'
const EMR_RELEASES = Object.keys(APPS_BY_RELEASE)
function trimApplications(label, applications) {
// If the release label has been cleared, don't do anything else
if (label === '') {
return applications
}
let nextAppIds = Object.keys(APPS_BY_RELEASE[label])
return applications.filter(appId => nextAppIds.indexOf(appId) !== -1)
}
function ReleaseSelect({ value, onChange, children }) {
return (
{EMR_RELEASES.map(version =>
)}
);
}
// not necessary but takes advantage of the twbs error styling
function FormGroup({ for: forFields, ...props }) {
if (!forFields) return
return (
{({ messages, ...triggerProps }) =>
}
);
}
let FormExample = React.createClass({
getInitialState() {
return {
value: schema.default(),
errors: {}
}
},
handleChange(value) {
// we could also adjust `errors` here to remove application errors
// when releaseLabel is empty instead of the `alsoValidates` on the field
this.setState({ value })
},
handleErrors(errors) {
this.setState({ errors })
},
handleSubmit(cluster) {
console.log(JSON.stringify(serialize(cluster), null, 2))
},
render() {
let { errors, value } = this.state
let releaseSelected = !!value.releaseLabel
let isV4 = /^emr-4/.test(value.releaseLabel)
return (
)
}
})
export default FormExample