import React from 'react'; import PropTypes from 'prop-types'; import { withStyles } from 'material-ui/styles'; import Button from 'material-ui/Button'; import { LinearProgress } from 'material-ui/Progress'; import { TextValidator, ValidatorForm } from 'react-material-ui-form-validator'; import Typography from 'material-ui/Typography'; import isIP from '../validators/isIP'; import isHostname from '../validators/isHostname'; import or from '../validators/or'; const styles = theme => ({ loadingSettings: { margin: theme.spacing.unit, }, loadingSettingsDetails: { margin: theme.spacing.unit * 4, textAlign: "center" }, textField: { width: "100%" }, button: { marginRight: theme.spacing.unit * 2, marginTop: theme.spacing.unit * 2, } }); class NTPSettingsForm extends React.Component { componentWillMount() { ValidatorForm.addValidationRule('isIPOrHostname', or(isIP, isHostname)); } render() { const { classes, ntpSettingsFetched, ntpSettings, errorMessage, handleValueChange, onSubmit, onReset } = this.props; return (
{ !ntpSettingsFetched ?
Loading...
: ntpSettings ? :
{errorMessage}
}
); } } NTPSettingsForm.propTypes = { classes: PropTypes.object.isRequired, ntpSettingsFetched: PropTypes.bool.isRequired, ntpSettings: PropTypes.object, errorMessage: PropTypes.string, onSubmit: PropTypes.func.isRequired, onReset: PropTypes.func.isRequired, handleValueChange: PropTypes.func.isRequired, }; export default withStyles(styles)(NTPSettingsForm);