Skip to content

Commit e2f89fd

Browse files
committed
Add changeset
1 parent 863c90e commit e2f89fd

6 files changed

Lines changed: 19 additions & 101 deletions

File tree

.changeset/large-cameras-talk.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@clerk/localizations': minor
3+
'@clerk/clerk-js': minor
4+
'@clerk/shared': minor
5+
'@clerk/ui': minor
6+
---
7+
8+
Allow to link external accounts to enterprise accounts via `UserProfile`

packages/clerk-js/src/core/resources/User.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ import type {
3535
Web3WalletResource,
3636
} from '@clerk/shared/types';
3737

38-
import { convertPageToOffsetSearchParams } from '@/utils/convertPageToOffsetSearchParams';
39-
4038
import { unixEpochToDate } from '../../utils/date';
4139
import { normalizeUnsafeMetadata } from '../../utils/resourceParams';
4240
import { eventBus, events } from '../events';
@@ -299,11 +297,19 @@ export class User extends BaseResource implements UserResource {
299297
getEnterpriseConnections = async (
300298
params?: GetEnterpriseConnectionsParams,
301299
): Promise<EnterpriseAccountConnectionResource[]> => {
300+
const { withOrganizationAccountLinking } = params || {};
301+
302302
const json = (
303303
await BaseResource._fetch({
304304
path: '/me/enterprise_connections',
305305
method: 'GET',
306-
search: convertPageToOffsetSearchParams(params),
306+
...(withOrganizationAccountLinking !== undefined
307+
? {
308+
search: {
309+
with_organization_account_linking: String(withOrganizationAccountLinking),
310+
},
311+
}
312+
: {}),
307313
})
308314
)?.response as unknown as EnterpriseAccountConnectionJSON[];
309315

packages/localizations/src/en-US.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,15 +1188,6 @@ export const enUS: LocalizationResource = {
11881188
successMessage: 'The provider has been added to your account',
11891189
title: 'Add connected account',
11901190
},
1191-
enterpriseAccountPage: {
1192-
removeResource: {
1193-
messageLine1: '{{identifier}} will be removed from this account.',
1194-
messageLine2:
1195-
'You will no longer be able to use this enterprise account and any dependent features will no longer work.',
1196-
successMessage: '{{enterpriseAccount}} has been removed from your account.',
1197-
title: 'Remove enterprise account',
1198-
},
1199-
},
12001191
deletePage: {
12011192
actionDescription: 'Type "Delete account" below to continue.',
12021193
confirm: 'Delete account',
@@ -1369,7 +1360,6 @@ export const enUS: LocalizationResource = {
13691360
title: 'Email addresses',
13701361
},
13711362
enterpriseAccountsSection: {
1372-
destructiveActionTitle: 'Remove',
13731363
primaryButton: 'Connect account',
13741364
title: 'Enterprise accounts',
13751365
},

packages/shared/src/types/localization.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,6 @@ export type __internal_LocalizationResource = {
684684
enterpriseAccountsSection: {
685685
title: LocalizationValue;
686686
primaryButton: LocalizationValue;
687-
destructiveActionTitle: LocalizationValue;
688687
};
689688
passwordSection: {
690689
title: LocalizationValue;
@@ -821,14 +820,6 @@ export type __internal_LocalizationResource = {
821820
successMessage: LocalizationValue<'connectedAccount'>;
822821
};
823822
};
824-
enterpriseAccountPage: {
825-
removeResource: {
826-
title: LocalizationValue;
827-
messageLine1: LocalizationValue<'identifier'>;
828-
messageLine2: LocalizationValue;
829-
successMessage: LocalizationValue<'enterpriseAccount'>;
830-
};
831-
};
832823
web3WalletPage: {
833824
title: LocalizationValue;
834825
subtitle__availableWallets: LocalizationValue;

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

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,13 @@ import { Fragment, useState } from 'react';
1111
import { Card } from '@/ui/elements/Card';
1212
import { useCardState, withCardStateProvider } from '@/ui/elements/contexts';
1313
import { ProfileSection } from '@/ui/elements/Section';
14-
import { ThreeDotsMenu } from '@/ui/elements/ThreeDotsMenu';
1514
import { handleError } from '@/ui/utils/errorHandler';
1615
import { sleep } from '@/utils/sleep';
1716

1817
import { ProviderIcon } from '../../common';
1918
import { useUserProfileContext } from '../../contexts';
2019
import { Badge, Box, descriptors, Flex, localizationKeys, Text } from '../../customizables';
2120
import { Action } from '../../elements/Action';
22-
import { useActionContext } from '../../elements/Action/ActionRoot';
23-
import type { PropsOfComponent } from '../../styledSystem';
24-
import { RemoveEnterpriseAccountForm } from './RemoveResourceForm';
2521

2622
const EnterpriseConnectMenuButton = (props: { connection: EnterpriseAccountConnectionResource }) => {
2723
const { connection } = props;
@@ -122,18 +118,6 @@ const AddEnterpriseAccount = ({
122118
);
123119
};
124120

125-
type RemoveEnterpriseAccountScreenProps = { accountId: string };
126-
const RemoveEnterpriseAccountScreen = (props: RemoveEnterpriseAccountScreenProps) => {
127-
const { close } = useActionContext();
128-
return (
129-
<RemoveEnterpriseAccountForm
130-
onSuccess={close}
131-
onReset={close}
132-
{...props}
133-
/>
134-
);
135-
};
136-
137121
export const EnterpriseAccountsSection = withCardStateProvider(() => {
138122
const { user } = useUser();
139123
const card = useCardState();
@@ -173,6 +157,7 @@ export const EnterpriseAccountsSection = withCardStateProvider(() => {
173157
/>
174158
))}
175159
</ProfileSection.ItemList>
160+
176161
{linkableEnterpriseConnections.length > 0 && (
177162
<AddEnterpriseAccount
178163
enterpriseConnections={linkableEnterpriseConnections}
@@ -192,13 +177,7 @@ const EnterpriseAccount = ({ account }: { account: EnterpriseAccountResource })
192177

193178
return (
194179
<Fragment key={accountId}>
195-
<ProfileSection.Item
196-
id='enterpriseAccounts'
197-
sx={t => ({
198-
gap: t.space.$2,
199-
justifyContent: 'start',
200-
})}
201-
>
180+
<ProfileSection.Item id='enterpriseAccounts'>
202181
<Flex sx={t => ({ overflow: 'hidden', gap: t.space.$2 })}>
203182
<EnterpriseAccountProviderIcon account={account} />
204183
<Box sx={{ whiteSpace: 'nowrap', overflow: 'hidden' }}>
@@ -228,36 +207,11 @@ const EnterpriseAccount = ({ account }: { account: EnterpriseAccountResource })
228207
</Flex>
229208
</Box>
230209
</Flex>
231-
232-
<EnterpriseAccountMenu account={account} />
233210
</ProfileSection.Item>
234-
235-
<Action.Open value={`remove-${accountId}`}>
236-
<Action.Card variant='destructive'>
237-
<RemoveEnterpriseAccountScreen accountId={accountId} />
238-
</Action.Card>
239-
</Action.Open>
240211
</Fragment>
241212
);
242213
};
243214

244-
const EnterpriseAccountMenu = ({ account }: { account: EnterpriseAccountResource }) => {
245-
const { open } = useActionContext();
246-
const accountId = account.id;
247-
248-
const actions = (
249-
[
250-
{
251-
label: localizationKeys('userProfile.start.enterpriseAccountsSection.destructiveActionTitle'),
252-
isDestructive: true,
253-
onClick: () => open(`remove-${accountId}`),
254-
},
255-
] satisfies (PropsOfComponent<typeof ThreeDotsMenu>['actions'][0] | null)[]
256-
).filter(a => a !== null) as PropsOfComponent<typeof ThreeDotsMenu>['actions'];
257-
258-
return <ThreeDotsMenu actions={actions} />;
259-
};
260-
261215
const EnterpriseAccountProviderIcon = ({ account }: { account: EnterpriseAccountResource }) => {
262216
const { provider, enterpriseConnection } = account;
263217

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

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -220,34 +220,3 @@ export const RemovePasskeyForm = (props: RemovePasskeyFormProps) => {
220220
/>
221221
);
222222
};
223-
224-
type RemoveEnterpriseAccountFormProps = FormProps & {
225-
accountId: string;
226-
};
227-
228-
export const RemoveEnterpriseAccountForm = (props: RemoveEnterpriseAccountFormProps) => {
229-
const { accountId: id, onSuccess, onReset } = props;
230-
const { user } = useUser();
231-
const resource = user?.enterpriseAccounts.find(e => e.id === id);
232-
const ref = React.useRef(resource?.enterpriseConnection?.name || resource?.emailAddress);
233-
234-
if (!ref.current) {
235-
return null;
236-
}
237-
238-
return (
239-
<RemoveResourceForm
240-
title={localizationKeys('userProfile.enterpriseAccountPage.removeResource.title')}
241-
messageLine1={localizationKeys('userProfile.enterpriseAccountPage.removeResource.messageLine1', {
242-
identifier: ref.current,
243-
})}
244-
messageLine2={localizationKeys('userProfile.enterpriseAccountPage.removeResource.messageLine2')}
245-
successMessage={localizationKeys('userProfile.enterpriseAccountPage.removeResource.successMessage', {
246-
enterpriseAccount: ref.current,
247-
})}
248-
deleteResource={() => Promise.resolve(resource?.destroy())}
249-
onSuccess={onSuccess}
250-
onReset={onReset}
251-
/>
252-
);
253-
};

0 commit comments

Comments
 (0)