Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions client/account/AccountProfileForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export default function AccountProfileForm({ values, handlers, user, settings, o
bio,
statusType,
customFields,
nickname,
} = values;

const {
Expand All @@ -58,6 +59,7 @@ export default function AccountProfileForm({ values, handlers, user, settings, o
handleStatusType,
handleBio,
handleCustomFields,
handleNickname,
} = handlers;

const previousEmail = getUserEmailAddress(user);
Expand Down Expand Up @@ -136,6 +138,9 @@ export default function AccountProfileForm({ values, handlers, user, settings, o
<Field.Row>
<TextInput error={nameError} disabled={!allowRealNameChange} flexGrow={1} value={realname} onChange={handleRealname}/>
</Field.Row>
{!allowRealNameChange && <Field.Hint>
{t('RealName_Change_Disabled')}
</Field.Hint>}
<Field.Error>
{nameError}
</Field.Error>
Expand All @@ -145,6 +150,9 @@ export default function AccountProfileForm({ values, handlers, user, settings, o
<Field.Row>
<TextInput error={usernameError} disabled={!canChangeUsername} flexGrow={1} value={username} onChange={handleUsername} addon={<Icon name='at' size='x20'/>}/>
</Field.Row>
{!canChangeUsername && <Field.Hint>
{t('Username_Change_Disabled')}
</Field.Hint>}
<Field.Error>
{usernameError}
</Field.Error>
Expand All @@ -155,10 +163,19 @@ export default function AccountProfileForm({ values, handlers, user, settings, o
<Field.Row>
<TextInput error={statusTextError} disabled={!allowUserStatusMessageChange} flexGrow={1} value={statusText} onChange={handleStatusText} addon={<UserStatusMenu margin='neg-x2' onChange={handleStatusType} initialStatus={statusType}/>}/>
</Field.Row>
{!allowUserStatusMessageChange && <Field.Hint>
{t('StatusMessage_Change_Disabled')}
</Field.Hint>}
<Field.Error>
{statusTextError}
</Field.Error>
</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>
<Field.Label>{t('Bio')}</Field.Label>
<Field.Row>
Expand All @@ -183,6 +200,9 @@ export default function AccountProfileForm({ values, handlers, user, settings, o
disabled={!allowEmailChange}
/>
</Field.Row>
{!allowEmailChange && <Field.Hint>
{t('Email_Change_Disabled')}
</Field.Hint>}
<Field.Error>
{t(emailError)}
</Field.Error>
Expand All @@ -203,6 +223,9 @@ export default function AccountProfileForm({ values, handlers, user, settings, o
<Field.Row>
<PasswordInput autoComplete='off' disabled={!allowPasswordChange} error={passwordError} flexGrow={1} value={password} onChange={handlePassword} addon={<Icon name='key' size='x20'/>}/>
</Field.Row>
{!allowPasswordChange && <Field.Hint>
{t('Password_Change_Disabled')}
</Field.Hint>}
</Field>, [t, password, handlePassword, passwordError, allowPasswordChange])}
{useMemo(() => <Field>
<AnimatedVisibility visibility={password ? AnimatedVisibility.VISIBLE : AnimatedVisibility.HIDDEN }>
Expand Down
8 changes: 7 additions & 1 deletion client/account/AccountProfilePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const getInitialValues = (user) => ({
statusType: user.status ?? '',
bio: user.bio ?? '',
customFields: user.customFields ?? {},
nickname: user.nickname ?? '',
});

const AccountProfilePage = () => {
Expand All @@ -62,7 +63,7 @@ const AccountProfilePage = () => {

const user = useUser();

const { values, handlers, hasUnsavedChanges } = useForm(getInitialValues(user));
const { values, handlers, hasUnsavedChanges, commit } = useForm(getInitialValues(user));
const [canSave, setCanSave] = useState(true);
const setModal = useSetModal();
const [loggingOut, setLoggingOut] = useState(false);
Expand Down Expand Up @@ -124,6 +125,7 @@ const AccountProfilePage = () => {
statusType,
customFields,
bio,
nickname,
} = values;

const { handleAvatar } = handlers;
Expand All @@ -143,8 +145,10 @@ const AccountProfilePage = () => {
...allowUserStatusMessageChange && { statusText },
...typedPassword && { typedPassword: SHA256(typedPassword) },
statusType,
nickname,
bio: bio || '',
}, customFields);
commit();
dispatchToastMessage({ type: 'success', message: t('Profile_saved_successfully') });
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
Expand Down Expand Up @@ -185,6 +189,8 @@ const AccountProfilePage = () => {
customFields,
statusType,
setModal,
commit,
nickname,
]);

const handleLogoutOtherLocations = useCallback(async () => {
Expand Down
2 changes: 2 additions & 0 deletions client/admin/users/UserInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function UserInfoWithData({ uid, username, ...props }) {
bio,
utcOffset,
lastLogin,
nickname,
} = user;
return {
name: showRealNames ? name : username,
Expand All @@ -48,6 +49,7 @@ export function UserInfoWithData({ uid, username, ...props }) {
createdAt: user.createdAt,
status: UserStatus.getStatus(status),
customStatus: statusText,
nickname,
};
}, [data, showRealNames]);

Expand Down
2 changes: 2 additions & 0 deletions client/channel/UserCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const UserCardWithData = ({ username, onClose, target, open, rid }) => {
statusText = status,
bio = defaultValue,
utcOffset = defaultValue,
nickname,
} = user;

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

Expand Down
2 changes: 2 additions & 0 deletions client/channel/UserInfo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const UserInfoWithData = React.memo(function UserInfoWithData({ uid, user
bio,
utcOffset,
lastLogin,
nickname,
} = user;
return {
name: showRealNames ? name : username,
Expand All @@ -55,6 +56,7 @@ export const UserInfoWithData = React.memo(function UserInfoWithData({ uid, user
// localTime: <LocalTime offset={utcOffset} />,
status: UserStatus.getStatus(status),
customStatus: statusText,
nickname,
};
}, [data, showRealNames]);

Expand Down
8 changes: 5 additions & 3 deletions client/components/basic/UserCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const Role = ({ children }) => <Tag
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(({
className,
style,
Expand All @@ -69,8 +69,9 @@ const UserCard = forwardRef(({
actions,
localTime = <Skeleton width='100%'/>,
onClose,
nickname,
t = (e) => e,
}, ref) => <UserCardConteiner className={className} ref={ref} style={style}>
}, ref) => <UserCardContainer className={className} ref={ref} style={style}>
<Box>
<UserAvatar username={username} size='x124'/>
{ actions && <Box flexGrow={0} display='flex' mb='x8' align='center' justifyContent='center'>
Expand All @@ -79,14 +80,15 @@ const UserCard = forwardRef(({
</Box>
<Box display='flex' flexDirection='column' flexGrow={1} flexShrink={1} mis='x24' width='1px'>
<Username status={status} name={name}/>
{nickname && <Info title={t('Nickname')}>{nickname}</Info>}
{ customStatus && <Info>{customStatus}</Info> }
<Roles>{roles}</Roles>
<Info>{localTime}</Info>
{ bio && <Info withTruncatedText={false} style={clampStyle} height='x60'>{bio}</Info> }
{open && <a onClick={open}>{t('See_full_profile')}</a>}
</Box>
{onClose && <Box><ActionButton icon='cross' onClick={onClose}/></Box>}
</UserCardConteiner>);
</UserCardContainer>);


export default UserCard;
Expand Down
12 changes: 9 additions & 3 deletions client/components/basic/UserInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const UserInfo = React.memo(function UserInfo({
customFields = [],
name,
data,
nickname,
// onChange,
actions,
...props
Expand Down Expand Up @@ -68,6 +69,11 @@ export const UserInfo = React.memo(function UserInfo({
<Info>{name}</Info>
</>}

{nickname && <>
<Label>{t('Nickname')}</Label>
<Info>{nickname}</Info>
</>}

{bio && <>
<Label>{t('Bio')}</Label>
<Info withTruncatedText={false}><MarkdownText content={bio}/></Info>
Expand All @@ -89,9 +95,9 @@ export const UserInfo = React.memo(function UserInfo({
</Info>
</>}

{ customFields && customFields.map((customField) => <React.Fragment key={customField.label}>
<Label>{t(customField.label)}</Label>
<Info>{customField.value}</Info>
{ customFields && Object.entries(customFields).map(([label, value]) => <React.Fragment key={label}>
<Label>{t(label)}</Label>
<Info>{value}</Info>
</React.Fragment>) }

<Label>{t('Created_at')}</Label>
Expand Down