Regression: nickname field in user profile. (#18359)

* Added nickname field, hints for disabled fields

* More missing nicknames
pull/18370/head
gabriellsh 5 years ago committed by GitHub
parent 59ca315ce3
commit 467fb759cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      client/account/AccountProfileForm.js
  2. 8
      client/account/AccountProfilePage.js
  3. 2
      client/admin/users/UserInfo.js
  4. 2
      client/channel/UserCard/index.js
  5. 2
      client/channel/UserInfo/index.js
  6. 8
      client/components/basic/UserCard.js
  7. 12
      client/components/basic/UserInfo.js

@ -45,6 +45,7 @@ export default function AccountProfileForm({ values, handlers, user, settings, o
bio, bio,
statusType, statusType,
customFields, customFields,
nickname,
} = values; } = values;
const { const {
@ -58,6 +59,7 @@ export default function AccountProfileForm({ values, handlers, user, settings, o
handleStatusType, handleStatusType,
handleBio, handleBio,
handleCustomFields, handleCustomFields,
handleNickname,
} = handlers; } = handlers;
const previousEmail = getUserEmailAddress(user); const previousEmail = getUserEmailAddress(user);
@ -136,6 +138,9 @@ export default function AccountProfileForm({ values, handlers, user, settings, o
<Field.Row> <Field.Row>
<TextInput error={nameError} disabled={!allowRealNameChange} flexGrow={1} value={realname} onChange={handleRealname}/> <TextInput error={nameError} disabled={!allowRealNameChange} flexGrow={1} value={realname} onChange={handleRealname}/>
</Field.Row> </Field.Row>
{!allowRealNameChange && <Field.Hint>
{t('RealName_Change_Disabled')}
</Field.Hint>}
<Field.Error> <Field.Error>
{nameError} {nameError}
</Field.Error> </Field.Error>
@ -145,6 +150,9 @@ export default function AccountProfileForm({ values, handlers, user, settings, o
<Field.Row> <Field.Row>
<TextInput error={usernameError} disabled={!canChangeUsername} flexGrow={1} value={username} onChange={handleUsername} addon={<Icon name='at' size='x20'/>}/> <TextInput error={usernameError} disabled={!canChangeUsername} flexGrow={1} value={username} onChange={handleUsername} addon={<Icon name='at' size='x20'/>}/>
</Field.Row> </Field.Row>
{!canChangeUsername && <Field.Hint>
{t('Username_Change_Disabled')}
</Field.Hint>}
<Field.Error> <Field.Error>
{usernameError} {usernameError}
</Field.Error> </Field.Error>
@ -155,10 +163,19 @@ export default function AccountProfileForm({ values, handlers, user, settings, o
<Field.Row> <Field.Row>
<TextInput error={statusTextError} disabled={!allowUserStatusMessageChange} flexGrow={1} value={statusText} onChange={handleStatusText} addon={<UserStatusMenu margin='neg-x2' onChange={handleStatusType} initialStatus={statusType}/>}/> <TextInput error={statusTextError} disabled={!allowUserStatusMessageChange} flexGrow={1} value={statusText} onChange={handleStatusText} addon={<UserStatusMenu margin='neg-x2' onChange={handleStatusType} initialStatus={statusType}/>}/>
</Field.Row> </Field.Row>
{!allowUserStatusMessageChange && <Field.Hint>
{t('StatusMessage_Change_Disabled')}
</Field.Hint>}
<Field.Error> <Field.Error>
{statusTextError} {statusTextError}
</Field.Error> </Field.Error>
</Field>, [t, statusTextError, allowUserStatusMessageChange, statusText, handleStatusText, handleStatusType, statusType])} </Field>, [t, statusTextError, allowUserStatusMessageChange, statusText, handleStatusText, handleStatusType, statusType])}
{useMemo(() => <Field>
<Field.Label>{t('Nickname')}</Field.Label>
<Field.Row>
<TextInput flexGrow={1} value={nickname} onChange={handleNickname} addon={<Icon name='edit' size='x20' alignSelf='center'/>}/>
</Field.Row>
</Field>, [nickname, handleNickname, t])}
{useMemo(() => <Field> {useMemo(() => <Field>
<Field.Label>{t('Bio')}</Field.Label> <Field.Label>{t('Bio')}</Field.Label>
<Field.Row> <Field.Row>
@ -183,6 +200,9 @@ export default function AccountProfileForm({ values, handlers, user, settings, o
disabled={!allowEmailChange} disabled={!allowEmailChange}
/> />
</Field.Row> </Field.Row>
{!allowEmailChange && <Field.Hint>
{t('Email_Change_Disabled')}
</Field.Hint>}
<Field.Error> <Field.Error>
{t(emailError)} {t(emailError)}
</Field.Error> </Field.Error>
@ -203,6 +223,9 @@ export default function AccountProfileForm({ values, handlers, user, settings, o
<Field.Row> <Field.Row>
<PasswordInput autoComplete='off' disabled={!allowPasswordChange} error={passwordError} flexGrow={1} value={password} onChange={handlePassword} addon={<Icon name='key' size='x20'/>}/> <PasswordInput autoComplete='off' disabled={!allowPasswordChange} error={passwordError} flexGrow={1} value={password} onChange={handlePassword} addon={<Icon name='key' size='x20'/>}/>
</Field.Row> </Field.Row>
{!allowPasswordChange && <Field.Hint>
{t('Password_Change_Disabled')}
</Field.Hint>}
</Field>, [t, password, handlePassword, passwordError, allowPasswordChange])} </Field>, [t, password, handlePassword, passwordError, allowPasswordChange])}
{useMemo(() => <Field> {useMemo(() => <Field>
<AnimatedVisibility visibility={password ? AnimatedVisibility.VISIBLE : AnimatedVisibility.HIDDEN }> <AnimatedVisibility visibility={password ? AnimatedVisibility.VISIBLE : AnimatedVisibility.HIDDEN }>

@ -54,6 +54,7 @@ const getInitialValues = (user) => ({
statusType: user.status ?? '', statusType: user.status ?? '',
bio: user.bio ?? '', bio: user.bio ?? '',
customFields: user.customFields ?? {}, customFields: user.customFields ?? {},
nickname: user.nickname ?? '',
}); });
const AccountProfilePage = () => { const AccountProfilePage = () => {
@ -62,7 +63,7 @@ const AccountProfilePage = () => {
const user = useUser(); const user = useUser();
const { values, handlers, hasUnsavedChanges } = useForm(getInitialValues(user)); const { values, handlers, hasUnsavedChanges, commit } = useForm(getInitialValues(user));
const [canSave, setCanSave] = useState(true); const [canSave, setCanSave] = useState(true);
const setModal = useSetModal(); const setModal = useSetModal();
const [loggingOut, setLoggingOut] = useState(false); const [loggingOut, setLoggingOut] = useState(false);
@ -124,6 +125,7 @@ const AccountProfilePage = () => {
statusType, statusType,
customFields, customFields,
bio, bio,
nickname,
} = values; } = values;
const { handleAvatar } = handlers; const { handleAvatar } = handlers;
@ -143,8 +145,10 @@ const AccountProfilePage = () => {
...allowUserStatusMessageChange && { statusText }, ...allowUserStatusMessageChange && { statusText },
...typedPassword && { typedPassword: SHA256(typedPassword) }, ...typedPassword && { typedPassword: SHA256(typedPassword) },
statusType, statusType,
nickname,
bio: bio || '', bio: bio || '',
}, customFields); }, customFields);
commit();
dispatchToastMessage({ type: 'success', message: t('Profile_saved_successfully') }); dispatchToastMessage({ type: 'success', message: t('Profile_saved_successfully') });
} catch (error) { } catch (error) {
dispatchToastMessage({ type: 'error', message: error }); dispatchToastMessage({ type: 'error', message: error });
@ -185,6 +189,8 @@ const AccountProfilePage = () => {
customFields, customFields,
statusType, statusType,
setModal, setModal,
commit,
nickname,
]); ]);
const handleLogoutOtherLocations = useCallback(async () => { const handleLogoutOtherLocations = useCallback(async () => {

@ -32,6 +32,7 @@ export function UserInfoWithData({ uid, username, ...props }) {
bio, bio,
utcOffset, utcOffset,
lastLogin, lastLogin,
nickname,
} = user; } = user;
return { return {
name: showRealNames ? name : username, name: showRealNames ? name : username,
@ -48,6 +49,7 @@ export function UserInfoWithData({ uid, username, ...props }) {
createdAt: user.createdAt, createdAt: user.createdAt,
status: UserStatus.getStatus(status), status: UserStatus.getStatus(status),
customStatus: statusText, customStatus: statusText,
nickname,
}; };
}, [data, showRealNames]); }, [data, showRealNames]);

@ -59,6 +59,7 @@ const UserCardWithData = ({ username, onClose, target, open, rid }) => {
statusText = status, statusText = status,
bio = defaultValue, bio = defaultValue,
utcOffset = defaultValue, utcOffset = defaultValue,
nickname,
} = user; } = user;
return { return {
@ -74,6 +75,7 @@ const UserCardWithData = ({ username, onClose, target, open, rid }) => {
), ),
status: UserStatus.getStatus(status), status: UserStatus.getStatus(status),
customStatus: statusText, customStatus: statusText,
nickname,
}; };
}, [data, username, showRealNames, state]); }, [data, username, showRealNames, state]);

@ -38,6 +38,7 @@ export const UserInfoWithData = React.memo(function UserInfoWithData({ uid, user
bio, bio,
utcOffset, utcOffset,
lastLogin, lastLogin,
nickname,
} = user; } = user;
return { return {
name: showRealNames ? name : username, name: showRealNames ? name : username,
@ -55,6 +56,7 @@ export const UserInfoWithData = React.memo(function UserInfoWithData({ uid, user
// localTime: <LocalTime offset={utcOffset} />, // localTime: <LocalTime offset={utcOffset} />,
status: UserStatus.getStatus(status), status: UserStatus.getStatus(status),
customStatus: statusText, customStatus: statusText,
nickname,
}; };
}, [data, showRealNames]); }, [data, showRealNames]);

@ -47,7 +47,7 @@ const Role = ({ children }) => <Tag
children={children} children={children}
/>; />;
const UserCardConteiner = forwardRef((props, ref) => <Box rcx-user-card bg='surface' elevation='2' p='x24' display='flex' borderRadius='x2' width='439px' {...props} ref={ref}/>); const UserCardContainer = forwardRef((props, ref) => <Box rcx-user-card bg='surface' elevation='2' p='x24' display='flex' borderRadius='x2' width='439px' {...props} ref={ref}/>);
const UserCard = forwardRef(({ const UserCard = forwardRef(({
className, className,
style, style,
@ -69,8 +69,9 @@ const UserCard = forwardRef(({
actions, actions,
localTime = <Skeleton width='100%'/>, localTime = <Skeleton width='100%'/>,
onClose, onClose,
nickname,
t = (e) => e, t = (e) => e,
}, ref) => <UserCardConteiner className={className} ref={ref} style={style}> }, ref) => <UserCardContainer className={className} ref={ref} style={style}>
<Box> <Box>
<UserAvatar username={username} size='x124'/> <UserAvatar username={username} size='x124'/>
{ actions && <Box flexGrow={0} display='flex' mb='x8' align='center' justifyContent='center'> { actions && <Box flexGrow={0} display='flex' mb='x8' align='center' justifyContent='center'>
@ -79,6 +80,7 @@ const UserCard = forwardRef(({
</Box> </Box>
<Box display='flex' flexDirection='column' flexGrow={1} flexShrink={1} mis='x24' width='1px'> <Box display='flex' flexDirection='column' flexGrow={1} flexShrink={1} mis='x24' width='1px'>
<Username status={status} name={name}/> <Username status={status} name={name}/>
{nickname && <Info title={t('Nickname')}>{nickname}</Info>}
{ customStatus && <Info>{customStatus}</Info> } { customStatus && <Info>{customStatus}</Info> }
<Roles>{roles}</Roles> <Roles>{roles}</Roles>
<Info>{localTime}</Info> <Info>{localTime}</Info>
@ -86,7 +88,7 @@ const UserCard = forwardRef(({
{open && <a onClick={open}>{t('See_full_profile')}</a>} {open && <a onClick={open}>{t('See_full_profile')}</a>}
</Box> </Box>
{onClose && <Box><ActionButton icon='cross' onClick={onClose}/></Box>} {onClose && <Box><ActionButton icon='cross' onClick={onClose}/></Box>}
</UserCardConteiner>); </UserCardContainer>);
export default UserCard; export default UserCard;

@ -32,6 +32,7 @@ export const UserInfo = React.memo(function UserInfo({
customFields = [], customFields = [],
name, name,
data, data,
nickname,
// onChange, // onChange,
actions, actions,
...props ...props
@ -68,6 +69,11 @@ export const UserInfo = React.memo(function UserInfo({
<Info>{name}</Info> <Info>{name}</Info>
</>} </>}
{nickname && <>
<Label>{t('Nickname')}</Label>
<Info>{nickname}</Info>
</>}
{bio && <> {bio && <>
<Label>{t('Bio')}</Label> <Label>{t('Bio')}</Label>
<Info withTruncatedText={false}><MarkdownText content={bio}/></Info> <Info withTruncatedText={false}><MarkdownText content={bio}/></Info>
@ -89,9 +95,9 @@ export const UserInfo = React.memo(function UserInfo({
</Info> </Info>
</>} </>}
{ customFields && customFields.map((customField) => <React.Fragment key={customField.label}> { customFields && Object.entries(customFields).map(([label, value]) => <React.Fragment key={label}>
<Label>{t(customField.label)}</Label> <Label>{t(label)}</Label>
<Info>{customField.value}</Info> <Info>{value}</Info>
</React.Fragment>) } </React.Fragment>) }
<Label>{t('Created_at')}</Label> <Label>{t('Created_at')}</Label>

Loading…
Cancel
Save