import React, { PropTypes } from 'react'; import { reduxForm } from 'redux-form'; import NewFileForm from './NewFileForm'; import classNames from 'classnames'; import InlineSVG from 'react-inlinesvg'; const exitUrl = require('../../../images/exit.svg'); import FileUploader from './FileUploader'; // At some point this will probably be generalized to a generic modal // in which you can insert different content // but for now, let's just make this work function NewFileModal(props) { const modalClass = classNames({ modal: true, 'modal--reduced': !props.canUploadMedia }); return (

Add File

{(() => { if (props.canUploadMedia) { return (

OR

); } return ''; })()}
); } NewFileModal.propTypes = { closeModal: PropTypes.func.isRequired, canUploadMedia: PropTypes.bool.isRequired }; function validate(formProps) { const errors = {}; if (!formProps.name) { errors.name = 'Please enter a name'; } else if (!formProps.name.match(/(.+\.js$|.+\.css$)/)) { errors.name = 'File must be of type JavaScript or CSS.'; } return errors; } export default reduxForm({ form: 'new-file', fields: ['name'], validate })(NewFileModal);