feat: allow rank-gated housekeeping preview in production
This commit is contained in:
1 parent
1dc8d1d46f
commit
9af1e62655
7 files changed
+75
-12
No files matched your search
@@ -2,12 +2,26 @@ import { notFound } from "next/navigation";
|
||||
import type { ReactNode } from "react";
|
||||
import { env } from "@/env";
|
||||
import { isHousekeepingPreviewEnabled } from "@/features/housekeeping/foundation/preview-gate";
|
||||
import { getHousekeepingCapabilityContext } from "@/features/housekeeping/foundation/server-capability-context";
|
||||
import { PERMS } from "@/lib/permission-slugs";
|
||||
|
||||
export default async function AdminNextLayout({
|
||||
children,
|
||||
}: {
|
||||
children: ReactNode;
|
||||
}) {
|
||||
const hasProductionAccess =
|
||||
env.NODE_ENV === "production" && env.HOUSEKEEPING_NEXT_PREVIEW_ENABLED
|
||||
? (await getHousekeepingCapabilityContext()).has(
|
||||
PERMS.HOUSEKEEPING_PREVIEW_ACCESS,
|
||||
)
|
||||
: false;
|
||||
|
||||
export default function AdminNextLayout({ children }: { children: ReactNode }) {
|
||||
if (
|
||||
!isHousekeepingPreviewEnabled({
|
||||
nodeEnv: env.NODE_ENV,
|
||||
flag: env.HOUSEKEEPING_NEXT_PREVIEW_ENABLED,
|
||||
hasProductionAccess,
|
||||
})
|
||||
) {
|
||||
notFound();
|
||||
|
||||
Reference in new issue
Block a user