dashboard fixes

This commit is contained in:
Nate Kelley 2025-04-08 10:29:15 -06:00
parent 18b17d69ef
commit 0fbf690504
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
16 changed files with 24 additions and 29 deletions

View File

@ -91,7 +91,7 @@ export const useGetDashboard = <TData = BusterDashboardResponse>(
return useQuery({
...dashboardQueryKeys.dashboardGetDashboard(id!, version_number),
queryFn: () => queryFn(id!, version_number),
enabled: !!id,
enabled: false, //it is false because we fetch the dashboard server side
select: params?.select,
...params
});

View File

@ -25,7 +25,7 @@ export const ShareMenuContent: React.FC<{
const onCopyLink = useMemoizedFn(() => {
let url = '';
if (assetType === ShareAssetType.METRIC && assetId) {
url = createBusterRoute({ route: BusterRoutes.APP_METRIC_ID, metricId: assetId });
url = createBusterRoute({ route: BusterRoutes.APP_METRIC_ID_CHART, metricId: assetId });
} else if (assetType === ShareAssetType.DASHBOARD && assetId) {
url = createBusterRoute({
route: BusterRoutes.APP_DASHBOARD_ID,

View File

@ -22,14 +22,14 @@ export const ShareMenuContentEmbed: React.FC<ShareMenuContentBodyProps> = React.
if (assetType === ShareAssetType.METRIC) {
url = createBusterRoute({
route: BusterRoutes.APP_METRIC_ID,
route: BusterRoutes.EMBED_METRIC_ID,
metricId: assetId
});
}
if (assetType === ShareAssetType.DASHBOARD) {
url = createBusterRoute({
route: BusterRoutes.APP_DASHBOARD_ID,
route: BusterRoutes.EMBED_DASHBOARD_ID,
dashboardId: assetId
});
}

View File

@ -49,7 +49,7 @@ export const ShareMenuContentPublish: React.FC<ShareMenuContentBodyProps> = Reac
const url = useMemo(() => {
let url = '';
if (assetType === ShareAssetType.METRIC) {
url = createBusterRoute({ route: BusterRoutes.APP_METRIC_ID, metricId: assetId });
url = createBusterRoute({ route: BusterRoutes.APP_METRIC_ID_CHART, metricId: assetId });
} else if (assetType === ShareAssetType.DASHBOARD) {
url = createBusterRoute({ route: BusterRoutes.APP_DASHBOARD_ID, dashboardId: assetId });
} else if (assetType === ShareAssetType.COLLECTION) {

View File

@ -28,7 +28,7 @@ export const assetTypeToIcon = (assetType: ShareAssetType) => {
export const assetTypeToRoute = (assetType: ShareAssetType, assetId: string) => {
switch (assetType) {
case ShareAssetType.METRIC:
return createBusterRoute({ route: BusterRoutes.APP_METRIC_ID, metricId: assetId });
return createBusterRoute({ route: BusterRoutes.APP_METRIC_ID_CHART, metricId: assetId });
case ShareAssetType.DASHBOARD:
return createBusterRoute({ route: BusterRoutes.APP_DASHBOARD_ID, dashboardId: assetId });
case ShareAssetType.COLLECTION:

View File

@ -34,7 +34,7 @@ const mockFavorites = [
{
id: '456',
name: 'Important Metrics',
route: createBusterRoute({ route: BusterRoutes.APP_METRIC_ID, metricId: '456' }),
route: createBusterRoute({ route: BusterRoutes.APP_METRIC_ID_CHART, metricId: '456' }),
ype: ShareAssetType.METRIC,
asset_id: '456',
created_at: new Date().toISOString(),
@ -43,7 +43,7 @@ const mockFavorites = [
{
id: '789',
name: 'Favorite Metric 3',
route: createBusterRoute({ route: BusterRoutes.APP_METRIC_ID, metricId: '789' }),
route: createBusterRoute({ route: BusterRoutes.APP_METRIC_ID_CHART, metricId: '789' }),
ype: ShareAssetType.METRIC,
asset_id: '789',
created_at: new Date().toISOString(),
@ -96,6 +96,6 @@ export const FavoritesActiveRoute: Story = {
args: {
isAdmin: true,
favorites: mockFavorites,
activePage: createBusterRoute({ route: BusterRoutes.APP_METRIC_ID, metricId: '456' })
activePage: createBusterRoute({ route: BusterRoutes.APP_METRIC_ID_CHART, metricId: '456' })
}
};

View File

@ -67,7 +67,7 @@ export const useListVersionHistories = ({
if (rereouteToAsset) {
await onChangePage(
createBusterRoute({
route: BusterRoutes.APP_METRIC_ID,
route: BusterRoutes.APP_METRIC_ID_CHART,
metricId: assetId
})
);

View File

@ -163,7 +163,7 @@ const CollectionIconRecord: Record<string, React.ReactNode> = {
const createAssetLink = (asset: BusterCollectionItemAsset, collectionId: string) => {
if (asset.asset_type === ShareAssetType.METRIC) {
return createBusterRoute({
route: BusterRoutes.APP_METRIC_ID,
route: BusterRoutes.APP_METRIC_ID_CHART,
metricId: asset.id
});
}

View File

@ -60,7 +60,7 @@ const DashboardMetricItemBase: React.FC<{
});
}
return createBusterRoute({
route: BusterRoutes.APP_METRIC_ID,
route: BusterRoutes.APP_METRIC_ID_CHART,
metricId: metricId
});
}, [metricId, chatId]);

View File

@ -38,7 +38,7 @@ export const MetricItemsContainer: React.FC<{
id: metric.id,
data: metric,
link: createBusterRoute({
route: BusterRoutes.APP_METRIC_ID,
route: BusterRoutes.APP_METRIC_ID_CHART,
metricId: metric.id
})
}));

View File

@ -66,7 +66,7 @@ const assetRouteRecord: Record<AllFileTypes, (assetId: string) => string | null>
}),
metric: (assetId) =>
createBusterRoute({
route: BusterRoutes.APP_METRIC_ID,
route: BusterRoutes.APP_METRIC_ID_CHART,
metricId: assetId
}),
dashboard: (assetId) =>

View File

@ -25,7 +25,7 @@ export const DashboardContainerHeaderButtons: React.FC<FileContainerButtonsProps
{ select: (x) => x.permission }
);
if (dashboardError) return null;
if (dashboardError || !permission) return null;
const isEditor = canEdit(permission);
const isEffectiveOwner = getIsEffectiveOwner(permission);

View File

@ -15,11 +15,7 @@ import { useGetMetric } from '@/api/buster_rest/metrics';
import { ThreeDotMenuButton } from './MetricThreeDotMenu';
import { canEdit, getIsEffectiveOwner } from '@/lib/share';
import Link from 'next/link';
import { BusterRoutes, createBusterRoute } from '@/routes';
import {
assetParamsToRoute,
createChatAssetRoute
} from '@/layouts/ChatLayout/ChatLayoutContext/helpers';
import { assetParamsToRoute } from '@/layouts/ChatLayout/ChatLayoutContext/helpers';
export const MetricContainerHeaderButtons: React.FC<FileContainerButtonsProps> = React.memo(() => {
const selectedLayout = useChatLayoutContextSelector((x) => x.selectedLayout);
@ -31,7 +27,7 @@ export const MetricContainerHeaderButtons: React.FC<FileContainerButtonsProps> =
);
//we assume it is fetched until it is not
if (metricError) return null;
if (metricError || !permission) return null;
const isEditor = canEdit(permission);
const isEffectiveOwner = getIsEffectiveOwner(permission);

View File

@ -5,14 +5,16 @@ import { NextRequest } from 'next/server';
import { createPathnameToBusterRoute } from './createRouteHelpers';
const assetCheckPages: BusterRoutes[] = [
BusterRoutes.APP_METRIC_ID,
BusterRoutes.APP_METRIC_ID_CHART,
BusterRoutes.APP_METRIC_ID_RESULTS,
BusterRoutes.APP_METRIC_ID_FILE,
BusterRoutes.APP_DASHBOARD_ID,
BusterRoutes.APP_CHAT
];
const publicPages: BusterRoutes[] = [
BusterRoutes.APP_METRIC_ID,
BusterRoutes.APP_DASHBOARD_ID,
BusterRoutes.EMBED_METRIC_ID,
BusterRoutes.EMBED_DASHBOARD_ID,
...Object.values(BusterEmbedRoutes),
...Object.values(BusterAuthRoutes)
];

View File

@ -3,7 +3,6 @@ export enum BusterAppRoutes {
APP_COLLECTIONS = '/app/collections',
APP_COLLECTIONS_ID = '/app/collections/:collectionId',
APP_METRIC = '/app/metrics',
APP_METRIC_ID = '/app/metrics/:metricId',
APP_METRIC_ID_CHART = '/app/metrics/:metricId/chart',
APP_METRIC_ID_VERSION_NUMBER = '/app/metrics/:metricId/chart?metric_version_number=:versionNumber',
APP_METRIC_ID_FILE = '/app/metrics/:metricId/file',
@ -53,7 +52,6 @@ export type BusterAppRoutesWithArgs = {
collectionId: string;
};
[BusterAppRoutes.APP_METRIC]: { route: BusterAppRoutes.APP_METRIC };
[BusterAppRoutes.APP_METRIC_ID]: { route: BusterAppRoutes.APP_METRIC_ID; metricId: string };
[BusterAppRoutes.APP_METRIC_ID_CHART]: {
route: BusterAppRoutes.APP_METRIC_ID_CHART;
metricId: string;
@ -184,6 +182,5 @@ export type BusterAppRoutesWithArgs = {
chatId: string;
valueId: string;
};
[BusterAppRoutes.APP_METRIC_ID]: { route: BusterAppRoutes.APP_METRIC_ID; metricId: string };
[BusterAppRoutes.APP_VALUE_ID]: { route: BusterAppRoutes.APP_VALUE_ID; valueId: string };
};

View File

@ -13,7 +13,7 @@ export const pathNameToRoute = (pathName: string, params: any): BusterRoutes =>
[BusterRoutes.APP_CHAT_ID_REASONING_ID]: BusterRoutes.APP_CHAT,
[BusterRoutes.APP_CHAT_ID_TERM_ID]: BusterRoutes.APP_CHAT,
[BusterRoutes.APP_CHAT_ID_VALUE_ID]: BusterRoutes.APP_CHAT,
[BusterRoutes.APP_METRIC_ID]: BusterRoutes.APP_METRIC,
[BusterRoutes.APP_METRIC_ID_CHART]: BusterRoutes.APP_METRIC,
[BusterRoutes.APP_DASHBOARD_ID]: BusterRoutes.APP_DASHBOARDS,
[BusterRoutes.APP_COLLECTIONS_ID]: BusterRoutes.APP_COLLECTIONS,
[BusterRoutes.APP_DATASETS_ID]: BusterRoutes.APP_DATASETS,
@ -43,7 +43,7 @@ export const pathNameToParentRoute = (pathName: string, params: any): BusterRout
[BusterRoutes.APP_CHAT_ID_REASONING_ID]: BusterRoutes.APP_CHAT,
[BusterRoutes.APP_CHAT_ID_TERM_ID]: BusterRoutes.APP_CHAT,
[BusterRoutes.APP_CHAT_ID_VALUE_ID]: BusterRoutes.APP_CHAT,
[BusterRoutes.APP_METRIC_ID]: BusterRoutes.APP_METRIC,
[BusterRoutes.APP_METRIC_ID_CHART]: BusterRoutes.APP_METRIC,
[BusterRoutes.APP_DASHBOARD_ID]: BusterRoutes.APP_DASHBOARDS,
[BusterRoutes.APP_COLLECTIONS_ID]: BusterRoutes.APP_COLLECTIONS,
[BusterRoutes.APP_DATASETS_ID]: BusterRoutes.APP_DATASETS,