Skip to content

Commit

Permalink
Merge branch 'remove-read-readwrite-access' of github.com:juspay/hype…
Browse files Browse the repository at this point in the history
…rswitch-control-center into user-management-block-sidebar
  • Loading branch information
Pritish Budhiraja committed Jan 17, 2024
2 parents 75596f9 + a56a688 commit c77867d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 64 deletions.
73 changes: 10 additions & 63 deletions src/components/EntityScaffold.res
Original file line number Diff line number Diff line change
@@ -1,85 +1,32 @@
module ComingSoon = {
@react.component
let make = (~title) => {
<div className="h-full w-full flex flex-col items-center justify-center">
<div className="text-2xl text-gray-500 pb-4"> {React.string(title)} </div>
<div> {React.string("Coming soon...")} </div>
</div>
}
}

module ShowPage = {
@react.component
let make = (~entityName, ~id) => {
<div className="h-full w-fit flex flex-col m-12">
<div className="text-2xl text-gray-500 pb-4">
{React.string(`Show ${entityName} `)}
<span className="text-sm"> {React.string(`#${id}`)} </span>
</div>
<div> {React.string("Coming soon...")} </div>
</div>
}
}

module UnauthorizedPage = {
@react.component
let make = (~entityName) => {
<div className="h-full w-fit flex flex-col m-12">
<div className="text-2xl text-gray-500 pb-4"> {React.string(entityName)} </div>
<div> {React.string("You don't have access to this module. Contact admin for access")} </div>
</div>
}
}

@react.component
let make = (
~entityName="",
~remainingPath,
~isAdminAccount=false,
~access: AuthTypes.authorization=Access,
~renderList=_ => <ComingSoon title="List" />,
~renderNewForm=_ => <ComingSoon title="New Form" />,
~renderList,
~renderNewForm=?,
~renderShow=?,
~renderOrder=?,
~renderEdit=_ => <ComingSoon title="Edit Form" />,
~renderEditWithMultiId=(_, _) => <ComingSoon title="Edit Form" />,
~renderClone=_ => <ComingSoon title="Clone Form" />,
) => {
if access === NoAccess {
<UnauthorizedPage entityName />
<UnauthorizedPage />
} else {
switch remainingPath {
| list{"new"} =>
switch access {
| Access => renderNewForm()
| NoAccess => <UnauthorizedPage entityName />
}
| list{id, "clone"} =>
switch access {
| Access => renderClone(id)
| NoAccess => <UnauthorizedPage entityName />
| Access =>
switch renderNewForm {
| Some(element) => element()
| None => React.null
}
| NoAccess => <UnauthorizedPage />
}
| list{id} =>
let page = switch renderShow {
| Some(fn) => fn(id)
| None => <ShowPage entityName id />
| None => React.null
}
page
| list{id, "edit"} =>
switch access {
| Access => renderEdit(id)
| NoAccess => <UnauthorizedPage entityName />
}
| list{id1, id2, "edit"} =>
switch access {
| Access => renderEditWithMultiId(id1, id2)
| NoAccess => <UnauthorizedPage entityName />
}
| list{"order", id} =>
switch renderOrder {
| Some(fn) => fn(id)
| None => <NotFoundPage />
}
| list{} => renderList()
| _ => <NotFoundPage />
}
Expand Down
19 changes: 19 additions & 0 deletions src/components/UnauthorizedPage.res
Original file line number Diff line number Diff line change
@@ -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
})
<NoDataFound message renderType={Locked}>
<Button
text={"Go to Home"}
buttonType=Primary
onClick={_ => {
setDashboardPageState(_ => #HOME)
RescriptReactRouter.replace("/home")
}}
customButtonStyle="mt-4 !p-2"
/>
</NoDataFound>
}
2 changes: 1 addition & 1 deletion src/entryPoints/hyperswitch/HyperSwitchApp.res
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ let make = () => {
| list{"quick-start"} => determineQuickStartPageState()
| list{"woocommerce"} => determineWooCommerce()
| list{"stripe-plus-paypal"} => determineStripePlusPayPal()
| list{"unauthorized"} => <AccessControl.UnauthorizedPage />
| list{"unauthorized"} => <UnauthorizedPage />
| _ =>
RescriptReactRouter.replace(`${hyperSwitchFEPrefix}/home`)
<Home />
Expand Down

0 comments on commit c77867d

Please sign in to comment.