2021-04-12 13:32:25 +00:00
|
|
|
import React, { Component } from "react";
|
|
|
|
import PropTypes from "prop-types";
|
|
|
|
import classnames from "classnames";
|
2016-11-16 16:58:25 +00:00
|
|
|
|
2021-04-12 13:32: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-11-16 16:58:25 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
const baseClass = "user-registration";
|
2016-12-01 18:57:19 +00:00
|
|
|
|
2016-11-16 16:58:25 +00:00
|
|
|
class RegistrationForm extends Component {
|
|
|
|
static propTypes = {
|
|
|
|
onNextPage: PropTypes.func,
|
|
|
|
onSubmit: PropTypes.func,
|
|
|
|
page: PropTypes.number,
|
|
|
|
};
|
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
constructor(props) {
|
2016-11-16 16:58:25 +00:00
|
|
|
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();
|
2021-04-12 13:32:25 +00:00
|
|
|
};
|
2016-11-16 16:58:25 +00:00
|
|
|
|
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);
|
2021-04-12 13:32:25 +00:00
|
|
|
};
|
2016-11-16 16:58:25 +00:00
|
|
|
|
2016-12-01 18:57:19 +00:00
|
|
|
isCurrentPage = (num) => {
|
|
|
|
const { page } = this.props;
|
|
|
|
|
|
|
|
if (num === page) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2021-04-12 13:32:25 +00:00
|
|
|
};
|
2016-12-01 18:57:19 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
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`,
|
2021-04-12 13:32:25 +00:00
|
|
|
`${baseClass}__container--admin`
|
2020-12-02 14:59:44 +00:00
|
|
|
);
|
2016-11-16 16:58:25 +00:00
|
|
|
|
2016-12-01 18:57:19 +00:00
|
|
|
const adminDetailsClass = classnames(
|
|
|
|
`${baseClass}__field-wrapper`,
|
2021-04-12 13:32:25 +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`,
|
2021-04-12 13:32:25 +00:00
|
|
|
`${baseClass}__container--org`
|
2020-12-02 14:59:44 +00:00
|
|
|
);
|
|
|
|
|
2016-12-01 18:57:19 +00:00
|
|
|
const orgDetailsClass = classnames(
|
|
|
|
`${baseClass}__field-wrapper`,
|
2021-04-12 13:32:25 +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`,
|
2021-04-12 13:32:25 +00:00
|
|
|
`${baseClass}__container--kolide`
|
2020-12-02 14:59:44 +00:00
|
|
|
);
|
|
|
|
|
2016-12-01 18:57:19 +00:00
|
|
|
const kolideDetailsClass = classnames(
|
|
|
|
`${baseClass}__field-wrapper`,
|
2021-04-12 13:32:25 +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`,
|
2021-04-12 13:32:25 +00:00
|
|
|
`${baseClass}__container--confirmation`
|
2020-12-02 14:59:44 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
const confirmationClass = classnames(
|
|
|
|
`${baseClass}__field-wrapper`,
|
2021-04-12 13:32:25 +00:00
|
|
|
`${baseClass}__field-wrapper--confirmation`
|
2020-12-02 14:59:44 +00:00
|
|
|
);
|
|
|
|
|
2021-04-12 13:32:25 +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,
|
|
|
|
[`${baseClass}__form--step4-active`]: page === 4,
|
|
|
|
});
|
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>
|
2020-12-10 21:09:05 +00:00
|
|
|
<p>Additional admins can be designated within the Fleet app.</p>
|
2021-04-12 13:32:25 +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>
|
2021-04-12 13:32:25 +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>
|
2021-04-12 13:32:25 +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}>
|
2020-12-10 21:09:05 +00:00
|
|
|
<h2>You're all set.</h2>
|
2021-04-12 13:32:25 +00:00
|
|
|
<ConfirmationPage
|
|
|
|
formData={formData}
|
|
|
|
handleSubmit={onSubmitConfirmation}
|
|
|
|
classNmae={confirmationClass}
|
|
|
|
currentPage={isCurrentPage(4)}
|
|
|
|
/>
|
2020-12-02 14:59:44 +00:00
|
|
|
</div>
|
2016-12-01 18:57:19 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2016-11-16 16:58:25 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default RegistrationForm;
|