<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #44854 This PR explicitly enables the 1Password autofill icon for credential fields, such as the ones in the login form. Made the decision to have `ignore1password=true` by default (less LOC changed since the vast majority of inputs aren't credential fields). Note: even though the Certificate Authority input fields contain some kind of secret or credentials, I feel like these differ enough from one another (+ these are usually admin-pasted values) that it didn't make sense to have the 1PW autofill on them. # Checklist for submitter - [x] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. ## Testing - [x] Added/updated automated tests - [x] QA'd all new/changed functionality manually https://github.com/user-attachments/assets/c8539d8f-e0e3-4499-ae67-16cfd0f59e3a <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Prevented the 1Password autofill icon from appearing on non-credential inputs. * Ensured explicit 1Password autofill handling for email/password fields across login, registration, password reset, and account forms. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
92 lines
2.6 KiB
React
92 lines
2.6 KiB
React
import React, { Component } from "react";
|
|
import PropTypes from "prop-types";
|
|
|
|
import Button from "components/buttons/Button";
|
|
import Form from "components/forms/Form";
|
|
import formFieldInterface from "interfaces/form_field";
|
|
import InputField from "components/forms/fields/InputField";
|
|
import validate from "components/forms/UserSettingsForm/validate";
|
|
|
|
const formFields = ["email", "name", "position", "username"];
|
|
|
|
const baseClass = "manage-user";
|
|
|
|
class UserSettingsForm extends Component {
|
|
static propTypes = {
|
|
fields: PropTypes.shape({
|
|
email: formFieldInterface.isRequired,
|
|
name: formFieldInterface.isRequired,
|
|
position: formFieldInterface.isRequired,
|
|
}).isRequired,
|
|
handleSubmit: PropTypes.func.isRequired,
|
|
pendingEmail: PropTypes.string,
|
|
onCancel: PropTypes.func.isRequired,
|
|
smtpConfigured: PropTypes.bool,
|
|
};
|
|
|
|
renderEmailHelpText = () => {
|
|
const { pendingEmail } = this.props;
|
|
|
|
if (!pendingEmail) {
|
|
return undefined;
|
|
}
|
|
|
|
return (
|
|
<i className={`${baseClass}__email-help-text`}>
|
|
Pending change to <b>{pendingEmail}</b>
|
|
</i>
|
|
);
|
|
};
|
|
|
|
render() {
|
|
const { fields, handleSubmit, onCancel, smtpConfigured } = this.props;
|
|
const { renderEmailHelpText } = this;
|
|
|
|
return (
|
|
<form onSubmit={handleSubmit} className={baseClass} autoComplete="off">
|
|
<div
|
|
className="smtp-not-configured"
|
|
data-tip
|
|
data-for="smtp-tooltip"
|
|
data-tip-disable={smtpConfigured}
|
|
>
|
|
<InputField
|
|
{...fields.email}
|
|
autofocus
|
|
label="Email (required)"
|
|
helpText={renderEmailHelpText()}
|
|
readOnly={!smtpConfigured}
|
|
ignore1password={false}
|
|
tooltip={
|
|
<>
|
|
Editing your email address requires that SMTP or SES is
|
|
configured in order to send a validation email.
|
|
<br />
|
|
<br />
|
|
Users with Admin role can configure SMTP in{" "}
|
|
<strong>Settings > Organization settings</strong>.
|
|
</>
|
|
}
|
|
/>
|
|
</div>
|
|
<InputField
|
|
{...fields.name}
|
|
label="Full name (required)"
|
|
inputOptions={{
|
|
maxLength: "80",
|
|
}}
|
|
/>
|
|
<InputField {...fields.position} label="Position" />
|
|
<div className="button-wrap">
|
|
<Button onClick={onCancel} variant="inverse">
|
|
Cancel
|
|
</Button>
|
|
<Button type="submit">Update</Button>
|
|
</div>
|
|
</form>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default Form(UserSettingsForm, { fields: formFields, validate });
|