2021-04-12 13:32:25 +00:00
|
|
|
import React, { Component } from "react";
|
|
|
|
|
import PropTypes from "prop-types";
|
2016-12-13 15:24:58 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
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";
|
2021-06-28 23:47:00 +00:00
|
|
|
import validate from "components/forms/UserSettingsForm/validate";
|
2016-12-13 15:24:58 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
const formFields = ["email", "name", "position", "username"];
|
2016-12-13 15:24:58 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
const baseClass = "manage-user";
|
2016-12-21 18:22:18 +00:00
|
|
|
|
2016-12-13 15:24:58 +00:00
|
|
|
class UserSettingsForm extends Component {
|
|
|
|
|
static propTypes = {
|
|
|
|
|
fields: PropTypes.shape({
|
|
|
|
|
email: formFieldInterface.isRequired,
|
|
|
|
|
name: formFieldInterface.isRequired,
|
|
|
|
|
position: formFieldInterface.isRequired,
|
|
|
|
|
}).isRequired,
|
|
|
|
|
handleSubmit: PropTypes.func.isRequired,
|
2017-02-24 15:08:59 +00:00
|
|
|
pendingEmail: PropTypes.string,
|
2016-12-13 15:24:58 +00:00
|
|
|
onCancel: PropTypes.func.isRequired,
|
2021-07-06 16:22:51 +00:00
|
|
|
smtpConfigured: PropTypes.bool,
|
2016-12-13 15:24:58 +00:00
|
|
|
};
|
|
|
|
|
|
2017-02-24 15:08:59 +00:00
|
|
|
renderEmailHint = () => {
|
|
|
|
|
const { pendingEmail } = this.props;
|
|
|
|
|
|
|
|
|
|
if (!pendingEmail) {
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<i className={`${baseClass}__email-hint`}>
|
|
|
|
|
Pending change to <b>{pendingEmail}</b>
|
|
|
|
|
</i>
|
|
|
|
|
);
|
2021-04-12 13:32:25 +00:00
|
|
|
};
|
2017-02-24 15:08:59 +00:00
|
|
|
|
2021-04-12 13:32:25 +00:00
|
|
|
render() {
|
2021-07-06 16:22:51 +00:00
|
|
|
const { fields, handleSubmit, onCancel, smtpConfigured } = this.props;
|
2017-02-24 15:08:59 +00:00
|
|
|
const { renderEmailHint } = this;
|
2016-12-13 15:24:58 +00:00
|
|
|
|
|
|
|
|
return (
|
2021-10-27 17:31:45 +00:00
|
|
|
<form onSubmit={handleSubmit} className={baseClass} autoComplete="off">
|
2021-07-06 16:22:51 +00:00
|
|
|
<div
|
|
|
|
|
className="smtp-not-configured"
|
|
|
|
|
data-tip
|
|
|
|
|
data-for="smtp-tooltip"
|
|
|
|
|
data-tip-disable={smtpConfigured}
|
|
|
|
|
>
|
|
|
|
|
<InputField
|
|
|
|
|
{...fields.email}
|
|
|
|
|
autofocus
|
|
|
|
|
label="Email (required)"
|
|
|
|
|
hint={renderEmailHint()}
|
|
|
|
|
disabled={!smtpConfigured}
|
2022-02-28 21:25:06 +00:00
|
|
|
tooltip={
|
|
|
|
|
"\
|
|
|
|
|
Editing your email address requires that SMTP is configured in order to send a validation email.\
|
|
|
|
|
<br /><br /> \
|
|
|
|
|
Users with Admin role can configure SMTP in <strong>Settings > Organization settings</strong>.\
|
|
|
|
|
"
|
|
|
|
|
}
|
2021-07-06 16:22:51 +00:00
|
|
|
/>
|
|
|
|
|
</div>
|
2022-02-09 01:40:38 +00:00
|
|
|
<InputField
|
|
|
|
|
{...fields.name}
|
|
|
|
|
label="Full name (required)"
|
|
|
|
|
inputOptions={{
|
|
|
|
|
maxLength: "80",
|
|
|
|
|
}}
|
|
|
|
|
/>
|
2021-04-12 13:32:25 +00:00
|
|
|
<InputField {...fields.position} label="Position" />
|
2016-12-21 18:22:18 +00:00
|
|
|
<div className={`${baseClass}__button-wrap`}>
|
2021-04-12 13:32:25 +00:00
|
|
|
<Button onClick={onCancel} variant="inverse">
|
|
|
|
|
Cancel
|
|
|
|
|
</Button>
|
|
|
|
|
<Button type="submit" variant="brand">
|
|
|
|
|
Update
|
|
|
|
|
</Button>
|
2016-12-21 18:22:18 +00:00
|
|
|
</div>
|
2016-12-13 15:24:58 +00:00
|
|
|
</form>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-28 23:47:00 +00:00
|
|
|
export default Form(UserSettingsForm, { fields: formFields, validate });
|