Merge pull request #627 from buster-so/devin/BUS-1494-1753276227

Front end - asset document titles
This commit is contained in:
Nate Kelley 2025-07-24 18:18:38 -06:00 committed by GitHub
commit 2df53404d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 95 additions and 15 deletions

View File

@ -0,0 +1 @@
export * from './requests';

View File

@ -0,0 +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<GetTitleResponse>(`/title`, {
method: 'GET',
params,
baseURL: BASE_URL_V2
});
};

View File

@ -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 <DashboardLayout dashboardId={dashboardId}>{children}</DashboardLayout>;
}
export default DashboardLayout;
export { generateMetadata };

View File

@ -1,3 +1,4 @@
import MetricLayout from '@metrics/layout';
import MetricLayout, { generateMetadata } from '@metrics/layout';
export default MetricLayout;
export { generateMetadata };

View File

@ -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'
};
}
}

View File

@ -1,3 +1,4 @@
import MetricLayout from '@metrics/layout';
import MetricLayout, { generateMetadata } from '@metrics/layout';
export default MetricLayout;
export { generateMetadata };

View File

@ -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 <DashboardLayout dashboardId={dashboardId}>{children}</DashboardLayout>;
}
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'
};
}
}

View File

@ -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({
</AppAssetCheckLayout>
);
}
// Generate metadata dynamically based on the metric - shared across all child pages
export async function generateMetadata({
params
}: {
params: Promise<{ metricId: string }>;
}): Promise<Metadata> {
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'
};
}
}

View File

@ -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": [
{