2019-05-28 12:07:46 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { Field, reduxForm } from 'redux-form';
|
2020-05-22 14:06:05 +00:00
|
|
|
import { Trans, withTranslation } from 'react-i18next';
|
2019-05-28 12:07:46 +00:00
|
|
|
import flow from 'lodash/flow';
|
|
|
|
|
2020-05-22 14:06:05 +00:00
|
|
|
import {
|
|
|
|
renderInputField, ipv4, mac, required,
|
|
|
|
} from '../../../../helpers/form';
|
2020-06-10 16:04:19 +00:00
|
|
|
import { FORM_NAME } from '../../../../helpers/constants';
|
2019-05-28 12:07:46 +00:00
|
|
|
|
|
|
|
const Form = (props) => {
|
|
|
|
const {
|
|
|
|
t,
|
|
|
|
handleSubmit,
|
|
|
|
reset,
|
|
|
|
pristine,
|
|
|
|
submitting,
|
|
|
|
toggleLeaseModal,
|
|
|
|
processingAdding,
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<form onSubmit={handleSubmit}>
|
|
|
|
<div className="modal-body">
|
|
|
|
<div className="form__group">
|
|
|
|
<Field
|
|
|
|
id="mac"
|
|
|
|
name="mac"
|
2019-12-12 18:48:17 +00:00
|
|
|
component={renderInputField}
|
2019-05-28 12:07:46 +00:00
|
|
|
type="text"
|
|
|
|
className="form-control"
|
|
|
|
placeholder={t('form_enter_mac')}
|
|
|
|
validate={[required, mac]}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="form__group">
|
|
|
|
<Field
|
|
|
|
id="ip"
|
|
|
|
name="ip"
|
2019-12-12 18:48:17 +00:00
|
|
|
component={renderInputField}
|
2019-05-28 12:07:46 +00:00
|
|
|
type="text"
|
|
|
|
className="form-control"
|
|
|
|
placeholder={t('form_enter_ip')}
|
|
|
|
validate={[required, ipv4]}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="form__group">
|
|
|
|
<Field
|
|
|
|
id="hostname"
|
|
|
|
name="hostname"
|
2019-12-12 18:48:17 +00:00
|
|
|
component={renderInputField}
|
2019-05-28 12:07:46 +00:00
|
|
|
type="text"
|
|
|
|
className="form-control"
|
|
|
|
placeholder={t('form_enter_hostname')}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="modal-footer">
|
|
|
|
<div className="btn-list">
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="btn btn-secondary btn-standard"
|
|
|
|
disabled={submitting}
|
|
|
|
onClick={() => {
|
|
|
|
reset();
|
|
|
|
toggleLeaseModal();
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Trans>cancel_btn</Trans>
|
|
|
|
</button>
|
|
|
|
<button
|
|
|
|
type="submit"
|
|
|
|
className="btn btn-success btn-standard"
|
|
|
|
disabled={submitting || pristine || processingAdding}
|
|
|
|
>
|
|
|
|
<Trans>save_btn</Trans>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
Form.propTypes = {
|
|
|
|
pristine: PropTypes.bool.isRequired,
|
|
|
|
handleSubmit: PropTypes.func.isRequired,
|
|
|
|
reset: PropTypes.func.isRequired,
|
|
|
|
submitting: PropTypes.bool.isRequired,
|
|
|
|
toggleLeaseModal: PropTypes.func.isRequired,
|
|
|
|
processingAdding: PropTypes.bool.isRequired,
|
|
|
|
t: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default flow([
|
2020-05-22 14:06:05 +00:00
|
|
|
withTranslation(),
|
2020-06-10 16:04:19 +00:00
|
|
|
reduxForm({ form: FORM_NAME.LEASE }),
|
2019-05-28 12:07:46 +00:00
|
|
|
])(Form);
|