Skip to content

Commit

Permalink
Merge pull request #285 from gnosisguild/fix-diff-align
Browse files Browse the repository at this point in the history
Fix diff view alignments & permission anchors
  • Loading branch information
jfschwarz authored Aug 21, 2024
2 parents 054bcc5 + 1fe47fd commit 37f59b4
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,21 @@ const FunctionPermissionItem: React.FC<
abi,
modified,
condition,
...rest
send,
delegatecall,
}) => {
const functionAbi = abi?.find(
(fragment) =>
(fragment: any) =>
fragment.type === "function" && toFunctionSelector(fragment) === selector
) as AbiFunction | undefined

return (
<DiffBox
diff={diff}
modified={
modified && <FunctionPermissionItem {...modified} chainId={chainId} />
modified && (
<FunctionPermissionItem {...modified} chainId={chainId} abi={abi} />
)
}
>
<div className={classes.functionContainer}>
Expand All @@ -46,14 +49,16 @@ const FunctionPermissionItem: React.FC<
selector={selector}
abi={functionAbi}
condition={condition}
{...rest}
send={send}
delegatecall={delegatecall}
/>
) : (
<RawFunctionPermissionItem
targetAddress={targetAddress}
selector={selector}
condition={condition}
{...rest}
send={send}
delegatecall={delegatecall}
/>
)}
<div className={classes.verticalGuide} />
Expand Down
18 changes: 17 additions & 1 deletion packages/app/components/permissions/annotations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe("processAnnotations()", () => {
"explode": false,
"in": "query",
"name": "buy",
"required": true,
"required": false,
"schema": {
"deprecated": false,
"items": {
Expand All @@ -100,6 +100,22 @@ describe("processAnnotations()", () => {
},
"style": "form",
},
{
"allowEmptyValue": false,
"allowReserved": false,
"explode": false,
"in": "query",
"name": "feeAmountBp",
"required": false,
"schema": {
"deprecated": false,
"maximum": 10000,
"minimum": 0,
"nullable": false,
"type": "integer",
},
"style": "form",
},
],
"summary": "Make swaps on cowswap",
"tags": [
Expand Down
10 changes: 3 additions & 7 deletions packages/app/ui/Anchor/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client"
import { ReactNode, createContext, useContext, useEffect } from "react"
import { RiLinkM } from "react-icons/ri"
import { IconLinkButton } from "../IconButton"
import { IconAButton } from "../IconButton"

const AnchorContext = createContext<string>("")

Expand Down Expand Up @@ -44,13 +44,9 @@ const Anchor: React.FC<{
}, [uniqueName])

return (
<IconLinkButton
id={uniqueName}
href={"#" + uniqueName}
className={className}
>
<IconAButton id={uniqueName} href={"#" + uniqueName} className={className}>
<RiLinkM />
</IconLinkButton>
</IconAButton>
)
}

Expand Down
17 changes: 16 additions & 1 deletion packages/app/ui/IconButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import cn from "classnames"
import React from "react"
import React, { AnchorHTMLAttributes } from "react"

import classes from "./style.module.css"
import Link from "next/link"
Expand Down Expand Up @@ -38,3 +38,18 @@ export const IconLinkButton: React.FC<
{...rest}
/>
)

export const IconAButton: React.FC<
AnchorHTMLAttributes<HTMLAnchorElement> & {
danger?: boolean
small?: boolean
}
> = ({ className, danger, small, ...rest }) => (
<a
className={cn(classes.button, className, {
[classes.danger]: danger,
[classes.small]: small,
})}
{...rest}
/>
)

0 comments on commit 37f59b4

Please sign in to comment.