This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
||||
// The workspace layout: the workspace has to be one this person can see, and the page says 404 before
|
||||
// it starts streaming if it is not (spec §3.3). A restricted workspace the person is not in is not in
|
||||
// `tenancy.workspace.list`, so it is the same not-found as one that does not exist.
|
||||
|
||||
import { workspaceList } from "@conusai-kit/tenancy"
|
||||
import { notFound } from "next/navigation"
|
||||
import type { ReactNode } from "react"
|
||||
import { orFallback } from "../../../src/server/guard"
|
||||
import { pageContext } from "../../../src/server/page"
|
||||
|
||||
export const dynamic = "force-dynamic"
|
||||
|
||||
export default async function WorkspaceLayout({
|
||||
children,
|
||||
params,
|
||||
}: {
|
||||
children: ReactNode
|
||||
params: Promise<{ org: string; workspace: string }>
|
||||
}): Promise<ReactNode> {
|
||||
const { org, workspace } = await params
|
||||
const { caller, path } = await pageContext()
|
||||
const { workspaces } = await orFallback(path, () => caller.call(workspaceList, { org }))
|
||||
if (!workspaces.some((entry) => entry.slug === workspace)) notFound()
|
||||
return children
|
||||
}
|
||||
Reference in New Issue
Block a user