mirror of
https://github.com/fleetdm/fleet
synced 2026-05-03 21:38:24 +00:00
## Addresses #10913 - Fixes the bug(s) outlined in the issue - Improves look and feel of the tabbing experience throughout the setup flow: https://www.loom.com/share/c482317d18314e629b7e5ebab7fd2840 ## Checklist for submitter - [x] Changes file added for user-visible changes in `changes/` - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
92 lines
2.6 KiB
JavaScript
92 lines
2.6 KiB
JavaScript
import React, { Component } from "react";
|
|
import PropTypes from "prop-types";
|
|
|
|
import Form from "components/forms/Form";
|
|
import formFieldInterface from "interfaces/form_field";
|
|
import Button from "components/buttons/Button";
|
|
import InputField from "components/forms/fields/InputField";
|
|
import helpers from "./helpers";
|
|
|
|
const formFields = ["name", "password", "password_confirmation", "email"];
|
|
const { validate } = helpers;
|
|
|
|
class AdminDetails extends Component {
|
|
static propTypes = {
|
|
className: PropTypes.string,
|
|
currentPage: PropTypes.bool,
|
|
fields: PropTypes.shape({
|
|
name: formFieldInterface.isRequired,
|
|
email: formFieldInterface.isRequired,
|
|
password: formFieldInterface.isRequired,
|
|
password_confirmation: formFieldInterface.isRequired,
|
|
}).isRequired,
|
|
handleSubmit: PropTypes.func.isRequired,
|
|
};
|
|
|
|
componentDidUpdate(prevProps) {
|
|
if (
|
|
this.props.currentPage &&
|
|
this.props.currentPage !== prevProps.currentPage
|
|
) {
|
|
// Component has a transition duration of 300ms set in
|
|
// RegistrationForm/_styles.scss. We need to wait 300ms before
|
|
// calling .focus() to preserve smooth transition.
|
|
setTimeout(() => {
|
|
this.firstInput.input.focus();
|
|
}, 300);
|
|
}
|
|
}
|
|
|
|
render() {
|
|
const { className, currentPage, fields, handleSubmit } = this.props;
|
|
const tabIndex = currentPage ? 0 : -1;
|
|
|
|
return (
|
|
<form onSubmit={handleSubmit} className={className} autoComplete="off">
|
|
<div className="registration-fields">
|
|
<InputField
|
|
{...fields.name}
|
|
label="Full name"
|
|
tabIndex={tabIndex}
|
|
autofocus={currentPage}
|
|
ref={(input) => {
|
|
this.firstInput = input;
|
|
}}
|
|
inputOptions={{
|
|
maxLength: "80",
|
|
}}
|
|
/>
|
|
<InputField {...fields.email} label="Email" tabIndex={tabIndex} />
|
|
<InputField
|
|
{...fields.password}
|
|
label="Password"
|
|
type="password"
|
|
tabIndex={tabIndex}
|
|
hint={[
|
|
"Must include 12 characters, at least 1 number (e.g. 0 - 9), and at least 1 symbol (e.g. &*#)",
|
|
]}
|
|
/>
|
|
<InputField
|
|
{...fields.password_confirmation}
|
|
type="password"
|
|
tabIndex={tabIndex}
|
|
label="Confirm password"
|
|
/>
|
|
</div>
|
|
<Button
|
|
type="submit"
|
|
tabIndex={tabIndex}
|
|
disabled={!currentPage}
|
|
variant="brand"
|
|
>
|
|
Next
|
|
</Button>
|
|
</form>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default Form(AdminDetails, {
|
|
fields: formFields,
|
|
validate,
|
|
});
|