-
Notifications
You must be signed in to change notification settings - Fork 13.7k
refactor(ui-client): remove unnecessary ReactElement type annotations from components #40811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import { AdminInfoPage } from '@rocket.chat/onboarding-ui'; | ||
| import { escapeRegExp } from '@rocket.chat/string-helpers'; | ||
| import { useSetting, useVerifyPassword, usePasswordPolicy, usePasswordPolicyOptions } from '@rocket.chat/ui-contexts'; | ||
| import type { ReactElement, ComponentProps } from 'react'; | ||
| import type { ComponentProps } from 'react'; | ||
| import { useMemo } from 'react'; | ||
| import { I18nextProvider, useTranslation } from 'react-i18next'; | ||
|
|
||
|
|
@@ -12,9 +12,9 @@ const usernameBlackList = ['all', 'here', 'admin'].map(toRegExp); | |
| const hasBlockedName = (username: string): boolean => | ||
| !!usernameBlackList.length && usernameBlackList.some((restrictedUsername) => restrictedUsername.test(escapeRegExp(username).trim())); | ||
|
|
||
| const AdminInfoStep = (): ReactElement => { | ||
| const AdminInfoStep = () => { | ||
| const { t, i18n } = useTranslation(); | ||
| const regexpForUsernameValidation = useSetting('UTF8_User_Names_Validation'); | ||
| const regexpForUsernameValidation = useSetting('UTF8_User_Names_Validation', '[0-9a-zA-Z-_.]+'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check if UTF8_User_Names_Validation setting is guaranteed to exist
rg -n -C3 "UTF8_User_Names_Validation" --type ts --type js -g '!*.spec.*' -g '!*.test.*'Repository: RocketChat/Rocket.Chat Length of output: 7672 🏁 Script executed: #!/bin/bash
set -euo pipefail
# 1) Inspect the relevant part of AdminInfoStep.tsx
echo "=== AdminInfoStep.tsx (context around useSetting) ==="
sed -n '1,120p' packages/ui-client/src/views/setupWizard/steps/AdminInfoStep.tsx
# 2) Find the useSetting hook definition and inspect its signature (to see if fallback is supported/expected)
echo "=== Searching for useSetting implementation/signature ==="
fd -t f -e ts -e tsx -e js -e jsx -e d.ts "useSetting" packages/ui-client/src | head -n 50
# Also search globally for the hook definition
rg -n "function useSetting|const useSetting|export (function|const) useSetting" packages/ui-client/src --hidden
# 3) Check other UI usages of useSetting with a fallback for UTF8_User_Names_Validation
echo "=== Other useSetting('UTF8_User_Names_Validation', ...) usages in ui-client ==="
rg -n "useSetting\('UTF8_User_Names_Validation'" packages/ui-client/src
# 4) If available, compare the setting default on the server side (already partially found, but re-show the exact add)
echo "=== Server setting default for UTF8_User_Names_Validation ==="
rg -n "add\\('UTF8_User_Names_Validation'" apps/meteor/server/settings/general.tsRepository: RocketChat/Rocket.Chat Length of output: 3106 🏁 Script executed: #!/bin/bash
set -uo pipefail
echo "=== Searching for useSetting definition/signature across repo ==="
rg -n --hidden --no-ignore-vcs \
"export (const|function) useSetting|function useSetting|const useSetting" . \
--glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' | head -n 50
echo "=== Searching for useSetting type declaration (d.ts) ==="
fd -e d.ts -e ts -e tsx --hidden useSetting . 2>/dev/null | head -n 50
# Find any d.ts files that mention UTF8_User_Names_Validation defaults/fallback
rg -n --hidden --no-ignore-vcs "useSetting\\(.*UTF8_User_Names_Validation" . \
--glob '!**/node_modules/**' --glob '!**/dist/**' --glob '!**/build/**' | head -n 50Repository: RocketChat/Rocket.Chat Length of output: 3450 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== packages/ui-contexts/src/hooks/useSetting.ts ==="
sed -n '1,200p' packages/ui-contexts/src/hooks/useSetting.ts
echo "=== Server default for UTF8_User_Names_Validation ==="
sed -n '240,310p' apps/meteor/server/settings/general.ts
echo "=== Server validateUsername fallback behavior ==="
sed -n '1,120p' apps/meteor/app/lib/server/functions/validateUsername.ts
echo "=== Other ui-client usages of fallback for UTF8_User_Names_Validation ==="
for f in \
apps/meteor/client/views/room/contextualBar/Threads/hooks/useNormalizedThreadTitleHtml.ts \
apps/meteor/client/views/root/hooks/loggedIn/useE2EEncryption.ts \
apps/meteor/client/views/account/profile/useAccountProfileSettings.ts
do
echo "---- $f ----"
sed -n '1,80p' "$f"
doneRepository: RocketChat/Rocket.Chat Length of output: 8885 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== packages/ui-contexts/src/hooks/useSettingStructure.ts ==="
sed -n '1,200p' packages/ui-contexts/src/hooks/useSettingStructure.ts
echo "=== packages/ui-contexts/src/hooks/useSettings.ts ==="
sed -n '1,200p' packages/ui-contexts/src/hooks/useSettings.ts
echo "=== packages/ui-contexts/src/hooks/useSettingSetValue.ts ==="
sed -n '1,120p' packages/ui-contexts/src/hooks/useSettingSetValue.ts
echo "=== Search for SettingsContext default/initial state ==="
rg -n "SettingsContext|createContext" packages/ui-contexts/src --hidden
# show the SettingsContext provider if it exists
fd -t f -e ts -e tsx "SettingsContext" packages/ui-contexts/src --hidden | head -n 20Repository: RocketChat/Rocket.Chat Length of output: 7717 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== packages/ui-contexts/src/SettingsContext.ts ==="
sed -n '1,120p' packages/ui-contexts/src/SettingsContext.ts
echo "=== Inspect SettingsContextValue/querySetting behavior ==="
sed -n '120,260p' packages/ui-contexts/src/SettingsContext.tsRepository: RocketChat/Rocket.Chat Length of output: 1275 🏁 Script executed: #!/bin/bash
# Find any UI usages of UTF8_User_Names_Validation without a fallback
rg -n --hidden "useSetting\\('UTF8_User_Names_Validation'\\)" --type ts --type tsx packages/ui-client/src apps/meteor/client/views -g '!*.spec.*' -g '!*.test.*'Repository: RocketChat/Rocket.Chat Length of output: 94 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== UI usages of useSetting('UTF8_User_Names_Validation') without fallback ==="
rg -n --hidden --no-ignore-vcs \
"useSetting\\(['\"]UTF8_User_Names_Validation['\"]\\)" \
packages/ui-client apps/meteor/client \
-g '!*.spec.*' -g '!*.test.*'
echo "=== UI usages of useSetting('UTF8_User_Names_Validation', ... ) ==="
rg -n --hidden --no-ignore-vcs \
"useSetting\\(['\"]UTF8_User_Names_Validation['\"],\\s*[^\\)]+" \
packages/ui-client apps/meteor/client \
-g '!*.spec.*' -g '!*.test.*'Repository: RocketChat/Rocket.Chat Length of output: 145 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "=== UI usages of useSetting('UTF8_User_Names_Validation') ==="
rg -n --hidden --no-ignore-vcs \
"useSetting\\(['\"]UTF8_User_Names_Validation['\"]\\)" \
packages/ui-client apps/meteor/client \
-g '!*.spec.*' -g '!*.test.*' || true
echo "=== UI usages of useSetting('UTF8_User_Names_Validation', <fallback>) ==="
rg -n --hidden --no-ignore-vcs \
"useSetting\\(['\"]UTF8_User_Names_Validation['\"],\\s*[^\\)]+\\)" \
packages/ui-client apps/meteor/client \
-g '!*.spec.*' -g '!*.test.*' || trueRepository: RocketChat/Rocket.Chat Length of output: 846 Clarify impact of adding
This fallback pattern is already used in other client code ( 🤖 Prompt for AI Agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Adding a fallback value to Prompt for AI agents |
||
| const usernameRegExp = new RegExp(`^${regexpForUsernameValidation}$`); | ||
|
|
||
| const { currentStep, validateEmail, registerAdminUser, maxSteps } = useSetupWizardContext(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2:
childrenwas widened toReactNode, but this component requires an element child forfirstElementChild-based initialization; the new type allows inputs that silently break scrollbar setup.Prompt for AI agents