From 55679b9d19e9f190ee8a4ad1345353f6677b1ba8 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Thu, 24 Jul 2025 17:54:55 -0600 Subject: [PATCH 1/3] Make request --- apps/web/src/api/buster_rest/title/index.ts | 1 + apps/web/src/api/buster_rest/title/requests.ts | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 apps/web/src/api/buster_rest/title/index.ts create mode 100644 apps/web/src/api/buster_rest/title/requests.ts diff --git a/apps/web/src/api/buster_rest/title/index.ts b/apps/web/src/api/buster_rest/title/index.ts new file mode 100644 index 000000000..c3dff2f3f --- /dev/null +++ b/apps/web/src/api/buster_rest/title/index.ts @@ -0,0 +1 @@ +export * from './requests'; diff --git a/apps/web/src/api/buster_rest/title/requests.ts b/apps/web/src/api/buster_rest/title/requests.ts new file mode 100644 index 000000000..b4078f482 --- /dev/null +++ b/apps/web/src/api/buster_rest/title/requests.ts @@ -0,0 +1,9 @@ +import { serverFetch } from '../../createServerInstance'; +import { GetTitleResponse, GetTitleRequest } from '@buster/server-shared/title'; + +export const getTitle_server = async (params: GetTitleRequest) => { + return serverFetch(`/title`, { + method: 'GET', + params + }); +}; From 0c6271f5c9d114791791c37116ac563390e2cbb7 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Thu, 24 Jul 2025 18:09:18 -0600 Subject: [PATCH 2/3] title generations --- .../dashboards/[dashboardId]/layout.tsx | 15 ++-------- .../metrics/[metricId]/layout.tsx | 3 +- .../chats/[chatId]/layout.tsx | 25 ++++++++++++++++ .../[chatId]/metrics/[metricId]/layout.tsx | 3 +- .../dashboards/[dashboardId]/layout.tsx | 21 ++++++++++++++ .../metrics/[metricId]/layout.tsx | 29 +++++++++++++++++++ apps/web/tsconfig.json | 2 +- 7 files changed, 83 insertions(+), 15 deletions(-) create mode 100644 apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/layout.tsx diff --git a/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/layout.tsx b/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/layout.tsx index 69cae866c..8f36c8ff1 100644 --- a/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/layout.tsx +++ b/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/layout.tsx @@ -1,13 +1,4 @@ -import { DashboardLayout } from '@/layouts/DashboardLayout'; +import DashboardLayout, { generateMetadata } from '@dashboards/layout'; -export default async function Layout({ - children, - params -}: { - children: React.ReactNode; - params: Promise<{ dashboardId: string }>; -}) { - const { dashboardId } = await params; - - return {children}; -} +export default DashboardLayout; +export { generateMetadata }; diff --git a/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/metrics/[metricId]/layout.tsx b/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/metrics/[metricId]/layout.tsx index 98e472be8..e90da7a8f 100644 --- a/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/metrics/[metricId]/layout.tsx +++ b/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/dashboards/[dashboardId]/metrics/[metricId]/layout.tsx @@ -1,3 +1,4 @@ -import MetricLayout from '@metrics/layout'; +import MetricLayout, { generateMetadata } from '@metrics/layout'; export default MetricLayout; +export { generateMetadata }; diff --git a/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/layout.tsx b/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/layout.tsx new file mode 100644 index 000000000..d2cbdac7f --- /dev/null +++ b/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/layout.tsx @@ -0,0 +1,25 @@ +import { getTitle_server } from '@/api/buster_rest/title'; + +export default function ChatLayout({ children }: { children: React.ReactNode }) { + return <>{children}; +} + +export async function generateMetadata({ params }: { params: Promise<{ chatId: string }> }) { + const { chatId } = await params; + + try { + const response = await getTitle_server({ + assetId: chatId, + assetType: 'chat' + }); + + return { + title: response.title || 'New Chat' + }; + } catch (error) { + console.error('Failed to fetch chat title:', error); + return { + title: 'New Chat' + }; + } +} diff --git a/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/metrics/[metricId]/layout.tsx b/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/metrics/[metricId]/layout.tsx index 98e472be8..e90da7a8f 100644 --- a/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/metrics/[metricId]/layout.tsx +++ b/apps/web/src/app/app/(primary_layout)/(chat_experience)/chats/[chatId]/metrics/[metricId]/layout.tsx @@ -1,3 +1,4 @@ -import MetricLayout from '@metrics/layout'; +import MetricLayout, { generateMetadata } from '@metrics/layout'; export default MetricLayout; +export { generateMetadata }; diff --git a/apps/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/layout.tsx b/apps/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/layout.tsx index 69cae866c..449593d04 100644 --- a/apps/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/layout.tsx +++ b/apps/web/src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/layout.tsx @@ -1,3 +1,4 @@ +import { getTitle_server } from '@/api/buster_rest/title'; import { DashboardLayout } from '@/layouts/DashboardLayout'; export default async function Layout({ @@ -11,3 +12,23 @@ export default async function Layout({ return {children}; } + +export async function generateMetadata({ params }: { params: Promise<{ dashboardId: string }> }) { + const { dashboardId } = await params; + + try { + const response = await getTitle_server({ + assetId: dashboardId, + assetType: 'dashboard' + }); + + return { + title: response.title || 'New Dashboard' + }; + } catch (error) { + console.error('Failed to fetch dashboard title:', error); + return { + title: 'New Dashboard' + }; + } +} diff --git a/apps/web/src/app/app/(primary_layout)/(chat_experience)/metrics/[metricId]/layout.tsx b/apps/web/src/app/app/(primary_layout)/(chat_experience)/metrics/[metricId]/layout.tsx index bc1260c8e..104c1b1e7 100644 --- a/apps/web/src/app/app/(primary_layout)/(chat_experience)/metrics/[metricId]/layout.tsx +++ b/apps/web/src/app/app/(primary_layout)/(chat_experience)/metrics/[metricId]/layout.tsx @@ -1,4 +1,6 @@ import { AppAssetCheckLayout } from '@/layouts/AppAssetCheckLayout'; +import type { Metadata } from 'next'; +import { getTitle_server } from '@/api/buster_rest/title'; export default async function MetricLayout({ children, @@ -15,3 +17,30 @@ export default async function MetricLayout({ ); } + +// Generate metadata dynamically based on the metric - shared across all child pages +export async function generateMetadata({ + params +}: { + params: Promise<{ metricId: string }>; +}): Promise { + const { metricId } = await params; + + try { + // Fetch the metric title using the server-side request + const response = await getTitle_server({ + assetId: metricId, + assetType: 'metric' + }); + + return { + title: response.title || 'New Metric' + }; + } catch (error) { + // Fallback title if the request fails + console.error('Failed to fetch metric title:', error); + return { + title: 'New Metric' + }; + } +} diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json index d2b8aefb9..5b37633cc 100644 --- a/apps/web/tsconfig.json +++ b/apps/web/tsconfig.json @@ -13,7 +13,7 @@ "paths": { "@/*": ["src/*"], "@metrics/*": ["src/app/app/(primary_layout)/(chat_experience)/metrics/[metricId]/*"], - "@dashboards": ["src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/*"] + "@dashboards/*": ["src/app/app/(primary_layout)/(chat_experience)/dashboards/[dashboardId]/*"] }, "plugins": [ { From 1d646c003d7771db2213bb46ed928bc703333ed3 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Thu, 24 Jul 2025 18:15:43 -0600 Subject: [PATCH 3/3] Update request to use v2 --- apps/web/src/api/buster_rest/title/requests.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/web/src/api/buster_rest/title/requests.ts b/apps/web/src/api/buster_rest/title/requests.ts index b4078f482..4c9ae682b 100644 --- a/apps/web/src/api/buster_rest/title/requests.ts +++ b/apps/web/src/api/buster_rest/title/requests.ts @@ -1,9 +1,11 @@ import { serverFetch } from '../../createServerInstance'; import { GetTitleResponse, GetTitleRequest } from '@buster/server-shared/title'; +import { BASE_URL_V2 } from '../config'; export const getTitle_server = async (params: GetTitleRequest) => { return serverFetch(`/title`, { method: 'GET', - params + params, + baseURL: BASE_URL_V2 }); };