start adding embeddable routes

This commit is contained in:
Nate Kelley 2025-03-18 09:53:35 -06:00
parent 54ef8971af
commit ccb195a65e
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
8 changed files with 50 additions and 2 deletions

View File

@ -7,7 +7,6 @@ import { ClientRedirect } from '../../components/ui/layouts/ClientRedirect';
import { LayoutClient } from './layoutClient';
import { prefetchGetMyUserInfo } from '@/api/buster_rest';
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
import path from 'path';
export const dynamic = 'force-dynamic';

View File

@ -0,0 +1,7 @@
export default function EmbedDashboardsPage({
params: { dashboardId }
}: {
params: { dashboardId: string };
}) {
return <div>EmbedDashboardsPage {dashboardId}</div>;
}

View File

@ -0,0 +1,13 @@
import { GlobalErrorComponent } from '@/components/features/errors/GlobalErrorComponent';
import { BusterReactQueryProvider } from '@/context/BusterReactQuery/BusterReactQueryAndApi';
import { BusterPosthogProvider } from '@/context/Posthog';
export default async function EmbedLayout({ children }: { children: React.ReactNode }) {
return (
<GlobalErrorComponent>
<BusterReactQueryProvider>
<BusterPosthogProvider>{children}</BusterPosthogProvider>
</BusterReactQueryProvider>
</GlobalErrorComponent>
);
}

View File

@ -0,0 +1,7 @@
export default function EmbedMetricsPage({
params: { metricId }
}: {
params: { metricId: string };
}) {
return <div>EmbedMetricsPage {metricId}</div>;
}

View File

@ -11,7 +11,8 @@ export async function middleware(request: NextRequest) {
const performUserCheck = !isPublicPage(request);
cspPolicyMiddleware(request);
nextPathnameMiddleware(request, supabaseResponse);
if (performUserCheck && !user && !request.nextUrl.pathname.includes('/test/')) {
if (performUserCheck && !user) {
return NextResponse.redirect(
new URL(createBusterRoute({ route: BusterRoutes.AUTH_LOGIN }), process.env.NEXT_PUBLIC_URL)
);

View File

@ -1,4 +1,5 @@
import { BusterAuthRoutes } from '@/routes/busterRoutes/busterAuthRoutes';
import { BusterEmbedRoutes } from '@/routes/busterRoutes/busterEmbedRoutes';
import { BusterRoutes, createPathnameToBusterRoute } from '@/routes/busterRoutes/busterRoutes';
import { NextRequest } from 'next/server';
@ -13,6 +14,7 @@ const publicPages: BusterRoutes[] = [
BusterRoutes.APP_METRIC_ID,
BusterRoutes.APP_DASHBOARD_ID,
BusterRoutes.APP_DASHBOARD_METRICS_ID,
...Object.values(BusterEmbedRoutes),
...Object.values(BusterAuthRoutes)
];

View File

@ -0,0 +1,15 @@
export enum BusterEmbedRoutes {
EMBED_METRIC_ID = '/embed/metrics/:metricId',
EMBED_DASHBOARD_ID = '/embed/dashboards/:dashboardId'
}
export type BusterEmbedRoutesWithArgs = {
[BusterEmbedRoutes.EMBED_METRIC_ID]: {
route: BusterEmbedRoutes.EMBED_METRIC_ID;
metricId: string;
};
[BusterEmbedRoutes.EMBED_DASHBOARD_ID]: {
route: BusterEmbedRoutes.EMBED_DASHBOARD_ID;
dashboardId: string;
};
};

View File

@ -1,5 +1,6 @@
import { BusterAppRoutes, BusterAppRoutesWithArgs } from './busterAppRoutes';
import { BusterAuthRoutes, BusterAuthRoutesWithArgs } from './busterAuthRoutes';
import { BusterEmbedRoutes, BusterEmbedRoutesWithArgs } from './busterEmbedRoutes';
import { BusterSettingsRoutes, BusterSettingsRoutesWithArgs } from './busterSettingsRoutes';
export enum BusterRootRoutes {
@ -14,6 +15,7 @@ export const BusterRoutes = {
...BusterAppRoutes,
...BusterAuthRoutes,
...BusterSettingsRoutes,
...BusterEmbedRoutes,
...BusterRootRoutes
};
@ -21,11 +23,13 @@ export type BusterRoutes =
| BusterAppRoutes
| BusterAuthRoutes
| BusterSettingsRoutes
| BusterEmbedRoutes
| BusterRootRoutes;
export type BusterRoutesWithArgs = BusterRootRoutesWithArgs &
BusterAuthRoutesWithArgs &
BusterAppRoutesWithArgs &
BusterEmbedRoutesWithArgs &
BusterSettingsRoutesWithArgs;
export type BusterRoutesWithArgsRoute = BusterRoutesWithArgs[BusterRoutes];