Skip to content

Commit 7a1099b

Browse files
committed
Make rows in contract table actual links to allow opening in new tab with cmd click (#5142)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on enhancing the `DeployedContractsPageHeader` and related components by improving the link handling for contract names and refining the UI elements in the contract table. ### Detailed summary - Updated `DeployedContractsPageHeader` to use a new `Button` import. - Added `linkOverlay` prop to `AsyncContractNameCell`. - Enhanced link styling in `AsyncContractNameCell` with conditional classes. - Passed `linkOverlay` prop when rendering `AsyncContractNameCell` in the contract table. - Simplified event handling in `ContractTableRow`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 4e5fdcf commit 7a1099b

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

apps/dashboard/src/app/team/[team_slug]/[project_slug]/contracts/DeployedContractsPageHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"use client";
22

3+
import { Button } from "@/components/ui/button";
34
import { DownloadIcon, PlusIcon } from "lucide-react";
45
import Link from "next/link";
56
import { useState } from "react";
6-
import { Button } from "../../../../../@/components/ui/button";
77
import { ImportModal } from "../../../../../components/contract-components/import-contract/modal";
88

99
export function DeployedContractsPageHeader() {

apps/dashboard/src/components/contract-components/tables/cells.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { Badge } from "@/components/ui/badge";
44
import { SkeletonContainer } from "@/components/ui/skeleton";
55
import { useThirdwebClient } from "@/constants/thirdweb.client";
6+
import { cn } from "@/lib/utils";
67
import { useDashboardContractMetadata } from "@3rdweb-sdk/react/hooks/useDashboardContractMetadata";
78
import type { BasicContract } from "contract-ui/types/types";
89
import { useChainSlug } from "hooks/chains/chainSlug";
@@ -16,13 +17,14 @@ import { usePublishedContractsFromDeploy } from "../hooks";
1617

1718
interface AsyncContractNameCellProps {
1819
cell: BasicContract;
20+
linkOverlay?: boolean;
1921
}
2022

2123
// The row components for the contract table, in the <Your contracts> page
2224
// url: /dashboard/contracts/deploy
2325

2426
export const AsyncContractNameCell = memo(
25-
({ cell }: AsyncContractNameCellProps) => {
27+
({ cell, linkOverlay }: AsyncContractNameCellProps) => {
2628
const chainSlug = useChainSlug(cell.chainId);
2729
const chain = useV5DashboardChain(cell.chainId);
2830
const client = useThirdwebClient();
@@ -46,7 +48,10 @@ export const AsyncContractNameCell = memo(
4648
<Link
4749
href={`/${chainSlug}/${cell.address}`}
4850
passHref
49-
className="text-foreground"
51+
className={cn(
52+
"text-foreground",
53+
linkOverlay && "before:absolute before:inset-0",
54+
)}
5055
>
5156
{v || shortenIfAddress(cell.address)}
5257
</Link>

apps/dashboard/src/components/contract-components/tables/deployed-contracts.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import {
1919
TableHeader,
2020
TableRow,
2121
} from "@/components/ui/table";
22-
import { useDashboardRouter } from "@/lib/DashboardRouter";
2322
import {
2423
type useAllContractList,
2524
useRemoveContractMutation,
@@ -38,7 +37,6 @@ import {
3837
useTable,
3938
} from "react-table";
4039
import { useAllChainsData } from "../../../hooks/chains/allChains";
41-
import { useChainSlug } from "../../../hooks/chains/chainSlug";
4240
import { AsyncContractNameCell, AsyncContractTypeCell } from "./cells";
4341
import { ShowMoreButton } from "./show-more-button";
4442

@@ -174,7 +172,7 @@ const ContractTable: React.FC<ContractTableProps> = ({
174172
accessor: (row) => row.address,
175173
// biome-ignore lint/suspicious/noExplicitAny: FIXME
176174
Cell: (cell: any) => {
177-
return <AsyncContractNameCell cell={cell.row.original} />;
175+
return <AsyncContractNameCell cell={cell.row.original} linkOverlay />;
178176
},
179177
},
180178
{
@@ -231,6 +229,7 @@ const ContractTable: React.FC<ContractTableProps> = ({
231229
copyIconPosition="left"
232230
address={cell.row.original.address}
233231
variant="ghost"
232+
className="relative z-10"
234233
/>
235234
);
236235
},
@@ -245,6 +244,7 @@ const ContractTable: React.FC<ContractTableProps> = ({
245244
<Button
246245
size="icon"
247246
variant="ghost"
247+
className="relative z-10"
248248
onClick={(e) => e.stopPropagation()}
249249
>
250250
<EllipsisVerticalIcon className="size-4" />
@@ -367,20 +367,14 @@ const ContractTable: React.FC<ContractTableProps> = ({
367367
};
368368

369369
const ContractTableRow = memo(({ row }: { row: Row<BasicContract> }) => {
370-
const chainSlug = useChainSlug(row.original.chainId);
371-
const router = useDashboardRouter();
372370
// eslint-disable-next-line @typescript-eslint/no-unused-vars
373371
const { key, ...rowProps } = row.getRowProps();
374372

375373
return (
376374
<TableRow
377375
{...rowProps}
378376
role="group"
379-
className="cursor-pointer hover:bg-muted/50"
380-
// TODO - replace this with before:absolute thing
381-
onClick={() => {
382-
router.push(`/${chainSlug}/${row.original.address}`);
383-
}}
377+
className="relative cursor-pointer hover:bg-muted/50"
384378
>
385379
{row.cells.map((cell, cellIndex) => {
386380
return (

0 commit comments

Comments
 (0)