fix:Account Management Status - #1769
Conversation
WalkthroughUpdated AccountManagement.jsx to display WeChat and Telegram binding info via a unified renderAccountInfo helper with optional chaining. Shows truncated IDs with a popover when present, otherwise 未绑定. Adjusted button logic to reflect presence of IDs and feature enablement via status flags. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant U as User
participant C as AccountManagement.jsx
participant H as renderAccountInfo()
participant P as Popover
U->>C: Open Account Management
C->>C: Read userState.user?.wechat_id / telegram_id
alt ID present
C->>H: renderAccountInfo(id, label)
H-->>C: Truncated ID + label
C->>P: Wrap with hover popover
P-->>U: Show full label on hover
else No ID
C-->>U: Display 未绑定
end
U->>C: Click Bind/Modify
alt WeChat enabled (status.wechat_login)
C-->>U: Show Bind or Modify action
else Not enabled
C-->>U: Show 未启用
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Pre-merge checks (3 passed)✅ Passed checks (3 passed)
Poem
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
web/src/components/settings/personal/cards/AccountManagement.jsx (3)
223-226: Bug: buttons disabled when ID is undefined (GitHub).
userState.user.github_id !== ''evaluates true forundefined, wrongly disabling the button. Use truthiness with optional chaining.- disabled={ - (userState.user && userState.user.github_id !== '') || - !status.github_oauth - } + disabled={ + !!userState.user?.github_id || !status.github_oauth + }
268-270: Same bug pattern here (OIDC).Undefined
oidc_idleads to a disabled button. Align with truthiness check.- disabled={ - (userState.user && userState.user.oidc_id !== '') || - !status.oidc_enabled - } + disabled={ + !!userState.user?.oidc_id || !status.oidc_enabled + }
354-356: Same bug pattern here (LinuxDO).Fix the disable logic to avoid treating undefined as bound.
- disabled={ - (userState.user && userState.user.linux_do_id !== '') || - !status.linuxdo_oauth - } + disabled={ + !!userState.user?.linux_do_id || !status.linuxdo_oauth + }
🧹 Nitpick comments (3)
web/src/components/settings/personal/cards/AccountManagement.jsx (3)
183-188: Simplify the ternary; drop redundant check.
userState.user && userState.user?.wechat_idis redundant. Use a single truthy check for readability.- {userState.user && userState.user?.wechat_id + {userState.user?.wechat_id ? t('修改绑定') : status.wechat_login ? t('绑定') : t('未启用')}
62-86: Optionally show ‘未启用’ when feature is off.Today renderAccountInfo always shows ‘未绑定’. To better align with the WeChat button state, consider allowing a custom empty text or a disabled flag.
- const renderAccountInfo = (accountId, label) => { + const renderAccountInfo = (accountId, label, { emptyText = t('未绑定') } = {}) => { if (!accountId || accountId === '') { - return <span className='text-gray-500'>{t('未绑定')}</span>; + return <span className='text-gray-500'>{emptyText}</span>; }Example usage for WeChat:
{renderAccountInfo(userState.user?.wechat_id, t('微信 ID'), { emptyText: status.wechat_login ? t('未绑定') : t('未启用'), })}
395-403: Prop casing: use readOnly.Semi/React expects
readOnly, notreadonly.- <Input - readonly + <Input + readOnly value={systemToken} onClick={handleSystemTokenClick} size='large' prefix={<IconKey />} />
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
web/src/components/settings/personal/cards/AccountManagement.jsx(3 hunks)
🔇 Additional comments (2)
web/src/components/settings/personal/cards/AccountManagement.jsx (2)
168-171: Good fix: safer access + unified display for WeChat.Optional chaining + renderAccountInfo avoids the “未配置却显示已绑定” confusion and handles undefined cleanly.
302-314: Telegram condition is now robust.Switching to
userState.user?.telegram_idavoids false “已绑定” when the field is undefined.
fix:Account Management Status
修复状态提示,避免出现未配置微信但显示已绑定状态
Summary by CodeRabbit