mirror of https://github.com/buster-so/buster.git
dashboard fixes
This commit is contained in:
parent
18b17d69ef
commit
0fbf690504
|
@ -91,7 +91,7 @@ export const useGetDashboard = <TData = BusterDashboardResponse>(
|
||||||
return useQuery({
|
return useQuery({
|
||||||
...dashboardQueryKeys.dashboardGetDashboard(id!, version_number),
|
...dashboardQueryKeys.dashboardGetDashboard(id!, version_number),
|
||||||
queryFn: () => queryFn(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,
|
select: params?.select,
|
||||||
...params
|
...params
|
||||||
});
|
});
|
||||||
|
|
|
@ -25,7 +25,7 @@ export const ShareMenuContent: React.FC<{
|
||||||
const onCopyLink = useMemoizedFn(() => {
|
const onCopyLink = useMemoizedFn(() => {
|
||||||
let url = '';
|
let url = '';
|
||||||
if (assetType === ShareAssetType.METRIC && assetId) {
|
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) {
|
} else if (assetType === ShareAssetType.DASHBOARD && assetId) {
|
||||||
url = createBusterRoute({
|
url = createBusterRoute({
|
||||||
route: BusterRoutes.APP_DASHBOARD_ID,
|
route: BusterRoutes.APP_DASHBOARD_ID,
|
||||||
|
|
|
@ -22,14 +22,14 @@ export const ShareMenuContentEmbed: React.FC<ShareMenuContentBodyProps> = React.
|
||||||
|
|
||||||
if (assetType === ShareAssetType.METRIC) {
|
if (assetType === ShareAssetType.METRIC) {
|
||||||
url = createBusterRoute({
|
url = createBusterRoute({
|
||||||
route: BusterRoutes.APP_METRIC_ID,
|
route: BusterRoutes.EMBED_METRIC_ID,
|
||||||
metricId: assetId
|
metricId: assetId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (assetType === ShareAssetType.DASHBOARD) {
|
if (assetType === ShareAssetType.DASHBOARD) {
|
||||||
url = createBusterRoute({
|
url = createBusterRoute({
|
||||||
route: BusterRoutes.APP_DASHBOARD_ID,
|
route: BusterRoutes.EMBED_DASHBOARD_ID,
|
||||||
dashboardId: assetId
|
dashboardId: assetId
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ export const ShareMenuContentPublish: React.FC<ShareMenuContentBodyProps> = Reac
|
||||||
const url = useMemo(() => {
|
const url = useMemo(() => {
|
||||||
let url = '';
|
let url = '';
|
||||||
if (assetType === ShareAssetType.METRIC) {
|
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) {
|
} else if (assetType === ShareAssetType.DASHBOARD) {
|
||||||
url = createBusterRoute({ route: BusterRoutes.APP_DASHBOARD_ID, dashboardId: assetId });
|
url = createBusterRoute({ route: BusterRoutes.APP_DASHBOARD_ID, dashboardId: assetId });
|
||||||
} else if (assetType === ShareAssetType.COLLECTION) {
|
} else if (assetType === ShareAssetType.COLLECTION) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ export const assetTypeToIcon = (assetType: ShareAssetType) => {
|
||||||
export const assetTypeToRoute = (assetType: ShareAssetType, assetId: string) => {
|
export const assetTypeToRoute = (assetType: ShareAssetType, assetId: string) => {
|
||||||
switch (assetType) {
|
switch (assetType) {
|
||||||
case ShareAssetType.METRIC:
|
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:
|
case ShareAssetType.DASHBOARD:
|
||||||
return createBusterRoute({ route: BusterRoutes.APP_DASHBOARD_ID, dashboardId: assetId });
|
return createBusterRoute({ route: BusterRoutes.APP_DASHBOARD_ID, dashboardId: assetId });
|
||||||
case ShareAssetType.COLLECTION:
|
case ShareAssetType.COLLECTION:
|
||||||
|
|
|
@ -34,7 +34,7 @@ const mockFavorites = [
|
||||||
{
|
{
|
||||||
id: '456',
|
id: '456',
|
||||||
name: 'Important Metrics',
|
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,
|
ype: ShareAssetType.METRIC,
|
||||||
asset_id: '456',
|
asset_id: '456',
|
||||||
created_at: new Date().toISOString(),
|
created_at: new Date().toISOString(),
|
||||||
|
@ -43,7 +43,7 @@ const mockFavorites = [
|
||||||
{
|
{
|
||||||
id: '789',
|
id: '789',
|
||||||
name: 'Favorite Metric 3',
|
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,
|
ype: ShareAssetType.METRIC,
|
||||||
asset_id: '789',
|
asset_id: '789',
|
||||||
created_at: new Date().toISOString(),
|
created_at: new Date().toISOString(),
|
||||||
|
@ -96,6 +96,6 @@ export const FavoritesActiveRoute: Story = {
|
||||||
args: {
|
args: {
|
||||||
isAdmin: true,
|
isAdmin: true,
|
||||||
favorites: mockFavorites,
|
favorites: mockFavorites,
|
||||||
activePage: createBusterRoute({ route: BusterRoutes.APP_METRIC_ID, metricId: '456' })
|
activePage: createBusterRoute({ route: BusterRoutes.APP_METRIC_ID_CHART, metricId: '456' })
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -67,7 +67,7 @@ export const useListVersionHistories = ({
|
||||||
if (rereouteToAsset) {
|
if (rereouteToAsset) {
|
||||||
await onChangePage(
|
await onChangePage(
|
||||||
createBusterRoute({
|
createBusterRoute({
|
||||||
route: BusterRoutes.APP_METRIC_ID,
|
route: BusterRoutes.APP_METRIC_ID_CHART,
|
||||||
metricId: assetId
|
metricId: assetId
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
@ -163,7 +163,7 @@ const CollectionIconRecord: Record<string, React.ReactNode> = {
|
||||||
const createAssetLink = (asset: BusterCollectionItemAsset, collectionId: string) => {
|
const createAssetLink = (asset: BusterCollectionItemAsset, collectionId: string) => {
|
||||||
if (asset.asset_type === ShareAssetType.METRIC) {
|
if (asset.asset_type === ShareAssetType.METRIC) {
|
||||||
return createBusterRoute({
|
return createBusterRoute({
|
||||||
route: BusterRoutes.APP_METRIC_ID,
|
route: BusterRoutes.APP_METRIC_ID_CHART,
|
||||||
metricId: asset.id
|
metricId: asset.id
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ const DashboardMetricItemBase: React.FC<{
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return createBusterRoute({
|
return createBusterRoute({
|
||||||
route: BusterRoutes.APP_METRIC_ID,
|
route: BusterRoutes.APP_METRIC_ID_CHART,
|
||||||
metricId: metricId
|
metricId: metricId
|
||||||
});
|
});
|
||||||
}, [metricId, chatId]);
|
}, [metricId, chatId]);
|
||||||
|
|
|
@ -38,7 +38,7 @@ export const MetricItemsContainer: React.FC<{
|
||||||
id: metric.id,
|
id: metric.id,
|
||||||
data: metric,
|
data: metric,
|
||||||
link: createBusterRoute({
|
link: createBusterRoute({
|
||||||
route: BusterRoutes.APP_METRIC_ID,
|
route: BusterRoutes.APP_METRIC_ID_CHART,
|
||||||
metricId: metric.id
|
metricId: metric.id
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -66,7 +66,7 @@ const assetRouteRecord: Record<AllFileTypes, (assetId: string) => string | null>
|
||||||
}),
|
}),
|
||||||
metric: (assetId) =>
|
metric: (assetId) =>
|
||||||
createBusterRoute({
|
createBusterRoute({
|
||||||
route: BusterRoutes.APP_METRIC_ID,
|
route: BusterRoutes.APP_METRIC_ID_CHART,
|
||||||
metricId: assetId
|
metricId: assetId
|
||||||
}),
|
}),
|
||||||
dashboard: (assetId) =>
|
dashboard: (assetId) =>
|
||||||
|
|
|
@ -25,7 +25,7 @@ export const DashboardContainerHeaderButtons: React.FC<FileContainerButtonsProps
|
||||||
{ select: (x) => x.permission }
|
{ select: (x) => x.permission }
|
||||||
);
|
);
|
||||||
|
|
||||||
if (dashboardError) return null;
|
if (dashboardError || !permission) return null;
|
||||||
|
|
||||||
const isEditor = canEdit(permission);
|
const isEditor = canEdit(permission);
|
||||||
const isEffectiveOwner = getIsEffectiveOwner(permission);
|
const isEffectiveOwner = getIsEffectiveOwner(permission);
|
||||||
|
|
|
@ -15,11 +15,7 @@ import { useGetMetric } from '@/api/buster_rest/metrics';
|
||||||
import { ThreeDotMenuButton } from './MetricThreeDotMenu';
|
import { ThreeDotMenuButton } from './MetricThreeDotMenu';
|
||||||
import { canEdit, getIsEffectiveOwner } from '@/lib/share';
|
import { canEdit, getIsEffectiveOwner } from '@/lib/share';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { BusterRoutes, createBusterRoute } from '@/routes';
|
import { assetParamsToRoute } from '@/layouts/ChatLayout/ChatLayoutContext/helpers';
|
||||||
import {
|
|
||||||
assetParamsToRoute,
|
|
||||||
createChatAssetRoute
|
|
||||||
} from '@/layouts/ChatLayout/ChatLayoutContext/helpers';
|
|
||||||
|
|
||||||
export const MetricContainerHeaderButtons: React.FC<FileContainerButtonsProps> = React.memo(() => {
|
export const MetricContainerHeaderButtons: React.FC<FileContainerButtonsProps> = React.memo(() => {
|
||||||
const selectedLayout = useChatLayoutContextSelector((x) => x.selectedLayout);
|
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
|
//we assume it is fetched until it is not
|
||||||
if (metricError) return null;
|
if (metricError || !permission) return null;
|
||||||
|
|
||||||
const isEditor = canEdit(permission);
|
const isEditor = canEdit(permission);
|
||||||
const isEffectiveOwner = getIsEffectiveOwner(permission);
|
const isEffectiveOwner = getIsEffectiveOwner(permission);
|
||||||
|
|
|
@ -5,14 +5,16 @@ import { NextRequest } from 'next/server';
|
||||||
import { createPathnameToBusterRoute } from './createRouteHelpers';
|
import { createPathnameToBusterRoute } from './createRouteHelpers';
|
||||||
|
|
||||||
const assetCheckPages: BusterRoutes[] = [
|
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_DASHBOARD_ID,
|
||||||
BusterRoutes.APP_CHAT
|
BusterRoutes.APP_CHAT
|
||||||
];
|
];
|
||||||
|
|
||||||
const publicPages: BusterRoutes[] = [
|
const publicPages: BusterRoutes[] = [
|
||||||
BusterRoutes.APP_METRIC_ID,
|
BusterRoutes.EMBED_METRIC_ID,
|
||||||
BusterRoutes.APP_DASHBOARD_ID,
|
BusterRoutes.EMBED_DASHBOARD_ID,
|
||||||
...Object.values(BusterEmbedRoutes),
|
...Object.values(BusterEmbedRoutes),
|
||||||
...Object.values(BusterAuthRoutes)
|
...Object.values(BusterAuthRoutes)
|
||||||
];
|
];
|
||||||
|
|
|
@ -3,7 +3,6 @@ export enum BusterAppRoutes {
|
||||||
APP_COLLECTIONS = '/app/collections',
|
APP_COLLECTIONS = '/app/collections',
|
||||||
APP_COLLECTIONS_ID = '/app/collections/:collectionId',
|
APP_COLLECTIONS_ID = '/app/collections/:collectionId',
|
||||||
APP_METRIC = '/app/metrics',
|
APP_METRIC = '/app/metrics',
|
||||||
APP_METRIC_ID = '/app/metrics/:metricId',
|
|
||||||
APP_METRIC_ID_CHART = '/app/metrics/:metricId/chart',
|
APP_METRIC_ID_CHART = '/app/metrics/:metricId/chart',
|
||||||
APP_METRIC_ID_VERSION_NUMBER = '/app/metrics/:metricId/chart?metric_version_number=:versionNumber',
|
APP_METRIC_ID_VERSION_NUMBER = '/app/metrics/:metricId/chart?metric_version_number=:versionNumber',
|
||||||
APP_METRIC_ID_FILE = '/app/metrics/:metricId/file',
|
APP_METRIC_ID_FILE = '/app/metrics/:metricId/file',
|
||||||
|
@ -53,7 +52,6 @@ export type BusterAppRoutesWithArgs = {
|
||||||
collectionId: string;
|
collectionId: string;
|
||||||
};
|
};
|
||||||
[BusterAppRoutes.APP_METRIC]: { route: BusterAppRoutes.APP_METRIC };
|
[BusterAppRoutes.APP_METRIC]: { route: BusterAppRoutes.APP_METRIC };
|
||||||
[BusterAppRoutes.APP_METRIC_ID]: { route: BusterAppRoutes.APP_METRIC_ID; metricId: string };
|
|
||||||
[BusterAppRoutes.APP_METRIC_ID_CHART]: {
|
[BusterAppRoutes.APP_METRIC_ID_CHART]: {
|
||||||
route: BusterAppRoutes.APP_METRIC_ID_CHART;
|
route: BusterAppRoutes.APP_METRIC_ID_CHART;
|
||||||
metricId: string;
|
metricId: string;
|
||||||
|
@ -184,6 +182,5 @@ export type BusterAppRoutesWithArgs = {
|
||||||
chatId: string;
|
chatId: string;
|
||||||
valueId: 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 };
|
[BusterAppRoutes.APP_VALUE_ID]: { route: BusterAppRoutes.APP_VALUE_ID; valueId: string };
|
||||||
};
|
};
|
||||||
|
|
|
@ -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_REASONING_ID]: BusterRoutes.APP_CHAT,
|
||||||
[BusterRoutes.APP_CHAT_ID_TERM_ID]: BusterRoutes.APP_CHAT,
|
[BusterRoutes.APP_CHAT_ID_TERM_ID]: BusterRoutes.APP_CHAT,
|
||||||
[BusterRoutes.APP_CHAT_ID_VALUE_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_DASHBOARD_ID]: BusterRoutes.APP_DASHBOARDS,
|
||||||
[BusterRoutes.APP_COLLECTIONS_ID]: BusterRoutes.APP_COLLECTIONS,
|
[BusterRoutes.APP_COLLECTIONS_ID]: BusterRoutes.APP_COLLECTIONS,
|
||||||
[BusterRoutes.APP_DATASETS_ID]: BusterRoutes.APP_DATASETS,
|
[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_REASONING_ID]: BusterRoutes.APP_CHAT,
|
||||||
[BusterRoutes.APP_CHAT_ID_TERM_ID]: BusterRoutes.APP_CHAT,
|
[BusterRoutes.APP_CHAT_ID_TERM_ID]: BusterRoutes.APP_CHAT,
|
||||||
[BusterRoutes.APP_CHAT_ID_VALUE_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_DASHBOARD_ID]: BusterRoutes.APP_DASHBOARDS,
|
||||||
[BusterRoutes.APP_COLLECTIONS_ID]: BusterRoutes.APP_COLLECTIONS,
|
[BusterRoutes.APP_COLLECTIONS_ID]: BusterRoutes.APP_COLLECTIONS,
|
||||||
[BusterRoutes.APP_DATASETS_ID]: BusterRoutes.APP_DATASETS,
|
[BusterRoutes.APP_DATASETS_ID]: BusterRoutes.APP_DATASETS,
|
||||||
|
|
Loading…
Reference in New Issue