feat: add display name to create local user modal (#1631)

pull/1636/head
TheCatLady 4 years ago committed by GitHub
parent 6b37242a3f
commit 44c3edb985
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,7 +3,7 @@ import { Field, Form, Formik } from 'formik';
import React from 'react'; import React from 'react';
import { defineMessages, useIntl } from 'react-intl'; import { defineMessages, useIntl } from 'react-intl';
import { useToasts } from 'react-toast-notifications'; import { useToasts } from 'react-toast-notifications';
import useSWR from 'swr'; import useSWR, { mutate } from 'swr';
import type { MainSettings } from '../../../../server/lib/settings'; import type { MainSettings } from '../../../../server/lib/settings';
import globalMessages from '../../../i18n/globalMessages'; import globalMessages from '../../../i18n/globalMessages';
import Button from '../../Common/Button'; import Button from '../../Common/Button';
@ -80,6 +80,7 @@ const SettingsUsers: React.FC = () => {
}, },
defaultPermissions: values.defaultPermissions, defaultPermissions: values.defaultPermissions,
}); });
mutate('/api/v1/settings/public');
addToast(intl.formatMessage(messages.toastSettingsSuccess), { addToast(intl.formatMessage(messages.toastSettingsSuccess), {
autoDismiss: true, autoDismiss: true,

@ -58,7 +58,6 @@ const messages = defineMessages({
'Are you sure you want to delete this user? All of their request data will be permanently removed.', 'Are you sure you want to delete this user? All of their request data will be permanently removed.',
localuser: 'Local User', localuser: 'Local User',
createlocaluser: 'Create Local User', createlocaluser: 'Create Local User',
createuser: 'Create User',
creating: 'Creating…', creating: 'Creating…',
create: 'Create', create: 'Create',
validationpasswordminchars: validationpasswordminchars:
@ -67,6 +66,7 @@ const messages = defineMessages({
usercreatedfailedexisting: usercreatedfailedexisting:
'The provided email address is already in use by another user.', 'The provided email address is already in use by another user.',
usercreatedsuccess: 'User created successfully!', usercreatedsuccess: 'User created successfully!',
displayName: 'Display Name',
email: 'Email Address', email: 'Email Address',
password: 'Password', password: 'Password',
passwordinfodescription: passwordinfodescription:
@ -294,6 +294,7 @@ const UserList: React.FC = () => {
> >
<Formik <Formik
initialValues={{ initialValues={{
displayName: '',
email: '', email: '',
password: '', password: '',
genpassword: false, genpassword: false,
@ -302,6 +303,7 @@ const UserList: React.FC = () => {
onSubmit={async (values) => { onSubmit={async (values) => {
try { try {
await axios.post('/api/v1/user', { await axios.post('/api/v1/user', {
username: values.displayName,
email: values.email, email: values.email,
password: values.genpassword ? null : values.password, password: values.genpassword ? null : values.password,
}); });
@ -338,7 +340,7 @@ const UserList: React.FC = () => {
}) => { }) => {
return ( return (
<Modal <Modal
title={intl.formatMessage(messages.createuser)} title={intl.formatMessage(messages.createlocaluser)}
iconSvg={<UserAddIcon />} iconSvg={<UserAddIcon />}
onOk={() => handleSubmit()} onOk={() => handleSubmit()}
okText={ okText={
@ -371,9 +373,24 @@ const UserList: React.FC = () => {
/> />
)} )}
<Form className="section"> <Form className="section">
<div className="form-row">
<label htmlFor="displayName" className="text-label">
{intl.formatMessage(messages.displayName)}
</label>
<div className="form-input">
<div className="form-input-field">
<Field
id="displayName"
name="displayName"
type="text"
/>
</div>
</div>
</div>
<div className="form-row"> <div className="form-row">
<label htmlFor="email" className="text-label"> <label htmlFor="email" className="text-label">
{intl.formatMessage(messages.email)} {intl.formatMessage(messages.email)}
<span className="label-required">*</span>
</label> </label>
<div className="form-input"> <div className="form-input">
<div className="form-input-field"> <div className="form-input-field">
@ -417,6 +434,9 @@ const UserList: React.FC = () => {
> >
<label htmlFor="password" className="text-label"> <label htmlFor="password" className="text-label">
{intl.formatMessage(messages.password)} {intl.formatMessage(messages.password)}
{!values.genpassword && (
<span className="label-required">*</span>
)}
</label> </label>
<div className="form-input"> <div className="form-input">
<div className="form-input-field"> <div className="form-input-field">

@ -693,10 +693,10 @@
"components.UserList.create": "Create", "components.UserList.create": "Create",
"components.UserList.created": "Created", "components.UserList.created": "Created",
"components.UserList.createlocaluser": "Create Local User", "components.UserList.createlocaluser": "Create Local User",
"components.UserList.createuser": "Create User",
"components.UserList.creating": "Creating…", "components.UserList.creating": "Creating…",
"components.UserList.deleteconfirm": "Are you sure you want to delete this user? All of their request data will be permanently removed.", "components.UserList.deleteconfirm": "Are you sure you want to delete this user? All of their request data will be permanently removed.",
"components.UserList.deleteuser": "Delete User", "components.UserList.deleteuser": "Delete User",
"components.UserList.displayName": "Display Name",
"components.UserList.edituser": "Edit User Permissions", "components.UserList.edituser": "Edit User Permissions",
"components.UserList.email": "Email Address", "components.UserList.email": "Email Address",
"components.UserList.importedfromplex": "{userCount, plural, one {# new user} other {# new users}} imported from Plex successfully!", "components.UserList.importedfromplex": "{userCount, plural, one {# new user} other {# new users}} imported from Plex successfully!",

Loading…
Cancel
Save