Skip to content

Commit

Permalink
Merge branch 'main' of github.com:juspay/hyperswitch-control-center i…
Browse files Browse the repository at this point in the history
…nto user-management-block-sidebar
  • Loading branch information
Pritish Budhiraja committed Jan 17, 2024
2 parents 2eaf347 + 59d0b53 commit fb3411f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 34 deletions.
54 changes: 20 additions & 34 deletions src/entryPoints/hyperswitch/HyperSwitchApp.res
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,6 @@ open HSLocalStorage
open HSwitchGlobalVars
open APIUtils

module FeatureFlagEnabledComponent = {
@react.component
let make = (~isEnabled, ~children) => {
let {setDashboardPageState} = React.useContext(GlobalProvider.defaultContext)
let updateRoute = () => {
setDashboardPageState(_ => #HOME)
RescriptReactRouter.replace("/home")
React.null
}
<> {isEnabled ? children : updateRoute()} </>
}
}

@react.component
let make = () => {
let url = RescriptReactRouter.useUrl()
Expand Down Expand Up @@ -249,19 +236,19 @@ let make = () => {
<ErrorBoundary>
{switch url.path {
| list{"home"} =>
<FeatureFlagEnabledComponent isEnabled={featureFlagDetails.default}>
<AccessControl isEnabled={featureFlagDetails.default}>
{featureFlagDetails.quickStart ? <HomeV2 /> : <Home />}
</FeatureFlagEnabledComponent>
</AccessControl>
| list{"fraud-risk-management", ...remainingPath} =>
<FeatureFlagEnabledComponent isEnabled={featureFlagDetails.frm}>
<AccessControl isEnabled={featureFlagDetails.frm}>
<EntityScaffold
entityName="risk-management"
remainingPath
renderList={() => <FRMSelect />}
renderNewForm={() => <FRMConfigure />}
renderShow={_ => <FRMConfigure />}
/>
</FeatureFlagEnabledComponent>
</AccessControl>
| list{"connectors", ...remainingPath} =>
<EntityScaffold
entityName="Connectors"
Expand Down Expand Up @@ -307,15 +294,15 @@ let make = () => {
renderShow={id => <ShowDisputes id />}
/>
| list{"customers", ...remainingPath} =>
<FeatureFlagEnabledComponent isEnabled=featureFlagDetails.customersModule>
<AccessControl isEnabled=featureFlagDetails.customersModule>
<EntityScaffold
entityName="Customers"
remainingPath
access=ReadWrite
renderList={() => <Customers />}
renderShow={id => <ShowCustomers id />}
/>
</FeatureFlagEnabledComponent>
</AccessControl>
| list{"routing", ...remainingPath} =>
<EntityScaffold
entityName="Routing"
Expand All @@ -341,12 +328,11 @@ let make = () => {
<RefundsAnalytics />
</FilterContext>
| list{"analytics-user-journey"} =>
<FeatureFlagEnabledComponent
isEnabled=featureFlagDetails.userJourneyAnalytics>
<AccessControl isEnabled=featureFlagDetails.userJourneyAnalytics>
<FilterContext key="UserJourneyAnalytics" index="UserJourneyAnalytics">
<UserJourneyAnalytics />
</FilterContext>
</FeatureFlagEnabledComponent>
</AccessControl>
| list{"monitoring"} => comingSoonPage
| list{"developer-api-keys"} => <KeyManagement.KeysManagement />
| list{"developer-system-metrics"} =>
Expand All @@ -366,31 +352,31 @@ let make = () => {
<PaymentSettings webhookOnly=false showFormOnly=false />}
/>
| list{"recon"} =>
<FeatureFlagEnabledComponent isEnabled=featureFlagDetails.recon>
<AccessControl isEnabled=featureFlagDetails.recon>
<Recon />
</FeatureFlagEnabledComponent>
</AccessControl>
| list{"sdk"} =>
<FeatureFlagEnabledComponent isEnabled={!featureFlagDetails.isLiveMode}>
<AccessControl isEnabled={!featureFlagDetails.isLiveMode}>
<SDKPage />
</FeatureFlagEnabledComponent>
</AccessControl>
| list{"3ds"} => <HSwitchThreeDS />
| list{"surcharge"} =>
<FeatureFlagEnabledComponent isEnabled={featureFlagDetails.surcharge}>
<AccessControl isEnabled={featureFlagDetails.surcharge}>
<Surcharge />
</FeatureFlagEnabledComponent>
</AccessControl>
| list{"account-settings"} =>
<FeatureFlagEnabledComponent isEnabled=featureFlagDetails.sampleData>
<AccessControl isEnabled=featureFlagDetails.sampleData>
<HSwitchSettings />
</FeatureFlagEnabledComponent>
</AccessControl>
| list{"account-settings", "profile"} => <HSwitchProfileSettings />
| list{"business-details"} =>
<FeatureFlagEnabledComponent isEnabled=featureFlagDetails.default>
<AccessControl isEnabled=featureFlagDetails.default>
<BusinessDetails />
</FeatureFlagEnabledComponent>
</AccessControl>
| list{"business-profiles"} =>
<FeatureFlagEnabledComponent isEnabled=featureFlagDetails.businessProfile>
<AccessControl isEnabled=featureFlagDetails.businessProfile>
<BusinessProfile />
</FeatureFlagEnabledComponent>
</AccessControl>
| list{"quick-start"} => determineQuickStartPageState()
| list{"woocommerce"} => determineWooCommerce()
| list{"stripe-plus-paypal"} => determineStripePlusPayPal()
Expand Down
11 changes: 11 additions & 0 deletions src/utils/AccessControl.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@react.component
let make = (~isEnabled, ~children) => {
let {setDashboardPageState} = React.useContext(GlobalProvider.defaultContext)

let updateRoute = () => {
setDashboardPageState(_ => #HOME)
RescriptReactRouter.replace("/home")
React.null
}
isEnabled ? children : updateRoute()
}

0 comments on commit fb3411f

Please sign in to comment.