Files
wehub-resource-sync e4dcfc49aa
Tests / Import Check (Python 3.13) (push) Has been cancelled
Tests / Import Check (Python 3.14) (push) Has been cancelled
Tests / Python Tests (Python 3.11) (push) Has been cancelled
Tests / Python Tests (Python 3.12) (push) Has been cancelled
Tests / Python Tests (Python 3.14) (push) Has been cancelled
Tests / Test Summary (push) Has been cancelled
Tests / Lint and Format (push) Has been cancelled
Tests / Web Node Tests (push) Has been cancelled
Tests / Import Check (Python 3.11) (push) Has been cancelled
Tests / Import Check (Python 3.12) (push) Has been cancelled
Tests / Python Tests (Python 3.13) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:00:43 +08:00

25 lines
697 B
TypeScript

"use client";
import { usePathname } from "next/navigation";
import { capabilityForPath } from "@/lib/capability-routes";
import { RequireCapability } from "./RequireCapability";
/**
* Route-level gate: derives the required model capability from the current
* pathname and locks the page when the user lacks it. Mounted once per authed
* layout group, so direct-URL access to a gated feature is covered too.
*/
export default function CapabilityGate({
children,
}: {
children: React.ReactNode;
}) {
const pathname = usePathname() ?? "";
const capability = capabilityForPath(pathname);
return (
<RequireCapability capability={capability}>{children}</RequireCapability>
);
}