0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-02-24 22:05:56 -05:00

fix(console): remove "change" button from link social in profile (#3341)

This commit is contained in:
Charles Zhao 2023-03-09 12:59:15 +08:00 committed by GitHub
parent 310c543f93
commit ae65feb642
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -21,7 +21,7 @@ import type { SocialUserInfo } from '@/types/profile';
import { socialUserInfoGuard } from '@/types/profile'; import { socialUserInfoGuard } from '@/types/profile';
import { popupWindow } from '../../utils'; import { popupWindow } from '../../utils';
import type { Action, Row } from '../CardContent'; import type { Row } from '../CardContent';
import CardContent from '../CardContent'; import CardContent from '../CardContent';
import NotSet from '../NotSet'; import NotSet from '../NotSet';
import * as styles from './index.module.scss'; import * as styles from './index.module.scss';
@ -64,9 +64,15 @@ const LinkAccountSection = ({ user, connectors, onUpdate }: Props) => {
const logoSrc = theme === AppearanceMode.DarkMode && logoDark ? logoDark : logo; const logoSrc = theme === AppearanceMode.DarkMode && logoDark ? logoDark : logo;
const relatedUserDetails = user.identities?.[target]?.details; const relatedUserDetails = user.identities?.[target]?.details;
const hasLinked = is(relatedUserDetails, socialUserInfoGuard); const hasLinked = is(relatedUserDetails, socialUserInfoGuard);
const conditionalUnlinkAction: Action[] = hasLinked
? [ return {
{ key: target,
icon: <ImageWithErrorFallback src={logoSrc} />,
label: <UnnamedTrans resource={name} />,
value: conditional(hasLinked && relatedUserDetails),
renderer: (user) => (user ? <UserInfoCard user={user} avatarSize="small" /> : <NotSet />),
action: hasLinked
? {
name: 'profile.unlink', name: 'profile.unlink',
handler: async () => { handler: async () => {
const [result] = await showConfirm({ const [result] = await showConfirm({
@ -83,20 +89,9 @@ const LinkAccountSection = ({ user, connectors, onUpdate }: Props) => {
onUpdate(); onUpdate();
} }
}, },
}, }
] : {
: []; name: 'profile.link',
return {
key: target,
icon: <ImageWithErrorFallback src={logoSrc} />,
label: <UnnamedTrans resource={name} />,
value: conditional(hasLinked && relatedUserDetails),
renderer: (user) => (user ? <UserInfoCard user={user} avatarSize="small" /> : <NotSet />),
action: [
...conditionalUnlinkAction,
{
name: hasLinked ? 'profile.change' : 'profile.link',
handler: async () => { handler: async () => {
const authUri = await getSocialAuthorizationUri(id); const authUri = await getSocialAuthorizationUri(id);
const callback = new URL( const callback = new URL(
@ -120,7 +115,6 @@ const LinkAccountSection = ({ user, connectors, onUpdate }: Props) => {
newWindow?.focus(); newWindow?.focus();
}, },
}, },
],
}; };
}); });
}, [ }, [