Skip to content

Commit 73ae581

Browse files
committed
[TOOL-3763] Dashboard: Update Contracts page (#6611)
<!-- ## title your PR with this format: "[SDK/Dashboard/Portal] Feature/Fix: Concise title for the changes" If you did not copy the branch name from Linear, paste the issue tag here (format is TEAM-0000): ## Notes for the reviewer Anything important to call out? Be sure to also clarify these in your comments. ## How to test Unit tests, playground, etc. --> <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on enhancing the user interface and functionality of the contracts management section. It introduces new components and modifies existing ones to improve user experience, particularly around contract deployment and management. ### Detailed summary - Removed the `GetStartedWithContractsDeploy` component. - Added `DeployViaCLIOrImportCard` component for contract deployment options. - Updated the `DeployedContractsPage` to include the new `DeployViaCLIOrImportCard`. - Modified the `ContractTableUI` to display a message and button when no contracts are present. - Increased the height of the no contracts message section. - Added a link to discover contracts with an external icon. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 6a0704a commit 73ae581

File tree

5 files changed

+75
-153
lines changed

5 files changed

+75
-153
lines changed

apps/dashboard/src/app/account/contracts/DeployedContractsPageHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export function DeployedContractsPageHeader(props: {
2323
projectId={props.projectId}
2424
/>
2525

26-
<div className="flex flex-col gap-3 pb-6 lg:flex-row lg:items-center lg:justify-between">
26+
<div className="flex flex-col gap-3 pt-2 pb-8 lg:flex-row lg:items-center lg:justify-between">
2727
<div>
2828
<h1 className="font-semibold text-3xl tracking-tight">Contracts</h1>
2929
</div>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
"use client";
2+
3+
import { Button } from "@/components/ui/button";
4+
import { ArrowUpRightIcon, DownloadIcon } from "lucide-react";
5+
import Link from "next/link";
6+
import { useState } from "react";
7+
import { ImportModal } from "../../../../components/contract-components/import-contract/modal";
8+
9+
export function DeployViaCLIOrImportCard(props: {
10+
teamId: string;
11+
projectId: string;
12+
}) {
13+
const [importModalOpen, setImportModalOpen] = useState(false);
14+
15+
return (
16+
<div className="rounded-lg border bg-card p-6">
17+
<ImportModal
18+
isOpen={importModalOpen}
19+
onClose={() => {
20+
setImportModalOpen(false);
21+
}}
22+
teamId={props.teamId}
23+
projectId={props.projectId}
24+
/>
25+
26+
<h2 className="mb-0.5 font-semibold text-lg">
27+
Already have a smart contract?
28+
</h2>
29+
<p className="max-w-2xl text-muted-foreground">
30+
Import an already deployed contract or deploy a contract from source
31+
code to easily manage permissions, upload assets, and interact with
32+
contract functions
33+
</p>
34+
35+
<div className="mt-6 flex gap-3">
36+
<Button variant="outline" className="gap-2 lg:px-20" asChild>
37+
<Link
38+
href="https://portal.thirdweb.com/contracts/deploy/overview"
39+
target="_blank"
40+
>
41+
Deploy via CLI
42+
<ArrowUpRightIcon className="size-4" />
43+
</Link>
44+
</Button>
45+
<Button
46+
variant="outline"
47+
className="gap-2 lg:px-6"
48+
onClick={() => setImportModalOpen(true)}
49+
>
50+
<DownloadIcon className="size-4" />
51+
Import Contract
52+
</Button>
53+
</div>
54+
</div>
55+
);
56+
}

apps/dashboard/src/app/account/contracts/_components/DeployedContractsPage.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ClientOnly } from "components/ClientOnly/ClientOnly";
33
import { Suspense } from "react";
44
import { ContractTable } from "../../../../components/contract-components/tables/contract-table";
55
import { DeployedContractsPageHeader } from "../DeployedContractsPageHeader";
6-
import { GetStartedWithContractsDeploy } from "./GetStartedWithContractsDeploy";
6+
import { DeployViaCLIOrImportCard } from "./DeployViaCLIOrImportCard";
77
import { getSortedDeployedContracts } from "./getSortedDeployedContracts";
88

99
export function DeployedContractsPage(props: {
@@ -21,6 +21,11 @@ export function DeployedContractsPage(props: {
2121
<Suspense fallback={<Loading />}>
2222
<DeployedContractsPageAsync {...props} />
2323
</Suspense>
24+
<div className="h-8" />
25+
<DeployViaCLIOrImportCard
26+
teamId={props.teamId}
27+
projectId={props.projectId}
28+
/>
2429
</div>
2530
</div>
2631
);
@@ -37,15 +42,6 @@ async function DeployedContractsPageAsync(props: {
3742
authToken: props.authToken,
3843
});
3944

40-
if (deployedContracts.length === 0) {
41-
return (
42-
<GetStartedWithContractsDeploy
43-
teamId={props.teamId}
44-
projectId={props.projectId}
45-
/>
46-
);
47-
}
48-
4945
return (
5046
<ClientOnly ssr={<Loading />}>
5147
<ContractTable

apps/dashboard/src/app/account/contracts/_components/GetStartedWithContractsDeploy.tsx

Lines changed: 0 additions & 139 deletions
This file was deleted.

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import {
2222
import { useMutation } from "@tanstack/react-query";
2323
import { ChainIcon } from "components/icons/ChainIcon";
2424
import { NetworkSelectDropdown } from "components/selects/NetworkSelectDropdown";
25-
import { EllipsisVerticalIcon, XIcon } from "lucide-react";
25+
import { EllipsisVerticalIcon, ExternalLinkIcon, XIcon } from "lucide-react";
26+
import Link from "next/link";
2627
import { useCallback, useEffect, useMemo, useState } from "react";
2728
import React from "react";
2829
import { toast } from "sonner";
@@ -202,8 +203,16 @@ export function ContractTableUI(props: {
202203
</Table>
203204

204205
{contracts.length === 0 && (
205-
<div className="flex h-[200px] items-center justify-center text-muted-foreground">
206-
No Contracts
206+
<div className="flex h-[350px] items-center justify-center text-muted-foreground">
207+
<div className="text-center">
208+
<p className="mb-3">No contracts added to project</p>
209+
<Button variant="outline" asChild className="bg-background">
210+
<Link href="/explore" target="_blank">
211+
Discover Contracts
212+
<ExternalLinkIcon className="ml-2 size-4" />
213+
</Link>
214+
</Button>
215+
</div>
207216
</div>
208217
)}
209218
</TableContainer>

0 commit comments

Comments
 (0)