mirror of https://github.com/buster-so/buster.git
hydration boundary for the metric and asset stores
This commit is contained in:
parent
023ac538e2
commit
80f8ce86fd
|
@ -1,8 +1,4 @@
|
||||||
import { prefetchGetMetric } from '@/api/buster_rest/metrics';
|
|
||||||
import { metricsQueryKeys } from '@/api/query_keys/metric';
|
|
||||||
import { HydrationBoundaryMetricStore } from '@/context/Metrics/useOriginalMetricStore';
|
|
||||||
import { AppAssetCheckLayout } from '@/layouts/AppAssetCheckLayout';
|
import { AppAssetCheckLayout } from '@/layouts/AppAssetCheckLayout';
|
||||||
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
|
|
||||||
|
|
||||||
export default async function MetricLayout({
|
export default async function MetricLayout({
|
||||||
children,
|
children,
|
||||||
|
@ -12,18 +8,10 @@ export default async function MetricLayout({
|
||||||
params: Promise<{ metricId: string }>;
|
params: Promise<{ metricId: string }>;
|
||||||
}) {
|
}) {
|
||||||
const { metricId } = await params;
|
const { metricId } = await params;
|
||||||
const queryClient = await prefetchGetMetric({ id: metricId });
|
|
||||||
|
|
||||||
const metric = queryClient.getQueryData(metricsQueryKeys.metricsGetMetric(metricId).queryKey);
|
|
||||||
// const state = queryClient.getQueryState(queryKeys.metricsGetMetric(metricId).queryKey);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HydrationBoundary state={dehydrate(queryClient)}>
|
|
||||||
<HydrationBoundaryMetricStore metric={metric}>
|
|
||||||
<AppAssetCheckLayout assetId={metricId} type="metric">
|
<AppAssetCheckLayout assetId={metricId} type="metric">
|
||||||
{children}
|
{children}
|
||||||
</AppAssetCheckLayout>
|
</AppAssetCheckLayout>
|
||||||
</HydrationBoundaryMetricStore>
|
|
||||||
</HydrationBoundary>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,16 +25,3 @@ export const HydrationBoundaryAssetStore: React.FC<{
|
||||||
|
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
};
|
};
|
||||||
|
|
||||||
// export const HydrationBoundaryMetricStore: React.FC<{
|
|
||||||
// children: React.ReactNode;
|
|
||||||
// metric?: OriginalMetricStore['originalMetrics'][string];
|
|
||||||
// }> = ({ children, metric }) => {
|
|
||||||
// const setOriginalMetrics = useOriginalMetricStore((x) => x.setOriginalMetric);
|
|
||||||
|
|
||||||
// useMount(() => {
|
|
||||||
// if (metric) setOriginalMetrics(metric);
|
|
||||||
// });
|
|
||||||
|
|
||||||
// return <>{children}</>;
|
|
||||||
// };
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import { prefetchGetMetric } from '@/api/buster_rest/metrics/queryReqestsServer'
|
||||||
import { prefetchGetDashboard } from '@/api/buster_rest/dashboards/queryServerRequests';
|
import { prefetchGetDashboard } from '@/api/buster_rest/dashboards/queryServerRequests';
|
||||||
import { metricsQueryKeys } from '@/api/query_keys/metric';
|
import { metricsQueryKeys } from '@/api/query_keys/metric';
|
||||||
import { dashboardQueryKeys } from '@/api/query_keys/dashboard';
|
import { dashboardQueryKeys } from '@/api/query_keys/dashboard';
|
||||||
|
import { HydrationBoundaryAssetStore } from '@/context/Assets/HydrationBoundaryAssetStore';
|
||||||
|
|
||||||
export type AppAssetCheckLayoutProps = {
|
export type AppAssetCheckLayoutProps = {
|
||||||
assetId: string;
|
assetId: string;
|
||||||
|
@ -53,9 +54,11 @@ export const AppAssetCheckLayout: React.FC<
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HydrationBoundary state={dehydratedState}>
|
<HydrationBoundary state={dehydratedState}>
|
||||||
|
<HydrationBoundaryAssetStore asset={queryData}>
|
||||||
<AppAssetLoadingContainer assetId={assetId} type={type}>
|
<AppAssetLoadingContainer assetId={assetId} type={type}>
|
||||||
{Component}
|
{Component}
|
||||||
</AppAssetLoadingContainer>
|
</AppAssetLoadingContainer>
|
||||||
|
</HydrationBoundaryAssetStore>
|
||||||
</HydrationBoundary>
|
</HydrationBoundary>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue