mirror of https://github.com/buster-so/buster.git
Merge pull request #627 from buster-so/devin/BUS-1494-1753276227
Front end - asset document titles
This commit is contained in:
commit
2df53404d1
|
@ -0,0 +1 @@
|
||||||
|
export * from './requests';
|
|
@ -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
|
||||||
|
});
|
||||||
|
};
|
|
@ -1,13 +1,4 @@
|
||||||
import { DashboardLayout } from '@/layouts/DashboardLayout';
|
import DashboardLayout, { generateMetadata } from '@dashboards/layout';
|
||||||
|
|
||||||
export default async function Layout({
|
export default DashboardLayout;
|
||||||
children,
|
export { generateMetadata };
|
||||||
params
|
|
||||||
}: {
|
|
||||||
children: React.ReactNode;
|
|
||||||
params: Promise<{ dashboardId: string }>;
|
|
||||||
}) {
|
|
||||||
const { dashboardId } = await params;
|
|
||||||
|
|
||||||
return <DashboardLayout dashboardId={dashboardId}>{children}</DashboardLayout>;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
import MetricLayout from '@metrics/layout';
|
import MetricLayout, { generateMetadata } from '@metrics/layout';
|
||||||
|
|
||||||
export default MetricLayout;
|
export default MetricLayout;
|
||||||
|
export { generateMetadata };
|
||||||
|
|
|
@ -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'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
import MetricLayout from '@metrics/layout';
|
import MetricLayout, { generateMetadata } from '@metrics/layout';
|
||||||
|
|
||||||
export default MetricLayout;
|
export default MetricLayout;
|
||||||
|
export { generateMetadata };
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { getTitle_server } from '@/api/buster_rest/title';
|
||||||
import { DashboardLayout } from '@/layouts/DashboardLayout';
|
import { DashboardLayout } from '@/layouts/DashboardLayout';
|
||||||
|
|
||||||
export default async function Layout({
|
export default async function Layout({
|
||||||
|
@ -11,3 +12,23 @@ export default async function Layout({
|
||||||
|
|
||||||
return <DashboardLayout dashboardId={dashboardId}>{children}</DashboardLayout>;
|
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'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import { AppAssetCheckLayout } from '@/layouts/AppAssetCheckLayout';
|
import { AppAssetCheckLayout } from '@/layouts/AppAssetCheckLayout';
|
||||||
|
import type { Metadata } from 'next';
|
||||||
|
import { getTitle_server } from '@/api/buster_rest/title';
|
||||||
|
|
||||||
export default async function MetricLayout({
|
export default async function MetricLayout({
|
||||||
children,
|
children,
|
||||||
|
@ -15,3 +17,30 @@ export default async function MetricLayout({
|
||||||
</AppAssetCheckLayout>
|
</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'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["src/*"],
|
"@/*": ["src/*"],
|
||||||
"@metrics/*": ["src/app/app/(primary_layout)/(chat_experience)/metrics/[metricId]/*"],
|
"@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": [
|
"plugins": [
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue