Skip to content

Commit 1e52258

Browse files
Merge pull request #56 from OpenZeppelin/chore/refactor-monitor-relayer-paths
chore/refactor monitor relayer paths
2 parents 87a76d7 + 0a0a345 commit 1e52258

File tree

4 files changed

+467
-60
lines changed

4 files changed

+467
-60
lines changed

src/components/layout/docs-layout-client.tsx

Lines changed: 76 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"use client";
22

3+
import { usePathname } from "next/navigation";
34
import type { ReactNode } from "react";
5+
import { useMemo } from "react";
46
import { baseOptions } from "@/app/layout.config";
57
import {
68
ArbitrumIcon,
@@ -21,67 +23,87 @@ interface DocsLayoutClientProps {
2123

2224
export function DocsLayoutClient({ children }: DocsLayoutClientProps) {
2325
const currentTree = useNavigationTree();
26+
const pathname = usePathname();
27+
28+
// Determine if shared paths should be included in Stellar tab based on sessionStorage
29+
const tabs = useMemo(() => {
30+
const isSharedPath =
31+
pathname.startsWith("/monitor") || pathname.startsWith("/relayer");
32+
const lastEcosystem =
33+
typeof window !== "undefined"
34+
? sessionStorage.getItem("lastEcosystem")
35+
: null;
36+
37+
// Include shared paths in Stellar tab only if coming from Stellar context
38+
const stellarUrls =
39+
isSharedPath && lastEcosystem === "stellar"
40+
? new Set(["/stellar-contracts", "/monitor", "/relayer"])
41+
: new Set(["/stellar-contracts"]);
42+
43+
return [
44+
{
45+
title: "Ethereum & EVM",
46+
url: "/contracts",
47+
icon: <EthereumIcon className="w-5 h-5" />,
48+
urls: new Set([
49+
"/contracts",
50+
"/community-contracts",
51+
"/upgrades-plugins",
52+
"/wizard",
53+
"/relayer",
54+
"/monitor",
55+
"/ui-builder",
56+
"/upgrades",
57+
"/defender",
58+
"/tools",
59+
]),
60+
},
61+
{
62+
title: "Arbitrum Stylus",
63+
url: "/contracts-stylus",
64+
icon: <ArbitrumIcon className="w-5 h-5" />,
65+
},
66+
{
67+
title: "Starknet",
68+
url: "/contracts-cairo",
69+
icon: <StarknetIcon className="w-5 h-5" />,
70+
},
71+
{
72+
title: "Stellar",
73+
url: "/stellar-contracts",
74+
icon: <StellarIcon className="w-5 h-5" />,
75+
urls: stellarUrls,
76+
},
77+
{
78+
title: "Midnight",
79+
url: "/contracts-compact",
80+
icon: <MidnightIcon className="w-5 h-5" />,
81+
},
82+
{
83+
title: "Polkadot",
84+
url: "/substrate-runtimes",
85+
icon: <PolkadotIcon className="w-5 h-5" />,
86+
},
87+
{
88+
title: "Uniswap Hooks",
89+
url: "/uniswap-hooks",
90+
icon: <UniswapIcon className="w-5 h-5" />,
91+
},
92+
{
93+
title: "Zama FHEVM",
94+
url: "/confidential-contracts",
95+
icon: <ZamaIcon className="w-5 h-5" />,
96+
},
97+
];
98+
}, [pathname]);
2499

25100
return (
26101
<DocsLayout
27102
tree={currentTree}
28103
nav={{ ...baseOptions, mode: "top", transparentMode: "none" }}
29104
{...baseOptions}
30105
sidebar={{
31-
tabs: [
32-
{
33-
title: "Ethereum & EVM",
34-
url: "/contracts",
35-
icon: <EthereumIcon className="w-5 h-5" />,
36-
urls: new Set([
37-
"/contracts",
38-
"/community-contracts",
39-
"/upgrades-plugins",
40-
"/wizard",
41-
"/relayer",
42-
"/monitor",
43-
"/ui-builder",
44-
"/upgrades",
45-
"/defender",
46-
"/tools",
47-
]),
48-
},
49-
{
50-
title: "Arbitrum Stylus",
51-
url: "/contracts-stylus",
52-
icon: <ArbitrumIcon className="w-5 h-5" />,
53-
},
54-
{
55-
title: "Starknet",
56-
url: "/contracts-cairo",
57-
icon: <StarknetIcon className="w-5 h-5" />,
58-
},
59-
{
60-
title: "Stellar",
61-
url: "/stellar-contracts",
62-
icon: <StellarIcon className="w-5 h-5" />,
63-
},
64-
{
65-
title: "Midnight",
66-
url: "/contracts-compact",
67-
icon: <MidnightIcon className="w-5 h-5" />,
68-
},
69-
{
70-
title: "Polkadot",
71-
url: "/substrate-runtimes",
72-
icon: <PolkadotIcon className="w-5 h-5" />,
73-
},
74-
{
75-
title: "Uniswap Hooks",
76-
url: "/uniswap-hooks",
77-
icon: <UniswapIcon className="w-5 h-5" />,
78-
},
79-
{
80-
title: "Zama FHEVM",
81-
url: "/confidential-contracts",
82-
icon: <ZamaIcon className="w-5 h-5" />,
83-
},
84-
],
106+
tabs,
85107
}}
86108
>
87109
{children}

src/hooks/use-navigation-tree.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { usePathname } from "next/navigation";
4+
import { useEffect } from "react";
45
import {
56
arbitrumStylusTree,
67
ethereumEvmTree,
@@ -15,6 +16,26 @@ import {
1516
export function useNavigationTree() {
1617
const pathname = usePathname();
1718

19+
// Track ecosystem changes in sessionStorage
20+
useEffect(() => {
21+
if (typeof window === "undefined") return;
22+
23+
if (pathname.startsWith("/stellar-contracts")) {
24+
sessionStorage.setItem("lastEcosystem", "stellar");
25+
} else if (
26+
pathname.startsWith("/contracts") ||
27+
pathname.startsWith("/community-contracts") ||
28+
pathname.startsWith("/upgrades-plugins") ||
29+
pathname.startsWith("/wizard") ||
30+
pathname.startsWith("/ui-builder") ||
31+
pathname.startsWith("/upgrades") ||
32+
pathname.startsWith("/defender") ||
33+
pathname.startsWith("/tools")
34+
) {
35+
sessionStorage.setItem("lastEcosystem", "ethereum");
36+
}
37+
}, [pathname]);
38+
1839
// Determine which navigation tree to use based on the current path
1940
if (pathname.startsWith("/contracts-stylus")) {
2041
return arbitrumStylusTree;
@@ -34,5 +55,23 @@ export function useNavigationTree() {
3455
return ethereumEvmTree;
3556
}
3657

58+
// For shared paths like /monitor and /relayer, check sessionStorage to see
59+
// which ecosystem was last active, defaulting to ethereumEvmTree
60+
if (typeof window !== "undefined") {
61+
const lastEcosystem = sessionStorage.getItem("lastEcosystem");
62+
63+
if (pathname.startsWith("/monitor") || pathname.startsWith("/relayer")) {
64+
switch (lastEcosystem) {
65+
case "stellar":
66+
return stellarTree;
67+
case "ethereum":
68+
return ethereumEvmTree;
69+
default:
70+
return ethereumEvmTree;
71+
}
72+
}
73+
}
74+
75+
// Default to ethereumEvmTree for other paths
3776
return ethereumEvmTree;
3877
}

src/navigation/ethereum-evm.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@
790790
},
791791
{
792792
"type": "separator",
793-
"name": "Tools"
793+
"name": "Open Source Tools"
794794
},
795795
{
796796
"type": "folder",
@@ -842,11 +842,6 @@
842842
"name": "Solana Integration",
843843
"url": "/relayer/solana"
844844
},
845-
{
846-
"type": "page",
847-
"name": "Stellar Integration",
848-
"url": "/relayer/stellar"
849-
},
850845
{
851846
"type": "folder",
852847
"name": "API Reference",
@@ -1090,6 +1085,11 @@
10901085
{
10911086
"type": "folder",
10921087
"name": "Monitor",
1088+
"index": {
1089+
"type": "page",
1090+
"name": "Overview",
1091+
"url": "/monitor"
1092+
},
10931093
"children": [
10941094
{
10951095
"type": "page",

0 commit comments

Comments
 (0)