From 48f3e333256b32b1351179e43a718b9d6777fd5e Mon Sep 17 00:00:00 2001 From: rique223 Date: Mon, 16 Oct 2023 17:13:05 -0300 Subject: [PATCH] refactor: :recycle: Ensure requirePasswordChange is true when setRandomPassword is true Created some logic to make sure the requirePasswordChange field will be true even if the user changed it to false and then changed setRandomPassword to true. Also changed some strings and sizes to follow figma specs. --- .../client/views/admin/users/AdminUserForm.tsx | 12 +++++++++--- .../packages/rocketchat-i18n/i18n/en.i18n.json | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/apps/meteor/client/views/admin/users/AdminUserForm.tsx b/apps/meteor/client/views/admin/users/AdminUserForm.tsx index f6e5867bf20e..5b576bba65b1 100644 --- a/apps/meteor/client/views/admin/users/AdminUserForm.tsx +++ b/apps/meteor/client/views/admin/users/AdminUserForm.tsx @@ -107,6 +107,8 @@ const UserForm = ({ userData, onReload, setCreatedUsersCount, ...props }: AdminU mode: 'onBlur', }); + const { avatar, username, setRandomPassword, password } = watch(); + useEffect(() => { resetField('sendWelcomeEmail', { defaultValue: isSmtpEnabled }); // eslint-disable-next-line react-hooks/exhaustive-deps @@ -117,6 +119,12 @@ const UserForm = ({ userData, onReload, setCreatedUsersCount, ...props }: AdminU // eslint-disable-next-line react-hooks/exhaustive-deps }, [isSmtpEnabled, userData?._id]); + useEffect(() => { + resetField('requirePasswordChange', { defaultValue: setRandomPassword }); + + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [setRandomPassword]); + const eventStats = useEndpointAction('POST', '/v1/statistics.telemetry'); const updateUserAction = useEndpoint('POST', '/v1/users.update'); const createUserAction = useEndpoint('POST', '/v1/users.create'); @@ -126,8 +134,6 @@ const UserForm = ({ userData, onReload, setCreatedUsersCount, ...props }: AdminU const availableRoles: SelectOption[] = roleData?.roles.map(({ _id, name, description }) => [_id, description || name]) || []; - const { avatar, username, setRandomPassword, password } = watch(); - const updateAvatar = useUpdateAvatar(avatar, userData?._id || ''); const handleUpdateUser = useMutation({ @@ -238,7 +244,7 @@ const UserForm = ({ userData, onReload, setCreatedUsersCount, ...props }: AdminU {t('Mark_email_as_verified')} - + accounts settings to enable.", + "Email_verification_isnt_required": "Email verification to login is not required. To require, enable setting in Accounts > Registration", "Emoji": "Emoji", "Emoji_picker": "Emoji picker", "EmojiCustomFilesystem": "Custom Emoji Filesystem", @@ -3292,7 +3292,7 @@ "Managing_assets": "Managing assets", "Managing_integrations": "Managing integrations", "Manual_Selection": "Manual Selection", - "Manually_created_users_briefing": "Manually created users will initially be listed under the 'Pending' tab. Once they log in for the first time, they will be moved to the 'Active' tab.", + "Manually_created_users_briefing": "Manually created users will initially be shown as pending. Once they log in for the first time, they will be shown as active.", "Manufacturing": "Manufacturing", "MapView_Enabled": "Enable Mapview", "MapView_Enabled_Description": "Enabling mapview will display a location share button on the right of the chat input field.",