diff --git a/apps/web/src/api/buster_rest/reports/queryRequests.ts b/apps/web/src/api/buster_rest/reports/queryRequests.ts index 83a508f18..1a5580fdd 100644 --- a/apps/web/src/api/buster_rest/reports/queryRequests.ts +++ b/apps/web/src/api/buster_rest/reports/queryRequests.ts @@ -65,18 +65,19 @@ export const prefetchGetReportsList = async ( /** * Hook to get an individual report by ID */ -export const useGetReportById = ( - reportId: string, +export const useGetReport = ( + reportId: string | undefined, options?: Omit, 'queryKey' | 'queryFn'> ) => { const queryFn = useMemoizedFn(() => { - return getReportById(reportId); + return getReportById(reportId!); }); return useQuery({ - ...queryKeys.reportsGetById(reportId), + ...queryKeys.reportsGetById(reportId!), queryFn, enabled: !!reportId, + select: options?.select, ...options }); }; diff --git a/apps/web/src/app/app/(primary_layout)/(chat_experience)/reports/layout.tsx b/apps/web/src/app/app/(primary_layout)/(chat_experience)/reports/layout.tsx new file mode 100644 index 000000000..58d399611 --- /dev/null +++ b/apps/web/src/app/app/(primary_layout)/(chat_experience)/reports/layout.tsx @@ -0,0 +1,46 @@ +import { AppAssetCheckLayout } from '@/layouts/AppAssetCheckLayout'; +import type { Metadata } from 'next'; +import { getTitle_server } from '@/api/buster_rest/title'; + +export default async function ReportLayout({ + children, + params +}: { + children: React.ReactNode; + params: Promise<{ reportId: string }>; +}) { + const { reportId } = await params; + + return ( + + {children} + + ); +} + +// Generate metadata dynamically based on the report - shared across all child pages +export async function generateMetadata({ + params +}: { + params: Promise<{ reportId: string }>; +}): Promise { + const { reportId } = await params; + + try { + // Fetch the report title using the server-side request + const response = await getTitle_server({ + assetId: reportId, + assetType: 'report' + }); + + return { + title: response.title || 'New Report' + }; + } catch (error) { + // Fallback title if the request fails + console.error('Failed to fetch report title:', error); + return { + title: 'New Report' + }; + } +} diff --git a/apps/web/src/app/app/(primary_layout)/(chat_experience)/reports/loading.tsx b/apps/web/src/app/app/(primary_layout)/(chat_experience)/reports/loading.tsx new file mode 100644 index 000000000..02fb527af --- /dev/null +++ b/apps/web/src/app/app/(primary_layout)/(chat_experience)/reports/loading.tsx @@ -0,0 +1,5 @@ +import { FileIndeterminateLoader } from '@/components/features/FileIndeterminateLoader'; + +export default function Loading() { + return ; +} diff --git a/apps/web/src/app/app/(settings_layout)/settings/(permissions)/dataset-groups/[datasetGroupId]/datasets/DatasetGroupDatasetsListContainer.tsx b/apps/web/src/app/app/(settings_layout)/settings/(permissions)/dataset-groups/[datasetGroupId]/datasets/DatasetGroupDatasetsListContainer.tsx index c6e2c4545..8ec8c90a2 100644 --- a/apps/web/src/app/app/(settings_layout)/settings/(permissions)/dataset-groups/[datasetGroupId]/datasets/DatasetGroupDatasetsListContainer.tsx +++ b/apps/web/src/app/app/(settings_layout)/settings/(permissions)/dataset-groups/[datasetGroupId]/datasets/DatasetGroupDatasetsListContainer.tsx @@ -1,10 +1,7 @@ 'use client'; import React, { useMemo, useState } from 'react'; -import type { - GetDatasetGroupDatasetsResponse, - GetPermissionGroupUsersResponse -} from '@/api/asset_interfaces'; +import type { GetDatasetGroupDatasetsResponse } from '@/api/asset_interfaces'; import { useUpdateDatasetGroupDatasets } from '@/api/buster_rest/dataset_groups'; import { PermissionAssignedCell } from '@/components/features/PermissionComponents'; import { @@ -42,7 +39,7 @@ export const DatasetGroupDatasetsListContainer: React.FC<{ title: 'Assigned', dataIndex: 'assigned', width: 130 + 85, - render: (assigned, permissionGroup: GetPermissionGroupUsersResponse) => { + render: (assigned, permissionGroup) => { return (
+ file-text x?.name }); + const { + isFetched: reportIsFetched, + error: reportError, + isError: reportIsError, + data: reportTitle + } = useGetReport(isReport ? props.assetId : undefined, { + select: (x) => x?.name + }); + const currentQuery = useMemo((): AssetQueryResult => { switch (props.type) { case 'metric': @@ -149,6 +159,14 @@ export const useGetAsset = ( isError: collectionIsError, showLoader: !collectionIsFetched && !collectionIsError }; + + case 'report': + return { + isFetched: reportIsFetched, + error: reportError, + isError: reportIsError, + showLoader: !reportIsFetched && !reportIsError + }; default: { const exhaustiveCheck: never = props.type; return { isFetched: false, error: null, isError: false, showLoader: false }; diff --git a/packages/server-shared/package.json b/packages/server-shared/package.json index 434c0f92b..eafd65a69 100644 --- a/packages/server-shared/package.json +++ b/packages/server-shared/package.json @@ -21,6 +21,10 @@ "types": "./dist/index.d.ts", "default": "./dist/index.js" }, + "./assets": { + "types": "./dist/assets/index.d.ts", + "default": "./dist/assets/index.js" + }, "./chats": { "types": "./dist/chats/index.d.ts", "default": "./dist/chats/index.js" diff --git a/packages/server-shared/src/assets/index.ts b/packages/server-shared/src/assets/index.ts index e69de29bb..c4b5f5176 100644 --- a/packages/server-shared/src/assets/index.ts +++ b/packages/server-shared/src/assets/index.ts @@ -0,0 +1 @@ +export * from './asset-types.types';