diff --git a/src/components/EntityScaffold.res b/src/components/EntityScaffold.res
index d9d048b33..68afbe809 100644
--- a/src/components/EntityScaffold.res
+++ b/src/components/EntityScaffold.res
@@ -1,85 +1,32 @@
-module ComingSoon = {
- @react.component
- let make = (~title) => {
-
-
{React.string(title)}
-
{React.string("Coming soon...")}
-
- }
-}
-
-module ShowPage = {
- @react.component
- let make = (~entityName, ~id) => {
-
-
- {React.string(`Show ${entityName} `)}
- {React.string(`#${id}`)}
-
-
{React.string("Coming soon...")}
-
- }
-}
-
-module UnauthorizedPage = {
- @react.component
- let make = (~entityName) => {
-
-
{React.string(entityName)}
-
{React.string("You don't have access to this module. Contact admin for access")}
-
- }
-}
-
@react.component
let make = (
~entityName="",
~remainingPath,
~isAdminAccount=false,
- ~access: AuthTypes.authorization=ReadWrite,
- ~renderList=() => ,
- ~renderNewForm=() => ,
+ ~access: AuthTypes.authorization=Access,
+ ~renderList,
+ ~renderNewForm=?,
~renderShow=?,
- ~renderOrder=?,
- ~renderEdit=_id => ,
- ~renderEditWithMultiId=(_id1, _id2) => ,
- ~renderClone=_id => ,
) => {
if access === NoAccess {
-
+
} else {
switch remainingPath {
| list{"new"} =>
switch access {
- | ReadWrite => renderNewForm()
- | _ =>
- }
- | list{id, "clone"} =>
- switch access {
- | ReadWrite => renderClone(id)
- | _ =>
+ | Access =>
+ switch renderNewForm {
+ | Some(element) => element()
+ | None => React.null
+ }
+ | NoAccess =>
}
| list{id} =>
let page = switch renderShow {
| Some(fn) => fn(id)
- | None =>
+ | None => React.null
}
page
- | list{id, "edit"} =>
- switch access {
- | ReadWrite => renderEdit(id)
- | _ =>
- }
- | list{id1, id2, "edit"} =>
- switch access {
- | ReadWrite => renderEditWithMultiId(id1, id2)
- | _ =>
- }
- | list{"order", id} =>
- switch renderOrder {
- | Some(fn) => fn(id)
- | None =>
- }
| list{} => renderList()
| _ =>
}
diff --git a/src/components/UnauthorizedPage.res b/src/components/UnauthorizedPage.res
new file mode 100644
index 000000000..55bddadc9
--- /dev/null
+++ b/src/components/UnauthorizedPage.res
@@ -0,0 +1,19 @@
+@react.component
+let make = (~message="You don't have access to this module. Contact admin for access") => {
+ let {setDashboardPageState} = React.useContext(GlobalProvider.defaultContext)
+ React.useEffect0(() => {
+ RescriptReactRouter.replace("/unauthorized")
+ None
+ })
+
+
+}
diff --git a/src/components/form/BoolInput.res b/src/components/form/BoolInput.res
index 64ec789f0..8ada7a9aa 100644
--- a/src/components/form/BoolInput.res
+++ b/src/components/form/BoolInput.res
@@ -114,7 +114,6 @@ let make = (
~boolCustomClass="",
~addAttributeId="",
) => {
- let accessLevel = React.useContext(FormAuthContext.formAuthContext)
let boolInput = baseInput->ffInputToBoolInput
let boolValue: Js.Json.t = boolInput.value
@@ -126,14 +125,8 @@ let make = (
let setIsSelected = boolInput.onChange
isCheckBox
- ?
+ ?
:
}
diff --git a/src/context/FormAuthContext.res b/src/context/FormAuthContext.res
index e59430a3d..6d87a6061 100644
--- a/src/context/FormAuthContext.res
+++ b/src/context/FormAuthContext.res
@@ -1,3 +1,3 @@
-let formAuthContext = React.createContext(AuthTypes.ReadWrite)
+let formAuthContext = React.createContext(AuthTypes.Access)
let make = React.Context.provider(formAuthContext)
diff --git a/src/entryPoints/hyperswitch/HyperSwitchApp.res b/src/entryPoints/hyperswitch/HyperSwitchApp.res
index 210af2a7c..f8d8e2979 100644
--- a/src/entryPoints/hyperswitch/HyperSwitchApp.res
+++ b/src/entryPoints/hyperswitch/HyperSwitchApp.res
@@ -240,7 +240,7 @@ let make = () => {
}
renderShow={id => }
/>
@@ -250,7 +250,7 @@ let make = () => {
}
renderShow={id => }
/>
@@ -259,7 +259,7 @@ let make = () => {
}
renderShow={id => }
/>
@@ -268,7 +268,7 @@ let make = () => {
}
renderShow={id => }
/>
@@ -285,7 +285,7 @@ let make = () => {
}
renderShow={_ => }
/>
@@ -350,7 +350,7 @@ let make = () => {
| list{"quick-start"} => determineQuickStartPageState()
| list{"woocommerce"} => determineWooCommerce()
| list{"stripe-plus-paypal"} => determineStripePlusPayPal()
-
+ | list{"unauthorized"} =>
| _ =>
RescriptReactRouter.replace(`${hyperSwitchFEPrefix}/home`)
diff --git a/src/entryPoints/hyperswitch/SidebarValues.res b/src/entryPoints/hyperswitch/SidebarValues.res
index 3717fc222..648d74cde 100644
--- a/src/entryPoints/hyperswitch/SidebarValues.res
+++ b/src/entryPoints/hyperswitch/SidebarValues.res
@@ -54,35 +54,35 @@ let home = isHomeEnabled =>
name: "Home",
icon: "hswitch-home",
link: "/home",
- access: ReadWrite,
+ access: Access,
})
: emptyComponent
let payments = SubLevelLink({
name: "Payments",
link: `/payments`,
- access: ReadWrite,
+ access: Access,
searchOptions: [("View payment operations", "")],
})
let refunds = SubLevelLink({
name: "Refunds",
link: `/refunds`,
- access: ReadWrite,
+ access: Access,
searchOptions: [("View refund operations", "")],
})
let disputes = SubLevelLink({
name: "Disputes",
link: `/disputes`,
- access: ReadWrite,
+ access: Access,
searchOptions: [("View dispute operations", "")],
})
let customers = SubLevelLink({
name: "Customers",
link: `/customers`,
- access: ReadWrite,
+ access: Access,
searchOptions: [("View customers", "")],
})
@@ -105,7 +105,7 @@ let connectors = (isConnectorsEnabled, isLiveMode) => {
name: "Processors",
link: `/connectors`,
icon: "connectors",
- access: ReadWrite,
+ access: Access,
searchOptions: HSwitchUtils.getSearchOptionsForProcessors(
~processorList=isLiveMode
? ConnectorUtils.connectorListForLive
@@ -119,21 +119,21 @@ let connectors = (isConnectorsEnabled, isLiveMode) => {
let paymentAnalytcis = SubLevelLink({
name: "Payments",
link: `/analytics-payments`,
- access: ReadWrite,
+ access: Access,
searchOptions: [("View analytics", "")],
})
let refundAnalytics = SubLevelLink({
name: "Refunds",
link: `/analytics-refunds`,
- access: ReadWrite,
+ access: Access,
searchOptions: [("View analytics", "")],
})
let userJourneyAnalytics = SubLevelLink({
name: "User Journey",
link: `/analytics-user-journey`,
- access: ReadWrite,
+ access: Access,
iconTag: "betaTag",
searchOptions: [("View analytics", "")],
})
@@ -153,7 +153,7 @@ let analytics = (isAnalyticsEnabled, userJourneyAnalyticsFlag) =>
let routing = SubLevelLink({
name: "Routing",
link: `/routing`,
- access: ReadWrite,
+ access: Access,
searchOptions: [
("Manage default routing configuration", "/default"),
("Create new volume based routing", "/volume"),
@@ -165,14 +165,14 @@ let routing = SubLevelLink({
let threeDs = SubLevelLink({
name: "3DS Decision Manager",
link: `/3ds`,
- access: ReadWrite,
+ access: Access,
searchOptions: [("Configure 3ds", "")],
})
let surcharge = SubLevelLink({
name: "Surcharge",
link: `/surcharge`,
- access: ReadWrite,
+ access: Access,
searchOptions: [("Add Surcharge", "")],
})
@@ -189,14 +189,14 @@ let workflow = (isWorkflowEnabled, isSurchargeEnabled) =>
let userManagement = SubLevelLink({
name: "Team",
link: `/users`,
- access: ReadWrite,
+ access: Access,
searchOptions: [("View team management", "")],
})
let accountSettings = SubLevelLink({
name: "Account Settings",
link: `/account-settings`,
- access: ReadWrite,
+ access: Access,
searchOptions: [
("View profile", "/profile"),
("Change password", "/profile"),
@@ -207,14 +207,14 @@ let accountSettings = SubLevelLink({
let businessDetails = SubLevelLink({
name: "Business Details",
link: `/business-details`,
- access: ReadWrite,
+ access: Access,
searchOptions: [("Configure business details", "")],
})
let businessProfiles = SubLevelLink({
name: "Business Profiles",
link: `/business-profiles`,
- access: ReadWrite,
+ access: Access,
searchOptions: [("Configure business profiles", "")],
})
@@ -242,14 +242,14 @@ let settings = (~isSampleDataEnabled, ~isUserManagementEnabled, ~isBusinessProfi
let apiKeys = SubLevelLink({
name: "API Keys",
link: `/developer-api-keys`,
- access: ReadWrite,
+ access: Access,
searchOptions: [("View API Keys", "")],
})
let systemMetric = SubLevelLink({
name: "System Metrics",
link: `/developer-system-metrics`,
- access: ReadWrite,
+ access: Access,
iconTag: "betaTag",
searchOptions: [("View System Metrics", "")],
})
@@ -257,7 +257,7 @@ let systemMetric = SubLevelLink({
let paymentSettings = SubLevelLink({
name: "Payment Settings",
link: `/payment-settings`,
- access: ReadWrite,
+ access: Access,
searchOptions: [("View payment settings", ""), ("View webhooks", ""), ("View return url", "")],
})
@@ -282,7 +282,7 @@ let fraudAndRisk = isfraudAndRiskEnabled =>
name: "Fraud & Risk",
icon: "shield-alt",
link: `/fraud-risk-management`,
- access: isfraudAndRiskEnabled ? ReadWrite : NoAccess,
+ access: isfraudAndRiskEnabled ? Access : NoAccess,
searchOptions: [],
})
: emptyComponent
@@ -293,7 +293,7 @@ let payoutConnectors = isPayoutConnectorsEnabled =>
name: "Payout Processors",
link: `/payoutconnectors`,
icon: "connectors",
- access: ReadWrite,
+ access: Access,
searchOptions: HSwitchUtils.getSearchOptionsForProcessors(
~processorList=ConnectorUtils.payoutConnectorList,
~getNameFromString=ConnectorUtils.getConnectorNameString,
@@ -307,7 +307,7 @@ let reconTag = (recon, isReconEnabled) =>
name: "Reconcilation",
icon: isReconEnabled ? "recon" : "recon-lock",
link: `/recon`,
- access: ReadWrite,
+ access: Access,
})
: emptyComponent
diff --git a/src/screens/HyperSwitch/UserManagement/PermissionUtils.res b/src/screens/HyperSwitch/UserManagement/PermissionUtils.res
index d75e19b33..bf529ff77 100644
--- a/src/screens/HyperSwitch/UserManagement/PermissionUtils.res
+++ b/src/screens/HyperSwitch/UserManagement/PermissionUtils.res
@@ -103,5 +103,5 @@ let getAccessValue = (~permissionValue: permissionType, permissionList) => {
ele === permissionValue
})
- isPermissionFound->Option.isSome ? Read : NoAccess
+ isPermissionFound->Option.isSome ? Access : NoAccess
}
diff --git a/src/screens/login/AuthTypes.res b/src/screens/login/AuthTypes.res
index a28e0757d..1bb419c39 100644
--- a/src/screens/login/AuthTypes.res
+++ b/src/screens/login/AuthTypes.res
@@ -1 +1 @@
-type authorization = NoAccess | Read | ReadWrite
+type authorization = NoAccess | Access