Skip to content

Commit 82f1fe4

Browse files
committed
Do not render section for empty accounts
1 parent 5751671 commit 82f1fe4

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

packages/ui/src/components/UserProfile/ConnectedAccountsSection.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ export const ConnectedAccountsSection = withCardStateProvider(
6767
...user.unverifiedExternalAccounts.filter(a => a.verification?.error),
6868
];
6969

70+
if (accounts.length === 0) {
71+
return null;
72+
}
73+
7074
return (
7175
<ProfileSection.Root
7276
title={localizationKeys('userProfile.start.connectedAccountsSection.title')}

packages/ui/src/components/UserProfile/EnterpriseAccountsSection.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
EnterpriseAccountConnectionResource,
66
EnterpriseAccountResource,
77
OAuthProvider,
8+
SamlIdpSlug,
89
} from '@clerk/shared/types';
910
import { Fragment, useState } from 'react';
1011

@@ -56,7 +57,10 @@ const EnterpriseConnectMenuButton = (props: { connection: EnterpriseAccountConne
5657
});
5758
};
5859

59-
const providerWithoutPrefix = connection?.name;
60+
const providerWithoutPrefix = connection.provider.replace(/(oauth_|saml_)/, '').trim() as OAuthProvider;
61+
const providerIconElementId = (connection.protocol === 'saml' ? connection.provider : providerWithoutPrefix) as
62+
| OAuthProvider
63+
| SamlIdpSlug;
6064

6165
return (
6266
<ProfileSection.ActionMenuItem
@@ -84,7 +88,7 @@ const EnterpriseConnectMenuButton = (props: { connection: EnterpriseAccountConne
8488
isDisabled={card.isLoading}
8589
alt={`Connect ${connection.name} account`}
8690
elementDescriptor={descriptors.providerIcon}
87-
elementId={descriptors.providerIcon.setId(providerWithoutPrefix)}
91+
elementId={descriptors.providerIcon.setId(providerIconElementId)}
8892
/>
8993
}
9094
/>

0 commit comments

Comments
 (0)