mirror of https://github.com/buster-so/buster.git
start adding embeddable routes
This commit is contained in:
parent
54ef8971af
commit
ccb195a65e
|
@ -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';
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
export default function EmbedDashboardsPage({
|
||||
params: { dashboardId }
|
||||
}: {
|
||||
params: { dashboardId: string };
|
||||
}) {
|
||||
return <div>EmbedDashboardsPage {dashboardId}</div>;
|
||||
}
|
|
@ -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>
|
||||
);
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
export default function EmbedMetricsPage({
|
||||
params: { metricId }
|
||||
}: {
|
||||
params: { metricId: string };
|
||||
}) {
|
||||
return <div>EmbedMetricsPage {metricId}</div>;
|
||||
}
|
|
@ -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)
|
||||
);
|
||||
|
|
|
@ -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)
|
||||
];
|
||||
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
};
|
|
@ -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];
|
||||
|
|
Loading…
Reference in New Issue