Skip to content

Commit

Permalink
Merge branch 'main' into feat/accept-dispute
Browse files Browse the repository at this point in the history
  • Loading branch information
Pritish Budhiraja authored Jan 19, 2024
2 parents 5cf9ff3 + 23c1ecb commit 0a2d4c9
Show file tree
Hide file tree
Showing 37 changed files with 369 additions and 932 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,31 @@ All notable changes to this project will be documented in this file. See [conven

- - -

## 1.26.0 (2024-01-18)

### Features

- Add new user ([#237](https://github.com/juspay/hyperswitch-control-center/pull/237)) ([`3749e32`](https://github.com/juspay/hyperswitch-control-center/commit/3749e3278602c2ad514079db3d6d78226cfa9391))
- Access added for Button ([#274](https://github.com/juspay/hyperswitch-control-center/pull/274)) ([`d5ecee6`](https://github.com/juspay/hyperswitch-control-center/commit/d5ecee626d3da87f6bda8495b7539ba8660a7618))

### Bug Fixes

- Floating point value fix for test payment ([#270](https://github.com/juspay/hyperswitch-control-center/pull/270)) ([`038a714`](https://github.com/juspay/hyperswitch-control-center/commit/038a71492de22f1a1a51b6de9f68f010bf872268))

### Refactors

- Routing types and utils ([#254](https://github.com/juspay/hyperswitch-control-center/pull/254)) ([`b8b5034`](https://github.com/juspay/hyperswitch-control-center/commit/b8b5034fbae6974e34c799e6f9333e3663247f7f))

### Miscellaneous Tasks

- Added Access Type & Remove the Read & ReadWrite Type ([#267](https://github.com/juspay/hyperswitch-control-center/pull/267)) ([`49e3eae`](https://github.com/juspay/hyperswitch-control-center/commit/49e3eaeb9bd14a3c788649b81cf561386a5ce006))
- Refactor invite users ([#273](https://github.com/juspay/hyperswitch-control-center/pull/273)) ([`85b07d0`](https://github.com/juspay/hyperswitch-control-center/commit/85b07d0cf058dd0842b11acb7714cd85f8d9d6c6))

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

- - -


## 1.25.1 (2024-01-17)

### Miscellaneous Tasks
Expand Down
196 changes: 98 additions & 98 deletions src/components/Button.res
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ let make = (
~customBackColor=?,
~isPhoneDropdown=false,
~showBtnTextToolTip=false,
~access=AuthTypes.Access,
) => {
let parentRef = React.useRef(Js.Nullable.null)
let dummyRef = React.useRef(Js.Nullable.null)
Expand Down Expand Up @@ -695,110 +696,109 @@ let make = (
: ""} ${customBackColor->Belt.Option.getWithDefault(
backColor,
)} ${customRoundedClass->Belt.Option.getWithDefault(roundedClass)}`

let newThemeGap = ""

<AddDataAttributes attributes=[(dataAttrKey, dataAttrStr)]>
<button
type_
disabled=dis
ref={parentRef->ReactDOM.Ref.domRef}
onKeyUp={e => e->ReactEvent.Keyboard.preventDefault}
onKeyPress={e => {
if !onEnterPress {
e->ReactEvent.Keyboard.preventDefault
}
}}
className={`flex group ${customButtonStyle->String.includes("justify")
? ""
: "justify-center"} ${relativeClass} ${heightClass} ${newThemeGap} ${conditionalButtonStyles} items-center ${borderStyle} ${textColor} ${cursorType} ${paddingClass} ${lengthStyle} ${customButtonStyle} ${customTextOverFlowClass}`}
onClick=handleClick>
{if buttonState == Loading {
<span className={iconPadding}>
<span className={`flex items-center mx-2 animate-spin`}>
<Loadericon size=iconSize iconColor=?loaderIconColor />
let customJustifyStyle = customButtonStyle->String.includes("justify") ? "" : "justify-center"

<UIUtils.RenderIf condition={access !== AuthTypes.NoAccess}>
<AddDataAttributes attributes=[(dataAttrKey, dataAttrStr)]>
<button
type_
disabled=dis
ref={parentRef->ReactDOM.Ref.domRef}
onKeyUp={e => e->ReactEvent.Keyboard.preventDefault}
onKeyPress={e => {
if !onEnterPress {
e->ReactEvent.Keyboard.preventDefault
}
}}
className={`flex group ${customJustifyStyle} ${relativeClass} ${heightClass} ${conditionalButtonStyles} items-center ${borderStyle} ${textColor} ${cursorType} ${paddingClass} ${lengthStyle} ${customButtonStyle} ${customTextOverFlowClass}`}
onClick=handleClick>
{if buttonState == Loading {
<span className={iconPadding}>
<span className={`flex items-center mx-2 animate-spin`}>
<Loadericon size=iconSize iconColor=?loaderIconColor />
</span>
</span>
</span>
} else {
switch leftIcon {
} else {
switch leftIcon {
| FontAwesome(iconName) =>
<span className={`flex items-center ${iconColor} ${iconMargin} ${iconPadding}`}>
<Icon
className={`align-middle ${strokeColor} ${iconBorderColor}`}
size=iconSize
name=iconName
/>
</span>
| Euler(iconName) =>
<span className={`flex items-center ${iconColor} ${iconMargin} ${eulerIconPadding}`}>
<Icon className={`align-middle ${strokeColor}`} size=iconSize name=iconName />
</span>
| CustomIcon(element) =>
<span className={`flex items-center ${iconMargin}`}> {element} </span>
| _ => React.null
}
}}
{switch text {
| Some(textStr) =>
if !(textStr->LogicUtils.isEmptyString) {
let btnContent =
<AddDataAttributes attributes=[("data-button-text", textStr)]>
<div
className={`${textPaddingClass} ${textSize} ${textWeight} ${ellipsisClass} whitespace-pre ${textStyle}`}>
{buttonState == Loading ? React.string(loadingText) : React.string(textStr)}
</div>
</AddDataAttributes>

if showBtnTextToolTip {
<div className=ellipsisParentClass>
<ToolTip
description=textStr
toolTipFor=btnContent
contentAlign=Default
justifyClass="justify-start"
/>
</div>
} else {
<div className=ellipsisParentClass> btnContent </div>
}
} else {
React.null
}

| None => React.null
}}
{switch badge.color {
| NoBadge => React.null
| _ =>
<AddDataAttributes attributes=[("data-badge-value", badge.value)]>
<span
className={`flex items-center ${rightIconSpacing} ${badgeColor} ${badgeTextColor} ${badgeSpacing} ${badgeTextSize} rounded-full`}>
{React.string(badge.value)}
</span>
</AddDataAttributes>
}}
{switch buttonRightText {
| Some(text) =>
<UIUtils.RenderIf condition={!(text->LogicUtils.isEmptyString)}>
<span className="text-jp-2-light-primary-600 font-semibold text-fs-14">
{React.string(text)}
</span>
</UIUtils.RenderIf>
| None => React.null
}}
{switch rightIcon {
| FontAwesome(iconName) =>
<span className={`flex items-center ${iconColor} ${iconMargin} ${iconPadding}`}>
<Icon
className={`align-middle ${strokeColor} ${iconBorderColor}`}
size=iconSize
name=iconName
/>
<span className={`flex items-center ${rightIconSpacing}`}>
<Icon className={`align-middle ${strokeColor}`} size=iconSize name=iconName />
</span>
| Euler(iconName) =>
<span className={`flex items-center ${iconColor} ${iconMargin} ${eulerIconPadding}`}>
<span className={`flex items-center ${iconMargin} ${eulerIconPadding}`}>
<Icon className={`align-middle ${strokeColor}`} size=iconSize name=iconName />
</span>
| CustomIcon(element) =>
<span className={`flex items-center ${iconMargin}`}> {element} </span>
<span className={`flex items-center ${iconPadding} `}> {element} </span>
| _ => React.null
}
}}
{switch text {
| Some(textStr) =>
if textStr !== "" {
let btnContent =
<AddDataAttributes attributes=[("data-button-text", textStr)]>
<div
className={`${textPaddingClass} ${textSize} ${textWeight} ${ellipsisClass} whitespace-pre ${textStyle}`}>
{buttonState == Loading ? React.string(loadingText) : React.string(textStr)}
</div>
</AddDataAttributes>

if showBtnTextToolTip {
<div className=ellipsisParentClass>
<ToolTip
description=textStr
toolTipFor=btnContent
contentAlign=Default
justifyClass="justify-start"
/>
</div>
} else {
<div className=ellipsisParentClass> btnContent </div>
}
} else {
React.null
}

| None => React.null
}}
{switch badge.color {
| NoBadge => React.null
| _ =>
<AddDataAttributes attributes=[("data-badge-value", badge.value)]>
<span
className={`flex items-center ${rightIconSpacing} ${badgeColor} ${badgeTextColor} ${badgeSpacing} ${badgeTextSize} rounded-full`}>
{React.string(badge.value)}
</span>
</AddDataAttributes>
}}
{switch buttonRightText {
| Some(text) =>
<UIUtils.RenderIf condition={text !== ""}>
<span className="text-jp-2-light-primary-600 font-semibold text-fs-14">
{React.string(text)}
</span>
</UIUtils.RenderIf>
| None => React.null
}}
{switch rightIcon {
| FontAwesome(iconName) =>
<span className={`flex items-center ${rightIconSpacing}`}>
<Icon className={`align-middle ${strokeColor}`} size=iconSize name=iconName />
</span>
| Euler(iconName) =>
<span className={`flex items-center ${iconMargin} ${eulerIconPadding}`}>
<Icon className={`align-middle ${strokeColor}`} size=iconSize name=iconName />
</span>
| CustomIcon(element) =>
<span className={`flex items-center ${iconPadding} `}> {element} </span>
| _ => React.null
}}
</button>
</AddDataAttributes>
}}
</button>
</AddDataAttributes>
</UIUtils.RenderIf>
}
5 changes: 3 additions & 2 deletions src/components/Button.resi
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ let useGetTextColor: (
) => string
@react.component
let make: (
~buttonFor: Js.String2.t=?,
~buttonFor: string=?,
~loadingText: string=?,
~buttonState: buttonState=?,
~text: Js.String2.t=?,
Expand All @@ -101,7 +101,7 @@ let make: (
~textWeight: string=?,
~fullLength: bool=?,
~disableRipple: bool=?,
~customButtonStyle: Js.String2.t=?,
~customButtonStyle: string=?,
~textStyleClass: string=?,
~customTextPaddingClass: string=?,
~allowButtonTextMinWidth: bool=?,
Expand All @@ -115,4 +115,5 @@ let make: (
~customBackColor: string=?,
~isPhoneDropdown: bool=?,
~showBtnTextToolTip: bool=?,
~access: AuthTypes.authorization=?,
) => React.element
75 changes: 11 additions & 64 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=ReadWrite,
~renderList=() => <ComingSoon title="List" />,
~renderNewForm=() => <ComingSoon title="New Form" />,
~access: AuthTypes.authorization=Access,
~renderList,
~renderNewForm=?,
~renderShow=?,
~renderOrder=?,
~renderEdit=_id => <ComingSoon title="Edit Form" />,
~renderEditWithMultiId=(_id1, _id2) => <ComingSoon title="Edit Form" />,
~renderClone=_id => <ComingSoon title="Clone Form" />,
) => {
if access === NoAccess {
<UnauthorizedPage entityName />
<UnauthorizedPage />
} else {
switch remainingPath {
| list{"new"} =>
switch access {
| ReadWrite => renderNewForm()
| _ => <UnauthorizedPage entityName />
}
| list{id, "clone"} =>
switch access {
| ReadWrite => renderClone(id)
| _ => <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 {
| ReadWrite => renderEdit(id)
| _ => <UnauthorizedPage entityName />
}
| list{id1, id2, "edit"} =>
switch access {
| ReadWrite => renderEditWithMultiId(id1, id2)
| _ => <UnauthorizedPage entityName />
}
| list{"order", id} =>
switch renderOrder {
| Some(fn) => fn(id)
| None => <NotFoundPage />
}
| list{} => renderList()
| _ => <NotFoundPage />
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/HyperSwitchAuthWrapper.res
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let make = (~children) => {
| _ =>
switch LocalStorage.getItem("login")->Js.Nullable.toOption {
| Some(token) =>
if !(token->HSwitchUtils.isEmptyString) {
if !(token->LogicUtils.isEmptyString) {
setAuthStatus(LoggedIn(HyperSwitchAuthTypes.getDummyAuthInfoForToken(token)))
} else {
setAuthStatus(LoggedOut)
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>
}
Loading

0 comments on commit 0a2d4c9

Please sign in to comment.