Skip to content

Commit 4f57fd7

Browse files
committed
Integrate with orgs in-app prompt
1 parent ac53c53 commit 4f57fd7

3 files changed

Lines changed: 27 additions & 11 deletions

File tree

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

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,29 +1462,43 @@ export class Clerk implements ClerkInterface {
14621462
* @param props Configuration parameters.
14631463
*/
14641464
public mountConfigureSSO = (node: HTMLDivElement, props?: ConfigureSSOProps) => {
1465-
if (disabledSelfServeSSOFeature(this, this.environment)) {
1465+
const { isEnabled: isOrganizationsEnabled } = this.__internal_attemptToEnableEnvironmentSetting({
1466+
for: 'organizations',
1467+
caller: 'ConfigureSSO',
1468+
onClose: () => {
1469+
throw new ClerkRuntimeError(warnings.cannotRenderAnyOrganizationComponent('ConfigureSSO'), {
1470+
code: CANNOT_RENDER_ORGANIZATIONS_DISABLED_ERROR_CODE,
1471+
});
1472+
},
1473+
});
1474+
1475+
if (!isOrganizationsEnabled) {
1476+
return;
1477+
}
1478+
1479+
const userExists = !noUserExists(this);
1480+
if (noOrganizationExists(this) && userExists) {
14661481
if (this.#instanceType === 'development') {
1467-
throw new ClerkRuntimeError(warnings.cannotRenderConfigureSSOComponentWhenDisabled, {
1468-
code: CANNOT_RENDER_SELF_SERVE_SSO_DISABLED_ERROR_CODE,
1482+
throw new ClerkRuntimeError(warnings.cannotRenderComponentWhenOrgDoesNotExist, {
1483+
code: CANNOT_RENDER_ORGANIZATION_MISSING_ERROR_CODE,
14691484
});
14701485
}
14711486
return;
14721487
}
14731488

1474-
if (disabledEmailAddressAttribute(this, this.environment)) {
1489+
if (disabledSelfServeSSOFeature(this, this.environment)) {
14751490
if (this.#instanceType === 'development') {
1476-
throw new ClerkRuntimeError(warnings.cannotRenderConfigureSSOComponentWhenEmailAddressDisabled, {
1477-
code: CANNOT_RENDER_CONFIGURE_SSO_EMAIL_ADDRESS_DISABLED_ERROR_CODE,
1491+
throw new ClerkRuntimeError(warnings.cannotRenderConfigureSSOComponentWhenDisabled, {
1492+
code: CANNOT_RENDER_SELF_SERVE_SSO_DISABLED_ERROR_CODE,
14781493
});
14791494
}
14801495
return;
14811496
}
14821497

1483-
const userExists = !noUserExists(this);
1484-
if (noOrganizationExists(this) && userExists) {
1498+
if (disabledEmailAddressAttribute(this, this.environment)) {
14851499
if (this.#instanceType === 'development') {
1486-
throw new ClerkRuntimeError(warnings.cannotRenderComponentWhenOrgDoesNotExist, {
1487-
code: CANNOT_RENDER_ORGANIZATION_MISSING_ERROR_CODE,
1500+
throw new ClerkRuntimeError(warnings.cannotRenderConfigureSSOComponentWhenEmailAddressDisabled, {
1501+
code: CANNOT_RENDER_CONFIGURE_SSO_EMAIL_ADDRESS_DISABLED_ERROR_CODE,
14881502
});
14891503
}
14901504
return;

packages/shared/src/internal/clerk-js/warnings.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const createMessageForDisabledOrganizations = (
1010
| 'OrganizationSwitcher'
1111
| 'OrganizationList'
1212
| 'CreateOrganization'
13-
| 'TaskChooseOrganization',
13+
| 'TaskChooseOrganization'
14+
| 'ConfigureSSO',
1415
) => {
1516
return formatWarning(
1617
`The <${componentName}/> cannot be rendered when the feature is turned off. Visit 'dashboard.clerk.com' to enable the feature. Since the feature is turned off, this is no-op.`,

packages/shared/src/types/clerk.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,6 +1644,7 @@ export type __internal_AttemptToEnableEnvironmentSettingParams = {
16441644
| 'OrganizationList'
16451645
| 'CreateOrganization'
16461646
| 'TaskChooseOrganization'
1647+
| 'ConfigureSSO'
16471648
| 'useOrganizationList'
16481649
| 'useOrganization';
16491650
onClose?: () => void;

0 commit comments

Comments
 (0)