From 074ba5627847815fbfb00d1dc7b8b328c16fbd86 Mon Sep 17 00:00:00 2001 From: Pavindu Lakshan Date: Tue, 11 Jun 2024 14:58:29 +0530 Subject: [PATCH 1/3] Improve readability in legacy auth flow builder rendering logic --- .../components/sign-on-methods-core.tsx | 102 +++++++++--------- 1 file changed, 54 insertions(+), 48 deletions(-) diff --git a/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx b/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx index be81eaaf553..1a6b423d466 100644 --- a/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx +++ b/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx @@ -899,6 +899,59 @@ export const SignOnMethodsCore: FunctionComponent { + if (isLoading || isAuthenticatorsFetchRequestLoading) { + return ( + + ); + } + + const isDefaultAuthFlow: boolean = isDefaultFlowConfiguration(); + + return ( + !readOnly && !loginFlow && isDefaultAuthFlow ? ( + { + handleLoginFlowSelect( + type, + googleAuthenticators, + gitHubAuthenticators, + facebookAuthenticators, + microsoftAuthenticators, + appleAuthenticators + ); + } } + data-componentid={ `${componentId}-landing` } + /> + ) : ( + void, template: any) => { + setSelectedIDPTemplate(template); + setIDPCreateWizardTriggerOrigin("EXTERNAL"); + setIDPTemplateTypeToTrigger(type); + setShowMissingSocialAuthenticatorModal(false); + setShowIDPCreateWizard(true); + broadcastIDPCreateSuccessMessage = cb; + } } + onUpdate={ onUpdate } + onReset={ handleLoginFlowReset } + data-componentid={ componentId } + isLoading={ isAuthenticatorsFetchRequestLoading } + setIsLoading={ setIsAuthenticatorsFetchRequestLoading } + readOnly={ readOnly } + /> + ) + ); + }; + return ( - { !(isLoading || isAuthenticatorsFetchRequestLoading) ? ( - !readOnly && !loginFlow && isDefaultFlowConfiguration() ? ( - { - handleLoginFlowSelect( - type, - googleAuthenticators, - gitHubAuthenticators, - facebookAuthenticators, - microsoftAuthenticators, - appleAuthenticators - ); - } } - data-componentid={ `${componentId}-landing` } - /> - ) : ( - void, template: any) => { - setSelectedIDPTemplate(template); - setIDPCreateWizardTriggerOrigin("EXTERNAL"); - setIDPTemplateTypeToTrigger(type); - setShowMissingSocialAuthenticatorModal(false); - setShowIDPCreateWizard(true); - broadcastIDPCreateSuccessMessage = cb; - } } - onUpdate={ onUpdate } - onReset={ handleLoginFlowReset } - data-componentid={ componentId } - isLoading={ isAuthenticatorsFetchRequestLoading } - setIsLoading={ setIsAuthenticatorsFetchRequestLoading } - readOnly={ readOnly } - /> - ) - ) : ( - - ) } - - ) } + legacyBuilder={ renderLegacyAuthenticationFlowBuilder() } onIDPCreateWizardTrigger={ (type: string, cb: () => void, template: any) => { setSelectedIDPTemplate(template); setIDPCreateWizardTriggerOrigin("EXTERNAL"); From 77b558cc76614bbf7abaff167a05e8ca76792cae Mon Sep 17 00:00:00 2001 From: Pavindu Lakshan Date: Tue, 11 Jun 2024 16:01:27 +0530 Subject: [PATCH 2/3] Address review comments --- .../components/sign-on-methods-core.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx b/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx index 1a6b423d466..ead8bef6ff7 100644 --- a/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx +++ b/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx @@ -906,10 +906,8 @@ export const SignOnMethodsCore: FunctionComponent - ) : ( + ); + } else { + return ( - ) - ); + ); + } }; return ( From 3f3ba24b12beda051ec8e5369a1bafc1af4faaf1 Mon Sep 17 00:00:00 2001 From: Pavindu Lakshan Date: Tue, 11 Jun 2024 16:03:31 +0530 Subject: [PATCH 3/3] Remove unnecessary else clause --- .../components/sign-on-methods-core.tsx | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx b/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx index ead8bef6ff7..acc0083cb6a 100644 --- a/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx +++ b/features/admin.applications.v1/components/settings/sign-on-methods/components/sign-on-methods-core.tsx @@ -924,32 +924,32 @@ export const SignOnMethodsCore: FunctionComponent ); - } else { - return ( - void, template: any) => { - setSelectedIDPTemplate(template); - setIDPCreateWizardTriggerOrigin("EXTERNAL"); - setIDPTemplateTypeToTrigger(type); - setShowMissingSocialAuthenticatorModal(false); - setShowIDPCreateWizard(true); - broadcastIDPCreateSuccessMessage = cb; - } } - onUpdate={ onUpdate } - onReset={ handleLoginFlowReset } - data-componentid={ componentId } - isLoading={ isAuthenticatorsFetchRequestLoading } - setIsLoading={ setIsAuthenticatorsFetchRequestLoading } - readOnly={ readOnly } - /> - ); } + + return ( + void, template: any) => { + setSelectedIDPTemplate(template); + setIDPCreateWizardTriggerOrigin("EXTERNAL"); + setIDPTemplateTypeToTrigger(type); + setShowMissingSocialAuthenticatorModal(false); + setShowIDPCreateWizard(true); + broadcastIDPCreateSuccessMessage = cb; + } } + onUpdate={ onUpdate } + onReset={ handleLoginFlowReset } + data-componentid={ componentId } + isLoading={ isAuthenticatorsFetchRequestLoading } + setIsLoading={ setIsAuthenticatorsFetchRequestLoading } + readOnly={ readOnly } + /> + ); }; return (