@@ -23,6 +23,7 @@ import type {
2323 __experimental_CheckoutInstance ,
2424 __experimental_CheckoutOptions ,
2525 __internal_AttemptToEnableEnvironmentSettingParams ,
26+ __internal_AttemptToEnableEnvironmentSettingResult ,
2627 __internal_CheckoutProps ,
2728 __internal_EnableOrganizationsPromptProps ,
2829 __internal_OAuthConsentProps ,
@@ -749,7 +750,7 @@ export class Clerk implements ClerkInterface {
749750
750751 public __internal_attemptToEnableEnvironmentSetting = (
751752 params : __internal_AttemptToEnableEnvironmentSettingParams ,
752- ) : { status : 'enabled' | 'prompt-shown' } => {
753+ ) : __internal_AttemptToEnableEnvironmentSettingResult => {
753754 const { for : setting , caller } = params ;
754755
755756 if ( ! this . user ) {
@@ -758,30 +759,28 @@ export class Clerk implements ClerkInterface {
758759 ) ;
759760 }
760761
761- if (
762- // If not in development instance, return enabled status in order to not open the prompt
763- this . #instanceType !== 'development'
764- ) {
765- return { status : 'enabled' } ;
766- }
767-
768762 switch ( setting ) {
769- case 'organizations' :
770- if ( ! disabledOrganizationsFeature ( this , this . environment ) ) {
771- return { status : 'enabled' } ;
763+ case 'organizations' : {
764+ const isSettingDisabled = disabledOrganizationsFeature ( this , this . environment ) ;
765+
766+ if ( ! isSettingDisabled ) {
767+ return { isEnabled : true } ;
772768 }
773769
774- this . __internal_openEnableOrganizationsPrompt ( {
775- caller,
776- // Reload current window to all invalidate all resources
777- // related to organizations, eg: roles
778- onSuccess : ( ) => window . location . reload ( ) ,
779- onClose : params . onClose ,
780- } as __internal_EnableOrganizationsPromptProps ) ;
770+ if ( this . #instanceType === 'development' ) {
771+ this . __internal_openEnableOrganizationsPrompt ( {
772+ caller,
773+ // Reload current window to all invalidate all resources
774+ // related to organizations, eg: roles
775+ onSuccess : ( ) => window . location . reload ( ) ,
776+ onClose : params . onClose ,
777+ } as __internal_EnableOrganizationsPromptProps ) ;
778+ }
781779
782- return { status : 'prompt-shown' } ;
780+ return { isEnabled : false } ;
781+ }
783782 default :
784- return { status : 'enabled' } ;
783+ return { isEnabled : true } ;
785784 }
786785 } ;
787786
@@ -871,7 +870,7 @@ export class Clerk implements ClerkInterface {
871870 public openOrganizationProfile = ( props ?: OrganizationProfileProps ) : void => {
872871 this . assertComponentsReady ( this . #componentControls) ;
873872
874- const { status } = this . __internal_attemptToEnableEnvironmentSetting ( {
873+ const { isEnabled : isOrganizationsEnabled } = this . __internal_attemptToEnableEnvironmentSetting ( {
875874 for : 'organizations' ,
876875 caller : 'OrganizationProfile' ,
877876 onClose : ( ) => {
@@ -881,7 +880,7 @@ export class Clerk implements ClerkInterface {
881880 } ,
882881 } ) ;
883882
884- if ( status === 'prompt-shown' ) {
883+ if ( ! isOrganizationsEnabled ) {
885884 return ;
886885 }
887886
@@ -908,7 +907,7 @@ export class Clerk implements ClerkInterface {
908907 public openCreateOrganization = ( props ?: CreateOrganizationProps ) : void => {
909908 this . assertComponentsReady ( this . #componentControls) ;
910909
911- const { status } = this . __internal_attemptToEnableEnvironmentSetting ( {
910+ const { isEnabled : isOrganizationsEnabled } = this . __internal_attemptToEnableEnvironmentSetting ( {
912911 for : 'organizations' ,
913912 caller : 'CreateOrganization' ,
914913 onClose : ( ) => {
@@ -918,7 +917,7 @@ export class Clerk implements ClerkInterface {
918917 } ,
919918 } ) ;
920919
921- if ( status === 'prompt-shown' ) {
920+ if ( ! isOrganizationsEnabled ) {
922921 return ;
923922 }
924923
@@ -1057,7 +1056,7 @@ export class Clerk implements ClerkInterface {
10571056 public mountOrganizationProfile = ( node : HTMLDivElement , props ?: OrganizationProfileProps ) => {
10581057 this . assertComponentsReady ( this . #componentControls) ;
10591058
1060- const { status } = this . __internal_attemptToEnableEnvironmentSetting ( {
1059+ const { isEnabled : isOrganizationsEnabled } = this . __internal_attemptToEnableEnvironmentSetting ( {
10611060 for : 'organizations' ,
10621061 caller : 'OrganizationProfile' ,
10631062 onClose : ( ) => {
@@ -1067,7 +1066,7 @@ export class Clerk implements ClerkInterface {
10671066 } ,
10681067 } ) ;
10691068
1070- if ( status === 'prompt-shown' ) {
1069+ if ( ! isOrganizationsEnabled ) {
10711070 return ;
10721071 }
10731072
@@ -1104,7 +1103,7 @@ export class Clerk implements ClerkInterface {
11041103 public mountCreateOrganization = ( node : HTMLDivElement , props ?: CreateOrganizationProps ) => {
11051104 this . assertComponentsReady ( this . #componentControls) ;
11061105
1107- const { status } = this . __internal_attemptToEnableEnvironmentSetting ( {
1106+ const { isEnabled : isOrganizationsEnabled } = this . __internal_attemptToEnableEnvironmentSetting ( {
11081107 for : 'organizations' ,
11091108 caller : 'CreateOrganization' ,
11101109 onClose : ( ) => {
@@ -1114,7 +1113,7 @@ export class Clerk implements ClerkInterface {
11141113 } ,
11151114 } ) ;
11161115
1117- if ( status === 'prompt-shown' ) {
1116+ if ( ! isOrganizationsEnabled ) {
11181117 return ;
11191118 }
11201119
@@ -1142,7 +1141,7 @@ export class Clerk implements ClerkInterface {
11421141 public mountOrganizationSwitcher = ( node : HTMLDivElement , props ?: OrganizationSwitcherProps ) => {
11431142 this . assertComponentsReady ( this . #componentControls) ;
11441143
1145- const { status } = this . __internal_attemptToEnableEnvironmentSetting ( {
1144+ const { isEnabled : isOrganizationsEnabled } = this . __internal_attemptToEnableEnvironmentSetting ( {
11461145 for : 'organizations' ,
11471146 caller : 'OrganizationSwitcher' ,
11481147 onClose : ( ) => {
@@ -1152,7 +1151,7 @@ export class Clerk implements ClerkInterface {
11521151 } ,
11531152 } ) ;
11541153
1155- if ( status === 'prompt-shown' ) {
1154+ if ( ! isOrganizationsEnabled ) {
11561155 return ;
11571156 }
11581157
@@ -1188,7 +1187,7 @@ export class Clerk implements ClerkInterface {
11881187 public mountOrganizationList = ( node : HTMLDivElement , props ?: OrganizationListProps ) => {
11891188 this . assertComponentsReady ( this . #componentControls) ;
11901189
1191- const { status } = this . __internal_attemptToEnableEnvironmentSetting ( {
1190+ const { isEnabled : isOrganizationsEnabled } = this . __internal_attemptToEnableEnvironmentSetting ( {
11921191 for : 'organizations' ,
11931192 caller : 'OrganizationList' ,
11941193 onClose : ( ) => {
@@ -1198,7 +1197,7 @@ export class Clerk implements ClerkInterface {
11981197 } ,
11991198 } ) ;
12001199
1201- if ( status === 'prompt-shown' ) {
1200+ if ( ! isOrganizationsEnabled ) {
12021201 return ;
12031202 }
12041203
@@ -1390,7 +1389,7 @@ export class Clerk implements ClerkInterface {
13901389 public mountTaskChooseOrganization = ( node : HTMLDivElement , props ?: TaskChooseOrganizationProps ) => {
13911390 this . assertComponentsReady ( this . #componentControls) ;
13921391
1393- const { status } = this . __internal_attemptToEnableEnvironmentSetting ( {
1392+ const { isEnabled : isOrganizationsEnabled } = this . __internal_attemptToEnableEnvironmentSetting ( {
13941393 for : 'organizations' ,
13951394 caller : 'TaskChooseOrganization' ,
13961395 onClose : ( ) => {
@@ -1400,7 +1399,7 @@ export class Clerk implements ClerkInterface {
14001399 } ,
14011400 } ) ;
14021401
1403- if ( status === 'prompt-shown' ) {
1402+ if ( ! isOrganizationsEnabled ) {
14041403 return ;
14051404 }
14061405
0 commit comments