Skip to content

Commit d85ee5f

Browse files
committed
Dashboard: add "Contracts" link in contract layout header (#7436)
![image.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/yNOf1svJ8o3zjO7zQouZ/05f5e0d2-cfee-4604-8567-a630e13f8232.png) <!-- ## 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 introduces a new optional property, `currentProjectSubpath`, to enhance the `TeamHeader` components by allowing the display of additional project navigation details, including a label, href, and icon. ### Detailed summary - Added `currentProjectSubpath` property to `TeamHeaderLoggedIn` and `TeamHeaderDesktopUI`. - Updated `TeamHeaderUI` to render project subpath details if provided. - Introduced a new story in `TeamHeaderUI.stories.tsx` to showcase the `currentProjectSubpath` feature. - Integrated `currentProjectSubpath` into the `ContractLayout` component for enhanced navigation. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added support for displaying an active project subpage link with an icon in the team header, enhancing breadcrumb navigation for projects. - Updated the team header to visually indicate the current subpage within a project. - **Documentation** - Added a new Storybook variant to demonstrate the team header with an active subpage link. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 8bb4d4b commit d85ee5f

File tree

4 files changed

+58
-5
lines changed

4 files changed

+58
-5
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/contract/[chainIdOrSlug]/[contractAddress]/layout.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { redirect } from "next/navigation";
2+
import { getAuthToken, getAuthTokenWalletAddress } from "@/api/auth-token";
23
import { getProjects } from "@/api/projects";
34
import { getTeams } from "@/api/team";
45
import { AppFooter } from "@/components/footers/app-footer";
56
import { getClientThirdwebClient } from "@/constants/thirdweb-client.client";
6-
import {
7-
getAuthToken,
8-
getAuthTokenWalletAddress,
9-
} from "../../../../../../../../@/api/auth-token";
10-
import { ErrorProvider } from "../../../../../../../../@/contexts/error-handler";
7+
import { ErrorProvider } from "@/contexts/error-handler";
8+
import { ContractIcon } from "@/icons/ContractIcon";
119
import { SharedContractLayout } from "../../../../../../(dashboard)/(chain)/[chain_id]/[contractAddress]/shared-layout";
1210
import { getValidAccount } from "../../../../../../account/settings/getAccount";
1311
import { TeamHeaderLoggedIn } from "../../../../../components/TeamHeader/team-header-logged-in.client";
@@ -68,6 +66,11 @@ export default async function ContractLayout(props: {
6866
accountAddress={accountAddress}
6967
client={client}
7068
currentProject={project}
69+
currentProjectSubpath={{
70+
href: `/team/${params.team_slug}/${params.project_slug}/contracts`,
71+
icon: <ContractIcon />,
72+
label: "Contracts",
73+
}}
7174
currentTeam={team}
7275
teamsAndProjects={teamsAndProjects}
7376
/>

apps/dashboard/src/app/(app)/team/components/TeamHeader/TeamHeaderUI.stories.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Meta, StoryObj } from "@storybook/nextjs";
2+
import { BoxIcon } from "lucide-react";
23
import { ThirdwebProvider } from "thirdweb/react";
34
import type { Project } from "@/api/projects";
45
import type { Team } from "@/api/team";
@@ -119,6 +120,19 @@ function Variants(props: { type: "mobile" | "desktop" }) {
119120
type={props.type}
120121
/>
121122
</BadgeContainer>
123+
124+
<BadgeContainer label="Pro Plan - active subpage">
125+
<Variant
126+
currentProject={proTeam.projects[0]}
127+
currentProjectSubpath={{
128+
href: "/team/project/foo",
129+
icon: <BoxIcon />,
130+
label: "Foo",
131+
}}
132+
team={proTeam.team}
133+
type={props.type}
134+
/>
135+
</BadgeContainer>
122136
</div>
123137
</ThirdwebProvider>
124138
);
@@ -132,6 +146,11 @@ function Variant(props: {
132146
team: Team;
133147
type: "mobile" | "desktop";
134148
currentProject?: Project;
149+
currentProjectSubpath?: {
150+
label: string;
151+
href: string;
152+
icon: React.ReactNode;
153+
};
135154
}) {
136155
const Comp =
137156
props.type === "mobile" ? TeamHeaderMobileUI : TeamHeaderDesktopUI;
@@ -149,6 +168,7 @@ function Variant(props: {
149168
createProject={() => {}}
150169
createTeam={() => {}}
151170
currentProject={undefined}
171+
currentProjectSubpath={props.currentProjectSubpath}
152172
currentTeam={props.team}
153173
logout={() => {}}
154174
teamsAndProjects={teamsAndProjectsStub}

apps/dashboard/src/app/(app)/team/components/TeamHeader/TeamHeaderUI.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ export type TeamHeaderCompProps = {
2121
currentTeam: Team;
2222
teamsAndProjects: Array<{ team: Team; projects: Project[] }>;
2323
currentProject: Project | undefined;
24+
currentProjectSubpath:
25+
| {
26+
label: string;
27+
icon: React.ReactNode;
28+
href: string;
29+
}
30+
| undefined;
2431
className?: string;
2532
account: Pick<Account, "email" | "id">;
2633
logout: () => void;
@@ -107,6 +114,23 @@ export function TeamHeaderDesktopUI(props: TeamHeaderCompProps) {
107114
teamsAndProjects={props.teamsAndProjects}
108115
/>
109116
</div>
117+
118+
{props.currentProjectSubpath && (
119+
<>
120+
<SlashSeparator />
121+
<div className="flex items-center gap-1.5">
122+
<div className="flex items-center justify-center rounded-full border size-6 [&>svg]:size-[50%] [&>svg]:text-muted-foreground">
123+
{props.currentProjectSubpath.icon}
124+
</div>
125+
<Link
126+
className="flex flex-row items-center gap-2 font-semibold text-sm"
127+
href={props.currentProjectSubpath.href}
128+
>
129+
{props.currentProjectSubpath.label}
130+
</Link>
131+
</div>
132+
</>
133+
)}
110134
</>
111135
)}
112136
</div>

apps/dashboard/src/app/(app)/team/components/TeamHeader/team-header-logged-in.client.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ export function TeamHeaderLoggedIn(props: {
2828
account: Pick<Account, "email" | "id">;
2929
accountAddress: string;
3030
client: ThirdwebClient;
31+
currentProjectSubpath?: {
32+
label: string;
33+
href: string;
34+
icon: React.ReactNode;
35+
};
3136
}) {
3237
// identify the account
3338
useIdentifyAccount({
@@ -89,6 +94,7 @@ export function TeamHeaderLoggedIn(props: {
8994
);
9095
},
9196
currentProject: props.currentProject,
97+
currentProjectSubpath: props.currentProjectSubpath,
9298
currentTeam: props.currentTeam,
9399
logout: logout,
94100
teamsAndProjects: props.teamsAndProjects,

0 commit comments

Comments
 (0)