2019-01-07 01:25:33 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2016-12-01 18:57:19 +00:00
|
|
|
import classnames from 'classnames';
|
2016-11-16 16:58:25 +00:00
|
|
|
|
|
|
|
import AdminDetails from 'components/forms/RegistrationForm/AdminDetails';
|
|
|
|
import ConfirmationPage from 'components/forms/RegistrationForm/ConfirmationPage';
|
|
|
|
import KolideDetails from 'components/forms/RegistrationForm/KolideDetails';
|
|
|
|
import OrgDetails from 'components/forms/RegistrationForm/OrgDetails';
|
|
|
|
|
2016-12-01 18:57:19 +00:00
|
|
|
const baseClass = 'user-registration';
|
|
|
|
|
2016-11-16 16:58:25 +00:00
|
|
|
class RegistrationForm extends Component {
|
|
|
|
static propTypes = {
|
|
|
|
onNextPage: PropTypes.func,
|
|
|
|
onSubmit: PropTypes.func,
|
|
|
|
page: PropTypes.number,
|
|
|
|
};
|
|
|
|
|
|
|
|
constructor (props) {
|
|
|
|
super(props);
|
2016-12-01 18:57:19 +00:00
|
|
|
const { window } = global;
|
2016-11-16 16:58:25 +00:00
|
|
|
|
2016-12-01 18:57:19 +00:00
|
|
|
this.state = {
|
|
|
|
errors: {},
|
|
|
|
formData: {
|
|
|
|
kolide_server_url: window.location.origin,
|
|
|
|
},
|
|
|
|
};
|
2016-11-16 16:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onPageFormSubmit = (pageFormData) => {
|
|
|
|
const { formData } = this.state;
|
|
|
|
const { onNextPage } = this.props;
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
formData: {
|
|
|
|
...formData,
|
|
|
|
...pageFormData,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
return onNextPage();
|
|
|
|
}
|
|
|
|
|
2017-01-11 19:27:33 +00:00
|
|
|
onSubmitConfirmation = (evt) => {
|
|
|
|
evt.preventDefault();
|
|
|
|
|
2016-11-16 16:58:25 +00:00
|
|
|
const { formData } = this.state;
|
|
|
|
const { onSubmit: handleSubmit } = this.props;
|
|
|
|
|
|
|
|
return handleSubmit(formData);
|
|
|
|
}
|
|
|
|
|
2016-12-01 18:57:19 +00:00
|
|
|
isCurrentPage = (num) => {
|
|
|
|
const { page } = this.props;
|
|
|
|
|
|
|
|
if (num === page) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
2017-01-11 19:27:33 +00:00
|
|
|
const { page } = this.props;
|
2016-11-16 16:58:25 +00:00
|
|
|
const { formData } = this.state;
|
2020-12-02 14:59:44 +00:00
|
|
|
const { isCurrentPage, onPageFormSubmit, onSubmitConfirmation } = this;
|
2016-11-16 16:58:25 +00:00
|
|
|
|
2020-12-02 14:59:44 +00:00
|
|
|
const adminDetailsContainerClass = classnames(
|
|
|
|
`${baseClass}__container`,
|
|
|
|
`${baseClass}__container--admin`,
|
|
|
|
);
|
2016-11-16 16:58:25 +00:00
|
|
|
|
2016-12-01 18:57:19 +00:00
|
|
|
const adminDetailsClass = classnames(
|
|
|
|
`${baseClass}__field-wrapper`,
|
2020-07-07 02:31:48 +00:00
|
|
|
`${baseClass}__field-wrapper--admin`,
|
2016-12-01 18:57:19 +00:00
|
|
|
);
|
2016-11-16 16:58:25 +00:00
|
|
|
|
2020-12-02 14:59:44 +00:00
|
|
|
const orgDetailsContainerClass = classnames(
|
|
|
|
`${baseClass}__container`,
|
|
|
|
`${baseClass}__container--org`,
|
|
|
|
);
|
|
|
|
|
2016-12-01 18:57:19 +00:00
|
|
|
const orgDetailsClass = classnames(
|
|
|
|
`${baseClass}__field-wrapper`,
|
2020-07-07 02:31:48 +00:00
|
|
|
`${baseClass}__field-wrapper--org`,
|
2016-12-01 18:57:19 +00:00
|
|
|
);
|
2016-11-16 16:58:25 +00:00
|
|
|
|
2020-12-02 14:59:44 +00:00
|
|
|
const kolideDetailsContainerClass = classnames(
|
|
|
|
`${baseClass}__container`,
|
|
|
|
`${baseClass}__container--kolide`,
|
|
|
|
);
|
|
|
|
|
2016-12-01 18:57:19 +00:00
|
|
|
const kolideDetailsClass = classnames(
|
|
|
|
`${baseClass}__field-wrapper`,
|
2020-07-07 02:31:48 +00:00
|
|
|
`${baseClass}__field-wrapper--kolide`,
|
2016-12-01 18:57:19 +00:00
|
|
|
);
|
2016-11-16 16:58:25 +00:00
|
|
|
|
2020-12-02 14:59:44 +00:00
|
|
|
const confirmationContainerClass = classnames(
|
|
|
|
`${baseClass}__container`,
|
|
|
|
`${baseClass}__container--confirmation`,
|
|
|
|
);
|
|
|
|
|
|
|
|
const confirmationClass = classnames(
|
|
|
|
`${baseClass}__field-wrapper`,
|
|
|
|
`${baseClass}__field-wrapper--confirmation`,
|
|
|
|
);
|
|
|
|
|
2016-12-01 18:57:19 +00:00
|
|
|
const formSectionClasses = classnames(
|
|
|
|
`${baseClass}__form`,
|
|
|
|
{
|
|
|
|
[`${baseClass}__form--step1-active`]: page === 1,
|
|
|
|
[`${baseClass}__form--step1-complete`]: page > 1,
|
|
|
|
[`${baseClass}__form--step2-active`]: page === 2,
|
|
|
|
[`${baseClass}__form--step2-complete`]: page > 2,
|
|
|
|
[`${baseClass}__form--step3-active`]: page === 3,
|
|
|
|
[`${baseClass}__form--step3-complete`]: page > 3,
|
2020-12-02 14:59:44 +00:00
|
|
|
[`${baseClass}__form--step4-active`]: page === 4,
|
2020-07-07 02:31:48 +00:00
|
|
|
},
|
2016-12-01 18:57:19 +00:00
|
|
|
);
|
2016-11-16 16:58:25 +00:00
|
|
|
|
|
|
|
return (
|
2016-12-01 18:57:19 +00:00
|
|
|
<div className={baseClass}>
|
2020-12-02 14:59:44 +00:00
|
|
|
<div className={formSectionClasses}>
|
|
|
|
<div className={adminDetailsContainerClass}>
|
|
|
|
<h2>Setup user</h2>
|
|
|
|
<p>Additional admins can be designated within the Fleet App</p>
|
2016-12-01 18:57:19 +00:00
|
|
|
<AdminDetails formData={formData} handleSubmit={onPageFormSubmit} className={adminDetailsClass} currentPage={isCurrentPage(1)} />
|
2020-12-02 14:59:44 +00:00
|
|
|
</div>
|
|
|
|
<div className={orgDetailsContainerClass}>
|
|
|
|
<h2>Organization details</h2>
|
2016-12-01 18:57:19 +00:00
|
|
|
<OrgDetails formData={formData} handleSubmit={onPageFormSubmit} className={orgDetailsClass} currentPage={isCurrentPage(2)} />
|
2020-12-02 14:59:44 +00:00
|
|
|
</div>
|
|
|
|
<div className={kolideDetailsContainerClass}>
|
|
|
|
<h2>Set Fleet URL</h2>
|
2016-12-01 18:57:19 +00:00
|
|
|
<KolideDetails formData={formData} handleSubmit={onPageFormSubmit} className={kolideDetailsClass} currentPage={isCurrentPage(3)} />
|
2017-01-11 19:27:33 +00:00
|
|
|
</div>
|
2020-12-02 14:59:44 +00:00
|
|
|
<div className={confirmationContainerClass}>
|
|
|
|
<h2>Success</h2>
|
|
|
|
<ConfirmationPage formData={formData} handleSubmit={onSubmitConfirmation} classNmae={confirmationClass} currentPage={isCurrentPage(4)} />
|
|
|
|
</div>
|
2016-12-01 18:57:19 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2016-11-16 16:58:25 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default RegistrationForm;
|