-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: sidebar refactoring & permissions added (#264)
- Loading branch information
Pritish Budhiraja
authored
Jan 17, 2024
1 parent
1fc2789
commit f428679
Showing
7 changed files
with
119 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
src/screens/HyperSwitch/UserManagement/PermissionUtils.res
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
type permissionType = | ||
| PaymentRead | ||
| PaymentWrite | ||
| RefundRead | ||
| RefundWrite | ||
| ApiKeyRead | ||
| ApiKeyWrite | ||
| MerchantAccountRead | ||
| MerchantAccountWrite | ||
| MerchantConnectorAccountRead | ||
| MerchantConnectorAccountWrite | ||
| ForexRead | ||
| RoutingRead | ||
| RoutingWrite | ||
| DisputeRead | ||
| DisputeWrite | ||
| MandateRead | ||
| MandateWrite | ||
| CustomerRead | ||
| CustomerWrite | ||
| FileRead | ||
| FileWrite | ||
| Analytics | ||
| ThreeDsDecisionManagerWrite | ||
| ThreeDsDecisionManagerRead | ||
| SurchargeDecisionManagerWrite | ||
| SurchargeDecisionManagerRead | ||
| UsersRead | ||
| UsersWrite | ||
| UnknownPermission(string) | ||
|
||
let mapPermissionTypeToString = permissionType => { | ||
switch permissionType { | ||
| PaymentRead => "PaymentRead" | ||
| PaymentWrite => "PaymentWrite" | ||
| RefundRead => "RefundRead" | ||
| RefundWrite => "RefundWrite" | ||
| ApiKeyRead => "ApiKeyRead" | ||
| ApiKeyWrite => "ApiKeyWrite" | ||
| MerchantAccountRead => "MerchantAccountRead" | ||
| MerchantAccountWrite => "MerchantAccountWrite" | ||
| MerchantConnectorAccountRead => "MerchantConnectorAccountRead" | ||
| MerchantConnectorAccountWrite => "MerchantConnectorAccountWrite" | ||
| ForexRead => "ForexRead" | ||
| RoutingRead => "RoutingRead" | ||
| RoutingWrite => "RoutingWrite" | ||
| DisputeRead => "DisputeRead" | ||
| DisputeWrite => "DisputeWrite" | ||
| MandateRead => "MandateRead" | ||
| MandateWrite => "MandateWrite" | ||
| CustomerRead => "CustomerRead" | ||
| CustomerWrite => "CustomerWrite" | ||
| FileRead => "FileRead" | ||
| FileWrite => "FileWrite" | ||
| Analytics => "Analytics" | ||
| ThreeDsDecisionManagerWrite => "ThreeDsDecisionManagerWrite" | ||
| ThreeDsDecisionManagerRead => "ThreeDsDecisionManagerRead" | ||
| SurchargeDecisionManagerWrite => "SurchargeDecisionManagerWrite" | ||
| SurchargeDecisionManagerRead => "SurchargeDecisionManagerRead" | ||
| UsersRead => "UsersRead" | ||
| UsersWrite => "UsersWrite" | ||
| UnknownPermission(val) => val | ||
} | ||
} | ||
|
||
let mapStringToPermissionType = val => { | ||
switch val { | ||
| "PaymentRead" => PaymentRead | ||
| "PaymentWrite" => PaymentWrite | ||
| "RefundRead" => RefundRead | ||
| "RefundWrite" => RefundWrite | ||
| "ApiKeyRead" => ApiKeyRead | ||
| "ApiKeyWrite" => ApiKeyWrite | ||
| "MerchantAccountRead" => MerchantAccountRead | ||
| "MerchantAccountWrite" => MerchantAccountWrite | ||
| "MerchantConnectorAccountRead" => MerchantConnectorAccountRead | ||
| "MerchantConnectorAccountWrite" => MerchantConnectorAccountWrite | ||
| "ForexRead" => ForexRead | ||
| "RoutingRead" => RoutingRead | ||
| "RoutingWrite" => RoutingWrite | ||
| "DisputeRead" => DisputeRead | ||
| "DisputeWrite" => DisputeWrite | ||
| "MandateRead" => MandateRead | ||
| "MandateWrite" => MandateWrite | ||
| "CustomerRead" => CustomerRead | ||
| "CustomerWrite" => CustomerWrite | ||
| "FileRead" => FileRead | ||
| "FileWrite" => FileWrite | ||
| "Analytics" => Analytics | ||
| "ThreeDsDecisionManagerWrite" => ThreeDsDecisionManagerWrite | ||
| "ThreeDsDecisionManagerRead" => ThreeDsDecisionManagerRead | ||
| "SurchargeDecisionManagerWrite" => SurchargeDecisionManagerWrite | ||
| "SurchargeDecisionManagerRead" => SurchargeDecisionManagerRead | ||
| "UsersRead" => UsersRead | ||
| "UsersWrite" => UsersWrite | ||
| val => UnknownPermission(val) | ||
} | ||
} | ||
|
||
let getAccessValue = (~permissionValue: permissionType, permissionList) => { | ||
open AuthTypes | ||
let isPermissionFound = permissionList->Array.find(ele => { | ||
ele === permissionValue | ||
}) | ||
|
||
isPermissionFound->Option.isSome ? Read : NoAccess | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
type authorization = NoAccess | Read | ReadWrite | Checker | ||
type authorization = NoAccess | Read | ReadWrite |