From c137dd653c3640874f3cc953f4514c51f08c1ae9 Mon Sep 17 00:00:00 2001 From: MananTank Date: Mon, 28 Apr 2025 16:53:32 +0000 Subject: [PATCH] [NEB-190] Set testnet flag on testnet pages in dashboard (#6875) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ## PR-Codex overview This PR focuses on adding a `networks` property to various components and functions within the application, enhancing the context management for network-related data across the dashboard. ### Detailed summary - Added `networks` property in `NebulaLoginPage.tsx`. - Updated `NebulaChatButton` components in multiple files to accept `networks`. - Modified context handling to include `networks` in session updates and chat functionalities. - Adjusted `ChatBar` and `ChatPageContent` components to utilize `networks`. - Enhanced API interactions in `session.ts` and `chat.ts` to handle `networks`. - Updated storybook stories to reflect changes in context with `networks`. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- .../(dashboard)/(chain)/[chain_id]/(chainPage)/layout.tsx | 1 + .../(chain)/[chain_id]/[contractAddress]/layout.tsx | 1 + apps/dashboard/src/app/(app)/(dashboard)/support/page.tsx | 1 + apps/dashboard/src/app/nebula-app/(app)/api/chat.ts | 4 ++++ apps/dashboard/src/app/nebula-app/(app)/api/session.ts | 2 ++ .../src/app/nebula-app/(app)/components/ChatBar.tsx | 2 ++ .../src/app/nebula-app/(app)/components/ChatPageContent.tsx | 3 +++ .../src/app/nebula-app/(app)/components/Chatbar.stories.tsx | 4 ++++ .../(app)/components/FloatingChat/FloatingChat.tsx | 5 +++++ .../(app)/components/FloatingChat/FloatingChatContent.tsx | 4 ++++ apps/dashboard/src/app/nebula-app/login/NebulaLoginPage.tsx | 1 + 11 files changed, 28 insertions(+) diff --git a/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/layout.tsx b/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/layout.tsx index f4bd349ab68..f35491d8330 100644 --- a/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/layout.tsx +++ b/apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/layout.tsx @@ -100,6 +100,7 @@ The following is the user's message: return ( <>
x.toString()), + networks: props.context?.networks || null, }); }} priorityChains={[ @@ -156,6 +157,7 @@ export function ChatBar(props: { props.setContext({ walletAddress: walletMeta.address, chainIds: props.context?.chainIds || [], + networks: props.context?.networks || null, }); }} /> diff --git a/apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx b/apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx index 17b60e36336..58f58eb7b0f 100644 --- a/apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx +++ b/apps/dashboard/src/app/nebula-app/(app)/components/ChatPageContent.tsx @@ -101,6 +101,7 @@ export function ChatPageContent(props: { props.initialParams?.chainIds.map((x) => x.toString()) || [], walletAddress: contextRes?.wallet_address || props.accountAddress || null, + networks: "mainnet", }; return value; @@ -131,6 +132,7 @@ export function ChatPageContent(props: { : { chainIds: [], walletAddress: null, + networks: null, }; if (!updatedContextFilters.walletAddress && address) { @@ -594,6 +596,7 @@ export async function handleNebulaPrompt(params: { setContextFilters({ chainIds: res.data.chain_ids.map((x) => x.toString()), walletAddress: res.data.wallet_address, + networks: res.data.networks, }); } }, diff --git a/apps/dashboard/src/app/nebula-app/(app)/components/Chatbar.stories.tsx b/apps/dashboard/src/app/nebula-app/(app)/components/Chatbar.stories.tsx index c5c796e1d21..78b0acd75bc 100644 --- a/apps/dashboard/src/app/nebula-app/(app)/components/Chatbar.stories.tsx +++ b/apps/dashboard/src/app/nebula-app/(app)/components/Chatbar.stories.tsx @@ -48,6 +48,7 @@ function Story() { isStreaming={false} context={{ chainIds: ["1"], + networks: null, walletAddress: null, }} showContextSelector={true} @@ -60,6 +61,7 @@ function Story() { isStreaming={false} context={{ chainIds: ["1", "137", "10"], + networks: null, walletAddress: null, }} showContextSelector={true} @@ -72,6 +74,7 @@ function Story() { isStreaming={false} context={{ chainIds: ["1", "137", "10", "146", "80094"], + networks: null, walletAddress: null, }} showContextSelector={true} @@ -89,6 +92,7 @@ function Story() { isStreaming={false} context={{ chainIds: ["1", "137", "10", "146", "80094"], + networks: null, walletAddress: null, }} showContextSelector={true} diff --git a/apps/dashboard/src/app/nebula-app/(app)/components/FloatingChat/FloatingChat.tsx b/apps/dashboard/src/app/nebula-app/(app)/components/FloatingChat/FloatingChat.tsx index ee690537cff..9dbdb8e33f5 100644 --- a/apps/dashboard/src/app/nebula-app/(app)/components/FloatingChat/FloatingChat.tsx +++ b/apps/dashboard/src/app/nebula-app/(app)/components/FloatingChat/FloatingChat.tsx @@ -16,6 +16,7 @@ import { useState, } from "react"; import type { ThirdwebClient } from "thirdweb"; +import type { NebulaContext } from "../../api/chat"; import type { ExamplePrompt } from "../../data/examplePrompts"; import { NebulaIcon } from "../../icons/NebulaIcon"; @@ -25,6 +26,7 @@ export function NebulaChatButton(props: { pageType: "chain" | "contract" | "support"; authToken: string | undefined; examplePrompts: ExamplePrompt[]; + networks: NebulaContext["networks"]; label: string; client: ThirdwebClient; isFloating: boolean; @@ -91,6 +93,7 @@ export function NebulaChatButton(props: {
chainId.toString()) || null, walletAddress: props.nebulaParams?.wallet || null, + networks: props.networks, }; }); diff --git a/apps/dashboard/src/app/nebula-app/login/NebulaLoginPage.tsx b/apps/dashboard/src/app/nebula-app/login/NebulaLoginPage.tsx index 2f34007e8bf..159562dff61 100644 --- a/apps/dashboard/src/app/nebula-app/login/NebulaLoginPage.tsx +++ b/apps/dashboard/src/app/nebula-app/login/NebulaLoginPage.tsx @@ -93,6 +93,7 @@ export function NebulaLoggedOutStatePage(props: { context={{ walletAddress: null, chainIds: chainIds.map((x) => x.toString()), + networks: null, }} setContext={(v) => { if (v?.chainIds) {