From c2d505c2baa1ed6ca6b24ecee95a6f9d4d7a9a73 Mon Sep 17 00:00:00 2001 From: Pritish Budhiraja <1805317@kiit.ac.in> Date: Tue, 20 Feb 2024 15:29:36 +0530 Subject: [PATCH] chore: Sidebar Connector Hierarchy changes (#426) --- src/entryPoints/hyperswitch/SidebarValues.res | 98 +++++++++++-------- 1 file changed, 57 insertions(+), 41 deletions(-) diff --git a/src/entryPoints/hyperswitch/SidebarValues.res b/src/entryPoints/hyperswitch/SidebarValues.res index 6383a85d3..d5bb2558e 100644 --- a/src/entryPoints/hyperswitch/SidebarValues.res +++ b/src/entryPoints/hyperswitch/SidebarValues.res @@ -120,19 +120,64 @@ let operations = (isOperationsEnabled, ~permissionJson) => { : emptyComponent } -let connectors = (isConnectorsEnabled, isLiveMode, ~permissionJson) => { +let paymentProcessor = (isLiveMode, permissionJson) => { + SubLevelLink({ + name: "Payment Processor", + link: `/connectors`, + access: permissionJson.merchantConnectorAccountRead, + searchOptions: HSwitchUtils.getSearchOptionsForProcessors( + ~processorList=isLiveMode + ? ConnectorUtils.connectorListForLive + : ConnectorUtils.connectorList, + ~getNameFromString=ConnectorUtils.getConnectorNameString, + ), + }) +} + +let payoutConnectors = (~permissionJson) => { + SubLevelLink({ + name: "Payout Processors", + link: `/payoutconnectors`, + access: permissionJson.merchantConnectorAccountRead, + searchOptions: HSwitchUtils.getSearchOptionsForProcessors( + ~processorList=ConnectorUtils.payoutConnectorList, + ~getNameFromString=ConnectorUtils.getConnectorNameString, + ), + }) +} + +let fraudAndRisk = (~permissionJson) => { + SubLevelLink({ + name: "Fraud & Risk", + link: `/fraud-risk-management`, + access: permissionJson.merchantConnectorAccountRead, + searchOptions: [], + }) +} + +let connectors = ( + isConnectorsEnabled, + ~isLiveMode, + ~isFrmEnabled, + ~isPayoutsEnabled, + ~permissionJson, +) => { + let connectorLinkArray = [paymentProcessor(isLiveMode, permissionJson)] + + if isPayoutsEnabled { + connectorLinkArray->Array.push(payoutConnectors(~permissionJson))->ignore + } + + if isFrmEnabled { + connectorLinkArray->Array.push(fraudAndRisk(~permissionJson))->ignore + } + isConnectorsEnabled - ? Link({ - name: "Processors", - link: `/connectors`, + ? Section({ + name: "Connectors", icon: "connectors", - access: permissionJson.merchantConnectorAccountRead, - searchOptions: HSwitchUtils.getSearchOptionsForProcessors( - ~processorList=isLiveMode - ? ConnectorUtils.connectorListForLive - : ConnectorUtils.connectorList, - ~getNameFromString=ConnectorUtils.getConnectorNameString, - ), + showSection: true, + links: connectorLinkArray, }) : emptyComponent } @@ -323,33 +368,6 @@ let developers = (isDevelopersEnabled, userRole, systemMetrics, ~permissionJson) : emptyComponent } -let fraudAndRisk = (isfraudAndRiskEnabled, ~permissionJson) => { - isfraudAndRiskEnabled - ? Link({ - name: "Fraud & Risk", - icon: "shield-alt", - link: `/fraud-risk-management`, - access: permissionJson.merchantConnectorAccountRead, - searchOptions: [], - }) - : emptyComponent -} - -let payoutConnectors = (isPayoutConnectorsEnabled, ~permissionJson) => { - isPayoutConnectorsEnabled - ? Link({ - name: "Payout Processors", - link: `/payoutconnectors`, - icon: "connectors", - access: permissionJson.merchantConnectorAccountRead, - searchOptions: HSwitchUtils.getSearchOptionsForProcessors( - ~processorList=ConnectorUtils.payoutConnectorList, - ~getNameFromString=ConnectorUtils.getConnectorNameString, - ), - }) - : emptyComponent -} - let reconTag = (recon, isReconEnabled) => recon ? Link({ @@ -383,11 +401,9 @@ let useGetSidebarValues = (~isReconEnabled: bool) => { productionAccess->productionAccessComponent, default->home, default->operations(~permissionJson), + default->connectors(~isLiveMode, ~isFrmEnabled=frm, ~isPayoutsEnabled=payOut, ~permissionJson), default->analytics(userJourneyAnalyticsFlag, ~permissionJson), - default->connectors(isLiveMode, ~permissionJson), default->workflow(isSurchargeEnabled, ~permissionJson), - frm->fraudAndRisk(~permissionJson), - payOut->payoutConnectors(~permissionJson), recon->reconTag(isReconEnabled), default->developers(userRole, systemMetrics, ~permissionJson), settings(