From a240988e92099dceab3b6417f9c8f57e140d0076 Mon Sep 17 00:00:00 2001 From: Abhishek Katiyar Date: Fri, 15 Nov 2024 14:00:45 +0530 Subject: [PATCH] INFRA-3897 | Abhishek | Make external auth and internal gateways optional for clusters --- src/coreform/deployment/ApiGatewayForm.tsx | 61 ++++++++++++++++------ 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/src/coreform/deployment/ApiGatewayForm.tsx b/src/coreform/deployment/ApiGatewayForm.tsx index 91b829c..3479244 100644 --- a/src/coreform/deployment/ApiGatewayForm.tsx +++ b/src/coreform/deployment/ApiGatewayForm.tsx @@ -68,17 +68,34 @@ const InternalCommonApiGatewayUrlMap = { [Cluster.IAPL_PROD]: InternalCommonApiGatewayUrl.IAPL_PROD, }; +const ExternalAuthEnabledMap = { + [Cluster.LENDING_NP]: InternalCommonApiGatewayUrl.LENDING_NP, + [Cluster.LENDING_PROD]: InternalCommonApiGatewayUrl.LENDING_PROD, + [Cluster.PAY_NP]: InternalCommonApiGatewayUrl.PAY_NP, + [Cluster.PAY_PROD]: InternalCommonApiGatewayUrl.PAY_PROD, + [Cluster.GI_NP]: InternalCommonApiGatewayUrl.GI_NP, + [Cluster.GI_PROD]: InternalCommonApiGatewayUrl.GI_PROD, + [Cluster.SA_NP]: InternalCommonApiGatewayUrl.SA_NP, + [Cluster.SA_PROD]: InternalCommonApiGatewayUrl.SA_PROD, + [Cluster.PPL_NONPROD]: InternalCommonApiGatewayUrl.PPL_NP, + [Cluster.PPL_PROD]: InternalCommonApiGatewayUrl.PPL_PROD, + [Cluster.IAPL_PROD]: InternalCommonApiGatewayUrl.IAPL_PROD, +}; + const rateLimitOptions = ['header', 'path']; const GatewayAttributes = (props: any = { sourceGatewayPath: string }) => { const { sourceGatewayPath } = props; const classes = useStyles(); const { values }: { values: any } = useFormikContext(); + const cluster = values?.cluster; const attributeStateValue = typeof getIn(values, sourceGatewayPath) !== 'undefined' ? getIn(values, sourceGatewayPath) : []; const deployedState = attributeStateValue.map( (gatewayAttributes: any) => gatewayAttributes.isDeployed, ); + const externalAuthAllowed = + cluster in ExternalAuthEnabledMap ? ExternalAuthEnabledMap[cluster] : undefined; return ( { />{' '} - - - } - label="Use External Auth Service" - /> - - + {externalAuthAllowed ? ( + + + } + label="Use External Auth Service" + /> + + + ) : ( + <> + )} @@ -226,6 +247,8 @@ const ApiGatewayForm = () => { const gatewayStateValue = typeof getIn(values, gatewayPath) !== 'undefined' ? getIn(values, gatewayPath) : []; const deployedState = gatewayStateValue.map((gateway: any) => gateway.isDeployed); + const internalGatewayUrl = + cluster in InternalCommonApiGatewayUrlMap ? InternalCommonApiGatewayUrlMap[cluster] : undefined; return ( { > {toMenuItems(ExternalCommonApiGatewayUrlMap[cluster])} - - {toMenuItems(InternalCommonApiGatewayUrlMap[cluster])} - + {internalGatewayUrl !== undefined ? ( + + {toMenuItems(InternalCommonApiGatewayUrlMap[cluster])} + + ) : ( + <> + )}