Repository navigation
Fix third-party binding cards showing incorrect status when disabled #1900
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 1 commit
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 | ||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -59,6 +59,8 @@ const AccountManagement = ({ | |||||||||||||||||||||||||||||||||||||||||||
| setShowChangePasswordModal, | ||||||||||||||||||||||||||||||||||||||||||||
| setShowAccountDeleteModal, | ||||||||||||||||||||||||||||||||||||||||||||
| }) => { | ||||||||||||||||||||||||||||||||||||||||||||
| const wechatEnabled = Boolean(status.wechat_login); | ||||||||||||||||||||||||||||||||||||||||||||
| const isWeChatBound = Boolean(userState.user?.wechat_id); | ||||||||||||||||||||||||||||||||||||||||||||
| const renderAccountInfo = (accountId, label) => { | ||||||||||||||||||||||||||||||||||||||||||||
| if (!accountId || accountId === '') { | ||||||||||||||||||||||||||||||||||||||||||||
| return <span className='text-gray-500'>{t('未绑定')}</span>; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -83,6 +85,27 @@ const AccountManagement = ({ | |||||||||||||||||||||||||||||||||||||||||||
| </Popover> | ||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| const getBindingStatusText = (enabled, bound) => { | ||||||||||||||||||||||||||||||||||||||||||||
| if (!enabled) { | ||||||||||||||||||||||||||||||||||||||||||||
| return t('未启用'); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| return bound ? t('已绑定') : t('未绑定'); | ||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
| const getBindingButtonText = (enabled, bound) => { | ||||||||||||||||||||||||||||||||||||||||||||
| if (bound) { | ||||||||||||||||||||||||||||||||||||||||||||
| return t('修改绑定'); | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| return enabled ? t('绑定') : t('未启用'); | ||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+99
to
+105
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. Button label should also prioritize “未启用”. Avoid showing “修改绑定/绑定” when disabled. - const getBindingButtonText = (enabled, bound) => {
- if (bound) {
- return t('修改绑定');
- }
- return enabled ? t('绑定') : t('未启用');
- };
+ const getBindingButtonText = (enabled, bound) => {
+ if (!enabled) return t('未启用');
+ return bound ? t('修改绑定') : t('绑定');
+ };📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||
| const renderProviderBinding = (enabled, accountId, label) => { | ||||||||||||||||||||||||||||||||||||||||||||
| if (!enabled) { | ||||||||||||||||||||||||||||||||||||||||||||
| return <span className='text-gray-500'>{t('未启用')}</span>; | ||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||
| return renderAccountInfo(accountId, label); | ||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+106
to
+118
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. renderProviderBinding should show “未启用” even if bound. Current check renders the account ID when disabled; flip the order. const renderProviderBinding = (enabled, accountId, label) => {
const hasAccountId = Boolean(accountId && accountId !== '');
-
- if (hasAccountId) {
- return renderAccountInfo(accountId, label);
- }
-
- if (!enabled) {
- return <span className='text-gray-500'>{t('未启用')}</span>;
- }
-
- return renderAccountInfo(accountId, label);
+ if (!enabled) {
+ return <span className='text-gray-500'>{t('未启用')}</span>;
+ }
+ return renderAccountInfo(accountId, label);
};📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||
| <Card className='!rounded-2xl'> | ||||||||||||||||||||||||||||||||||||||||||||
| {/* 卡片头部 */} | ||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -165,9 +188,7 @@ const AccountManagement = ({ | |||||||||||||||||||||||||||||||||||||||||||
| {t('微信')} | ||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||
| <div className='text-sm text-gray-500 truncate'> | ||||||||||||||||||||||||||||||||||||||||||||
| {userState.user && userState.user.wechat_id !== '' | ||||||||||||||||||||||||||||||||||||||||||||
| ? t('已绑定') | ||||||||||||||||||||||||||||||||||||||||||||
| : t('未绑定')} | ||||||||||||||||||||||||||||||||||||||||||||
| {getBindingStatusText(wechatEnabled, isWeChatBound)} | ||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -176,14 +197,10 @@ const AccountManagement = ({ | |||||||||||||||||||||||||||||||||||||||||||
| type='primary' | ||||||||||||||||||||||||||||||||||||||||||||
| theme='outline' | ||||||||||||||||||||||||||||||||||||||||||||
| size='small' | ||||||||||||||||||||||||||||||||||||||||||||
| disabled={!status.wechat_login} | ||||||||||||||||||||||||||||||||||||||||||||
| disabled={!wechatEnabled} | ||||||||||||||||||||||||||||||||||||||||||||
| onClick={() => setShowWeChatBindModal(true)} | ||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||
| {userState.user && userState.user.wechat_id !== '' | ||||||||||||||||||||||||||||||||||||||||||||
| ? t('修改绑定') | ||||||||||||||||||||||||||||||||||||||||||||
| : status.wechat_login | ||||||||||||||||||||||||||||||||||||||||||||
| ? t('绑定') | ||||||||||||||||||||||||||||||||||||||||||||
| : t('未启用')} | ||||||||||||||||||||||||||||||||||||||||||||
| {getBindingButtonText(wechatEnabled, isWeChatBound)} | ||||||||||||||||||||||||||||||||||||||||||||
| </Button> | ||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -204,7 +221,8 @@ const AccountManagement = ({ | |||||||||||||||||||||||||||||||||||||||||||
| {t('GitHub')} | ||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||
| <div className='text-sm text-gray-500 truncate'> | ||||||||||||||||||||||||||||||||||||||||||||
| {renderAccountInfo( | ||||||||||||||||||||||||||||||||||||||||||||
| {renderProviderBinding( | ||||||||||||||||||||||||||||||||||||||||||||
| status.github_oauth, | ||||||||||||||||||||||||||||||||||||||||||||
| userState.user?.github_id, | ||||||||||||||||||||||||||||||||||||||||||||
| t('GitHub ID'), | ||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+234
to
238
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. Guard against undefined IDs in button disable logic (GitHub). Elsewhere you compare to Apply inline change near the button: - disabled={
- (userState.user && userState.user.github_id !== '') ||
- !status.github_oauth
- }
+ disabled={Boolean(userState.user?.github_id) || !status.github_oauth}
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -245,7 +263,8 @@ const AccountManagement = ({ | |||||||||||||||||||||||||||||||||||||||||||
| {t('OIDC')} | ||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||
| <div className='text-sm text-gray-500 truncate'> | ||||||||||||||||||||||||||||||||||||||||||||
| {renderAccountInfo( | ||||||||||||||||||||||||||||||||||||||||||||
| {renderProviderBinding( | ||||||||||||||||||||||||||||||||||||||||||||
| status.oidc_enabled, | ||||||||||||||||||||||||||||||||||||||||||||
| userState.user?.oidc_id, | ||||||||||||||||||||||||||||||||||||||||||||
| t('OIDC ID'), | ||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+276
to
280
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. Same undefined check for OIDC button. - disabled={
- (userState.user && userState.user.oidc_id !== '') ||
- !status.oidc_enabled
- }
+ disabled={Boolean(userState.user?.oidc_id) || !status.oidc_enabled}
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -289,7 +308,8 @@ const AccountManagement = ({ | |||||||||||||||||||||||||||||||||||||||||||
| {t('Telegram')} | ||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||
| <div className='text-sm text-gray-500 truncate'> | ||||||||||||||||||||||||||||||||||||||||||||
| {renderAccountInfo( | ||||||||||||||||||||||||||||||||||||||||||||
| {renderProviderBinding( | ||||||||||||||||||||||||||||||||||||||||||||
| status.telegram_oauth, | ||||||||||||||||||||||||||||||||||||||||||||
| userState.user?.telegram_id, | ||||||||||||||||||||||||||||||||||||||||||||
| t('Telegram ID'), | ||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||
|
RedwindA marked this conversation as resolved.
Resolved
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -334,7 +354,8 @@ const AccountManagement = ({ | |||||||||||||||||||||||||||||||||||||||||||
| {t('LinuxDO')} | ||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||
| <div className='text-sm text-gray-500 truncate'> | ||||||||||||||||||||||||||||||||||||||||||||
| {renderAccountInfo( | ||||||||||||||||||||||||||||||||||||||||||||
| {renderProviderBinding( | ||||||||||||||||||||||||||||||||||||||||||||
| status.linuxdo_oauth, | ||||||||||||||||||||||||||||||||||||||||||||
| userState.user?.linux_do_id, | ||||||||||||||||||||||||||||||||||||||||||||
| t('LinuxDO ID'), | ||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||
|
RedwindA marked this conversation as resolved.
Resolved
|
||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||
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.
Make “未启用” take precedence in status text.
When a provider is disabled, show “未启用” even if the user had bound previously (matches PR intent).
Apply:
📝 Committable suggestion
🤖 Prompt for AI Agents