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-permission-type-change
  • Loading branch information
Riddhiagrawal001 committed Oct 8, 2024
2 parents 6b85586 + 2f2cd83 commit e282d0a
Show file tree
Hide file tree
Showing 35 changed files with 798 additions and 216 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@ All notable changes to this project will be documented in this file. See [conven

- - -

## 2024.10.08.1

### Features

- Tooltip fix and enhancement ([#1571](https://github.com/juspay/hyperswitch-control-center/pull/1571)) ([`0cda40b`](https://github.com/juspay/hyperswitch-control-center/commit/0cda40b243acab3bbbcfa0f8488389c642e67785))
- Failed payment distribution graph ([#1528](https://github.com/juspay/hyperswitch-control-center/pull/1528)) ([`470b582`](https://github.com/juspay/hyperswitch-control-center/commit/470b582b5da77abb9a00a42948451d00942be62c))
- Graphs legends display ([#1574](https://github.com/juspay/hyperswitch-control-center/pull/1574)) ([`233b192`](https://github.com/juspay/hyperswitch-control-center/commit/233b1922ada5018ee92847fc5b859d63d5246d03))

### Bug Fixes

- Selected item displays on top of list ([#1560](https://github.com/juspay/hyperswitch-control-center/pull/1560)) ([`5e36d6f`](https://github.com/juspay/hyperswitch-control-center/commit/5e36d6fac432d33e57313d4f058925a8b414665e))
- UI connector preview ([#1538](https://github.com/juspay/hyperswitch-control-center/pull/1538)) ([`d32e536`](https://github.com/juspay/hyperswitch-control-center/commit/d32e5366d751505afb1264ea4ad3724cf9ffd808))
- Update status of connector ( Disable / Enable ) ([#1575](https://github.com/juspay/hyperswitch-control-center/pull/1575)) ([`b5c14dd`](https://github.com/juspay/hyperswitch-control-center/commit/b5c14ddc588b2fa1939591b7bcccc43f7ff883a2))

**Full Changelog:** [`2024.10.08.0...2024.10.08.1`](https://github.com/juspay/hyperswitch-control-center/compare/2024.10.08.0...2024.10.08.1)

- - -

## 2024.10.08.0

### Features
Expand Down
14 changes: 14 additions & 0 deletions src/components/SelectBox.res
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,20 @@ module RenderListItemInBaseRadio = {
~selectClass="",
~customScrollStyle=?,
) => {
let decodedValue = value->JSON.Decode.string
switch decodedValue {
| Some(str) =>
newOptions->Array.sort((item1, item2) => {
if item1.value == str {
-1.
} else if item2.value == str {
1.
} else {
0.
}
})
| None => ()
}
let dropdownList =
newOptions
->Array.mapWithIndex((option, i) => {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/entryPoints/HyperSwitchApp.res
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ let make = () => {
| list{"performance-monitor"}
| list{"analytics-refunds"}
| list{"analytics-disputes"} =>
<AnalyticsContainser />
<AnalyticsContainer />
| list{"new-analytics-payment"} =>
<AccessControl
isEnabled={featureFlagDetails.newAnalytics}
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/AuthHooks.res
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ let headersForXFeature = (~uri, ~headers) => {
if uri->String.includes("lottie-files") || uri->String.includes("config/merchant-access") {
headers->Dict.set("Content-Type", `application/json`)
} else {
headers->Dict.set("x-feature", "router-custom")
headers->Dict.set("x-feature", "integ-custom")
}
}

Expand Down
22 changes: 12 additions & 10 deletions src/screens/Connectors/ConnectPayPalFlow/MenuOptionForPayPal.res
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,15 @@ let make = (
handleCancel: {text: "Cancel"},
})
}

let authType = switch connectorInfo.connector_account_details {
| HeaderKey(authKeys) => authKeys.auth_type
| BodyKey(bodyKey) => bodyKey.auth_type
| SignatureKey(signatureKey) => signatureKey.auth_type
| MultiAuthKey(multiAuthKey) => multiAuthKey.auth_type
| CertificateAuth(certificateAuth) => certificateAuth.auth_type
| CurrencyAuthKey(currencyAuthKey) => currencyAuthKey.auth_type
| UnKnownAuthType(_) => ""
}
<Popover \"as"="div" className="relative inline-block text-left">
{_popoverProps => <>
<Popover.Button> {_ => <Icon name="menu-option" size=28 />} </Popover.Button>
Expand All @@ -95,9 +103,7 @@ let make = (
id="neglectTopbarTheme"
className="relative flex flex-col bg-white py-3 overflow-hidden rounded ring-1 ring-black ring-opacity-5 w-max">
{<>
<RenderIf
condition={connectorInfo.connector_account_details.auth_type->ConnectorUtils.mapAuthType ===
#SignatureKey}>
<RenderIf condition={authType->ConnectorUtils.mapAuthType === #SignatureKey}>
<Navbar.MenuOption
text="Create new PayPal account"
onClick={_ => {
Expand All @@ -113,9 +119,7 @@ let make = (
setSetupAccountStatus(_ => PayPalFlowTypes.Connect_paypal_landing)
}}
/>
<RenderIf
condition={connectorInfo.connector_account_details.auth_type->ConnectorUtils.mapAuthType ===
#BodyKey}>
<RenderIf condition={authType->ConnectorUtils.mapAuthType === #BodyKey}>
<Navbar.MenuOption
text="Update"
onClick={_ => {
Expand All @@ -124,9 +128,7 @@ let make = (
}}
/>
</RenderIf>
<RenderIf
condition={connectorInfo.connector_account_details.auth_type->ConnectorUtils.mapAuthType ===
#SignatureKey}>
<RenderIf condition={authType->ConnectorUtils.mapAuthType === #SignatureKey}>
<Navbar.MenuOption
text="Update Payment Methods"
onClick={_ => {
Expand Down
1 change: 0 additions & 1 deletion src/screens/Connectors/ConnectorHome.res
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,6 @@ let make = (~isPayoutFlow=false, ~showStepIndicator=true, ~showBreadCrumb=true)
currentStep
setCurrentStep
isUpdateFlow
isPayoutFlow
setInitialValues
getPayPalStatus
getConnectorDetails={Some(getConnectorDetails)}
Expand Down
70 changes: 31 additions & 39 deletions src/screens/Connectors/ConnectorPreview.res
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module KeyAndCopyArea = {
{copyValue->React.string}
</p>
<div
className="cursor-pointer h-20 w-20 pt-1"
className="cursor-pointer w-20 pt-1"
onClick={_ => {
Clipboard.writeText(copyValue)
showToast(~message="Copied to Clipboard!", ~toastType=ToastSuccess)
Expand Down Expand Up @@ -127,8 +127,6 @@ module ConnectorSummaryGrid = {
let make = (
~connectorInfo: ConnectorTypes.connectorPayload,
~connector,
~isPayoutFlow,
~setScreenState,
~setCurrentStep,
~updateStepValue=None,
~getConnectorDetails=None,
Expand All @@ -148,26 +146,32 @@ module ConnectorSummaryGrid = {
~connectorName={connectorInfo.merchant_connector_id},
~merchantId,
)
let (processorType, _) = connectorInfo.connector_type->ConnectorUtils.connectorTypeTuple
let {connector_name: connectorName} = connectorInfo

let connectorDetails = React.useMemo(() => {
try {
if connector->LogicUtils.isNonEmptyString {
let dict = isPayoutFlow
? Window.getPayoutConnectorConfig(connector)
: Window.getConnectorConfig(connector)

if connectorName->LogicUtils.isNonEmptyString {
let dict = switch processorType {
| PaymentProcessor => Window.getConnectorConfig(connectorName)
| PayoutProcessor => Window.getPayoutConnectorConfig(connectorName)
| AuthenticationProcessor => Window.getAuthenticationConnectorConfig(connectorName)
| PMAuthProcessor => Window.getPMAuthenticationProcessorConfig(connectorName)
| TaxProcessor => Window.getTaxProcessorConfig(connectorName)
| PaymentVas => JSON.Encode.null
}
dict
} else {
Dict.make()->JSON.Encode.object
JSON.Encode.null
}
} catch {
| Exn.Error(e) => {
Js.log2("FAILED TO LOAD CONNECTOR CONFIG", e)
let err = Exn.message(e)->Option.getOr("Something went wrong")
setScreenState(_ => PageLoaderWrapper.Error(err))
Dict.make()->JSON.Encode.object
let _ = Exn.message(e)->Option.getOr("Something went wrong")
JSON.Encode.null
}
}
}, [connector])
}, [connectorInfo.merchant_connector_id])
let (_, connectorAccountFields, _, _, _, _, _) = ConnectorUtils.getConnectorFields(
connectorDetails,
)
Expand All @@ -176,8 +180,8 @@ module ConnectorSummaryGrid = {
| _ => true
}

<div className="p-2 md:px-10">
<div className="grid grid-cols-4 my-12">
<>
<div className="grid grid-cols-4 border-b md:px-10 py-8">
<h4 className="text-lg font-semibold"> {"Integration status"->React.string} </h4>
<AddDataAttributes attributes=[("data-testid", "connector_status"->String.toLowerCase)]>
<div
Expand All @@ -186,7 +190,7 @@ module ConnectorSummaryGrid = {
</div>
</AddDataAttributes>
</div>
<div className="grid grid-cols-4 my-12">
<div className="grid grid-cols-4 border-b md:px-10 py-8">
<div className="flex items-start">
<h4 className="text-lg font-semibold"> {"Webhook Endpoint"->React.string} </h4>
<ToolTip
Expand All @@ -201,31 +205,20 @@ module ConnectorSummaryGrid = {
<KeyAndCopyArea copyValue={copyValueOfWebhookEndpoint} />
</div>
</div>
<div className="grid grid-cols-4 my-12">
<div className="grid grid-cols-4 border-b md:px-10 py-8">
<h4 className="text-lg font-semibold"> {"Profile"->React.string} </h4>
<div className="col-span-3">
{`${currentProfileName.profile_name} - ${connectorInfo.profile_id}`->React.string}
</div>
</div>
<div className="grid grid-cols-4 my-12">
<div className="grid grid-cols-4 border-b md:px-10 py-8">
<div className="flex items-start">
<h4 className="text-lg font-semibold"> {"API Keys"->React.string} </h4>
<h4 className="text-lg font-semibold"> {"Creds"->React.string} </h4>
</div>
<div className="flex flex-col gap-6 col-span-3">
<div className="flex flex-col gap-6 col-span-3">
<div className="flex gap-12">
<div className="flex flex-col gap-6 w-1/2">
{connectorAccountFields
->Dict.keysToArray
->Array.mapWithIndex((field, index) => {
open LogicUtils
let label = connectorAccountFields->getString(field, "")
<InfoField
key={index->Int.toString}
label={label}
render={connectorInfo->ConnectorUtils.getConnectorDetailsValue(field)}
/>
})
->React.array}
<ConnectorPreviewHelper.PreviewCreds connectorAccountFields connectorInfo />
</div>
<RenderIf condition={isUpdateFlow}>
<ConnectorUpdateAuthCreds connectorInfo getConnectorDetails />
Expand All @@ -236,7 +229,7 @@ module ConnectorSummaryGrid = {
</div>
{switch updateStepValue {
| Some(state) =>
<div className="grid grid-cols-4 my-12">
<div className="grid grid-cols-4 border-b md:px-10 py-8">
<div className="flex items-start">
<h4 className="text-lg font-semibold"> {"PMTs"->React.string} </h4>
</div>
Expand Down Expand Up @@ -302,7 +295,7 @@ module ConnectorSummaryGrid = {

| None => React.null
}}
</div>
</>
}
}

Expand All @@ -312,7 +305,6 @@ let make = (
~currentStep: ConnectorTypes.steps,
~setCurrentStep,
~isUpdateFlow,
~isPayoutFlow,
~showMenuOption=true,
~setInitialValues,
~getPayPalStatus,
Expand All @@ -327,6 +319,7 @@ let make = (
let updateDetails = useUpdateMethod()
let showToast = ToastState.useShowToast()
let mixpanelEvent = MixpanelHook.useSendEvent()
let fetchConnectorListResponse = ConnectorListHook.useFetchConnectorList()
let connector = UrlUtils.useGetFilterDictFromUrl("")->LogicUtils.getString("name", "")
let {setShowFeedbackModal} = React.useContext(GlobalProvider.defaultContext)
let (screenState, setScreenState) = React.useState(_ => PageLoaderWrapper.Success)
Expand Down Expand Up @@ -354,9 +347,10 @@ let make = (
isConnectorDisabled,
)
let url = getURL(~entityName=CONNECTOR, ~methodType=Post, ~id=Some(connectorID))
let _ = await updateDetails(url, disableConnectorPayload->JSON.Encode.object, Post)
let res = await updateDetails(url, disableConnectorPayload->JSON.Encode.object, Post)
fetchConnectorListResponse()->ignore
setInitialValues(_ => res)
showToast(~message=`Successfully Saved the Changes`, ~toastType=ToastSuccess)
RescriptReactRouter.push(GlobalVars.appendDashboardPath(~url=redirectPath))
} catch {
| Exn.Error(_) => showToast(~message=`Failed to Disable connector!`, ~toastType=ToastError)
}
Expand Down Expand Up @@ -432,8 +426,6 @@ let make = (
<ConnectorSummaryGrid
connectorInfo
connector
isPayoutFlow
setScreenState
setCurrentStep
updateStepValue={Some(ConnectorTypes.PaymentMethods)}
getConnectorDetails
Expand Down
69 changes: 69 additions & 0 deletions src/screens/Connectors/ConnectorPreviewHelper.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
module InfoField = {
@react.component
let make = (~label, ~str) => {
<div>
<h2 className="text-lg font-semibold"> {label->React.string} </h2>
<h3 className=" break-words"> {str->React.string} </h3>
</div>
}
}

module CredsInfoField = {
@react.component
let make = (~authKeys, ~connectorAccountFields) => {
open LogicUtils
let dict = authKeys->Identity.genericTypeToDictOfJson
dict
->Dict.keysToArray
->Array.filter(ele => ele !== "auth_type")
->Array.map(field => {
let value = dict->getString(field, "")
let label = connectorAccountFields->getString(field, "")
<InfoField label str=value />
})
->React.array
}
}

module CashtoCodeCredsInfo = {
@react.component
let make = (~authKeys: ConnectorTypes.currencyAuthKey) => {
open LogicUtils
let dict = authKeys.auth_key_map->Identity.genericTypeToDictOfJson
dict
->Dict.keysToArray
->Array.map(ele => {
let data = dict->getDictfromDict(ele)
let keys = data->Dict.keysToArray

{
<>
<InfoField label="Currency" str=ele />
{keys
->Array.map(ele => {
let value = data->getString(ele, "")
<InfoField label={ele->snakeToTitle} str=value />
})
->React.array}
</>
}
})
->React.array
}
}

module PreviewCreds = {
@react.component
let make = (~connectorAccountFields, ~connectorInfo: ConnectorTypes.connectorPayload) => {
switch connectorInfo.connector_account_details {
| HeaderKey(authKeys) => <CredsInfoField authKeys connectorAccountFields />
| BodyKey(bodyKey) => <CredsInfoField authKeys=bodyKey connectorAccountFields />
| SignatureKey(signatureKey) => <CredsInfoField authKeys=signatureKey connectorAccountFields />
| MultiAuthKey(multiAuthKey) => <CredsInfoField authKeys=multiAuthKey connectorAccountFields />
| CertificateAuth(certificateAuth) =>
<CredsInfoField authKeys=certificateAuth connectorAccountFields />
| CurrencyAuthKey(currencyAuthKey) => <CashtoCodeCredsInfo authKeys=currencyAuthKey />
| UnKnownAuthType(_) => React.null
}
}
}
Loading

0 comments on commit e282d0a

Please sign in to comment.