Skip to content

Commit e188b34

Browse files
authored
Dashboard: Move Engine pages (#7393)
1 parent ffbea7f commit e188b34

File tree

40 files changed

+225
-174
lines changed

40 files changed

+225
-174
lines changed

apps/dashboard/redirects.js

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,51 @@ const legacyDashboardToTeamRedirects = [
6262
},
6363
];
6464

65+
const projectRoute = "/team/:team_slug/:project_slug";
66+
67+
const projectPageRedirects = [
68+
{
69+
source: `${projectRoute}/connect/pay/:path*`,
70+
destination: `${projectRoute}/universal-bridge/:path*`,
71+
permanent: false,
72+
},
73+
{
74+
source: `${projectRoute}/connect/universal-bridge/:path*`,
75+
destination: `${projectRoute}/universal-bridge/:path*`,
76+
permanent: false,
77+
},
78+
{
79+
source: `${projectRoute}/connect/account-abstraction/:path*`,
80+
destination: `${projectRoute}/account-abstraction/:path*`,
81+
permanent: false,
82+
},
83+
{
84+
source: `${projectRoute}/connect/in-app-wallets/:path*`,
85+
destination: `${projectRoute}/wallets/:path*`,
86+
permanent: false,
87+
},
88+
{
89+
source: `${projectRoute}/engine/cloud/vault/:path*`,
90+
destination: `${projectRoute}/vault/:path*`,
91+
permanent: false,
92+
},
93+
{
94+
source: `${projectRoute}/engine/cloud/:path*`,
95+
destination: `${projectRoute}/transactions/:path*`,
96+
permanent: false,
97+
},
98+
{
99+
source: `${projectRoute}/assets/:path*`,
100+
destination: `${projectRoute}/tokens/:path*`,
101+
permanent: false,
102+
},
103+
{
104+
source: `${projectRoute}/nebula/:path*`,
105+
destination: projectRoute,
106+
permanent: false,
107+
},
108+
];
109+
65110
/** @type {import('next').NextConfig['redirects']} */
66111
async function redirects() {
67112
return [
@@ -326,14 +371,6 @@ async function redirects() {
326371
destination: "/",
327372
permanent: false,
328373
},
329-
// pay > universal-bridge redirect
330-
{
331-
source: "/team/:team_slug/:project_slug/connect/pay/:path*",
332-
destination:
333-
"/team/:team_slug/:project_slug/connect/universal-bridge/:path*",
334-
permanent: false,
335-
},
336-
337374
// all /learn/tutorials (and sub-routes) -> /learn/guides
338375
{
339376
source: "/learn/tutorials/:path*",
@@ -382,8 +419,8 @@ async function redirects() {
382419
destination: "/transactions",
383420
permanent: false,
384421
},
385-
386422
...legacyDashboardToTeamRedirects,
423+
...projectPageRedirects,
387424
];
388425
}
389426

apps/dashboard/src/@/components/blocks/Sidebar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type SidebarBaseLink = {
99
label: React.ReactNode;
1010
exactMatch?: boolean;
1111
icon?: React.FC<{ className?: string }>;
12+
isActive?: (pathname: string) => boolean;
1213
};
1314

1415
export type SidebarLink =

apps/dashboard/src/@/components/blocks/SidebarLayout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ function RenderSidebarGroup(props: {
123123
className="flex items-center gap-2 text-muted-foreground text-sm hover:bg-accent"
124124
activeClassName="text-foreground bg-accent"
125125
exactMatch={link.exactMatch}
126+
isActive={link.isActive}
126127
onClick={() => {
127128
sidebar.setOpenMobile(false);
128129
}}

apps/dashboard/src/@/components/ui/NavLink.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@ export type NavButtonProps = {
1111
href: string;
1212
exactMatch?: boolean;
1313
onClick?: () => void;
14+
isActive?: (pathname: string) => boolean;
1415
};
1516

1617
export function NavLink(props: React.PropsWithChildren<NavButtonProps>) {
1718
const pathname = usePathname();
18-
const isActive = pathname
19-
? props.exactMatch
20-
? pathname === props.href
21-
: pathname.startsWith(props.href)
22-
: false;
19+
const isActive = props.isActive
20+
? props.isActive(pathname)
21+
: pathname
22+
? props.exactMatch
23+
? pathname === props.href
24+
: pathname.startsWith(props.href)
25+
: false;
2326
return (
2427
<Link
2528
href={props.href}

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/components/ProjectSidebarLayout.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ import { SmartAccountIcon } from "../../../../../(dashboard)/(chain)/components/
1919

2020
export function ProjectSidebarLayout(props: {
2121
layoutPath: string;
22+
engineLinkType: "cloud" | "dedicated";
2223
children: React.ReactNode;
2324
}) {
24-
const { layoutPath, children } = props;
25+
const { layoutPath, engineLinkType, children } = props;
2526

2627
return (
2728
<FullWidthSidebarLayout
@@ -62,9 +63,18 @@ export function ProjectSidebarLayout(props: {
6263
icon: CoinsIcon,
6364
},
6465
{
65-
href: `${layoutPath}/engine`,
66+
href:
67+
engineLinkType === "cloud"
68+
? `${layoutPath}/transactions`
69+
: `${layoutPath}/engine/dedicated`,
6670
label: "Transactions",
6771
icon: ArrowLeftRightIcon,
72+
isActive: (pathname) => {
73+
return (
74+
pathname.startsWith(`${layoutPath}/transactions`) ||
75+
pathname.startsWith(`${layoutPath}/engine/dedicated`)
76+
);
77+
},
6878
},
6979
{
7080
href: `${layoutPath}/insight`,

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/dedicated/(general)/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function EngineLegacyBannerUI(props: {
9595
<div className="flex justify-start gap-3">
9696
<Button className="flex items-center gap-2" asChild size="sm">
9797
<Link
98-
href={`/team/${props.teamSlug}/${props.projectSlug}/engine/cloud`}
98+
href={`/team/${props.teamSlug}/${props.projectSlug}/transactions`}
9999
>
100100
<EngineIcon className="size-4" /> Try Engine Cloud
101101
</Link>

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/dedicated/(instance)/[engineId]/overview/components/engine-overview.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ function BackendWalletsSection(props: {
141141
chainId={chainId}
142142
onChange={setChainId}
143143
className="min-w-40 max-w-52 lg:max-w-60"
144-
popoverContentClassName="!w-[80vw] md:!w-[500px]"
144+
popoverContentClassName="!w-[80vw] md:!w-[400px]"
145+
disableChainId
145146
align="end"
146147
client={props.client}
147148
/>

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/engine/page.tsx

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

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/layout.tsx

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getProject, getProjects } from "@/api/projects";
1+
import { type Project, getProject, getProjects } from "@/api/projects";
22
import { getTeamBySlug, getTeams } from "@/api/team";
33
import { Button } from "@/components/ui/button";
44
import { SidebarProvider } from "@/components/ui/sidebar";
@@ -16,6 +16,7 @@ import {
1616
import { TeamHeaderLoggedIn } from "../../../components/TeamHeader/team-header-logged-in.client";
1717
import { ProjectSidebarLayout } from "./components/ProjectSidebarLayout";
1818
import { SaveLastUsedProject } from "./components/SaveLastUsedProject";
19+
import { getEngineInstances } from "./engine/dedicated/_utils/getEngineInstances";
1920

2021
export default async function ProjectLayout(props: {
2122
children: React.ReactNode;
@@ -59,6 +60,11 @@ export default async function ProjectLayout(props: {
5960
teamId: team.id,
6061
});
6162

63+
const engineLinkType = await getEngineLinkType({
64+
authToken,
65+
project,
66+
});
67+
6268
return (
6369
<SidebarProvider>
6470
<div className="flex h-dvh min-w-0 grow flex-col">
@@ -88,7 +94,10 @@ export default async function ProjectLayout(props: {
8894
client={client}
8995
/>
9096
</div>
91-
<ProjectSidebarLayout layoutPath={layoutPath}>
97+
<ProjectSidebarLayout
98+
layoutPath={layoutPath}
99+
engineLinkType={engineLinkType}
100+
>
92101
{props.children}
93102
</ProjectSidebarLayout>
94103
</div>
@@ -109,3 +118,32 @@ export default async function ProjectLayout(props: {
109118
</SidebarProvider>
110119
);
111120
}
121+
122+
async function getEngineLinkType(params: {
123+
authToken: string;
124+
project: Project;
125+
}) {
126+
const projectEngineCloudService = params.project.services.find(
127+
(service) => service.name === "engineCloud",
128+
);
129+
130+
const engineCloudToken = projectEngineCloudService?.managementAccessToken;
131+
132+
// if we have a management access token, link to engine cloud page
133+
let engineLinkType: "cloud" | "dedicated" = "cloud";
134+
135+
// if we don't have a engine cloud management access token, check if there are any legacy engine instances
136+
if (!engineCloudToken) {
137+
const engineInstances = await getEngineInstances({
138+
authToken: params.authToken,
139+
teamIdOrSlug: params.project.teamId,
140+
});
141+
142+
// if we have any legacy engine instances, link to the legacy engine page
143+
if (engineInstances.data && engineInstances.data.length > 0) {
144+
engineLinkType = "dedicated";
145+
}
146+
}
147+
148+
return engineLinkType;
149+
}
File renamed without changes.

0 commit comments

Comments
 (0)