-
Notifications
You must be signed in to change notification settings - Fork 286
Expand file tree
/
Copy pathlayout.tsx
More file actions
47 lines (42 loc) · 1.81 KB
/
layout.tsx
File metadata and controls
47 lines (42 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { InfoIcon } from "lucide-react";
import { NavigationMenu } from "../components/navigationMenu";
import { SINGLE_TENANT_ORG_DOMAIN } from "@/lib/constants";
import Link from "next/link";
import { getCurrentUserRole, getReposStats } from "@/actions";
import { isServiceError } from "@/lib/utils";
import { ServiceErrorException } from "@/lib/serviceError";
import { OrgRole } from "@sourcebot/db";
interface LayoutProps {
children: React.ReactNode;
params: Promise<{ domain: string }>;
}
export default async function Layout(
props: LayoutProps
) {
const params = await props.params;
const { domain } = params;
const { children } = props;
const repoStats = await getReposStats();
if (isServiceError(repoStats)) {
throw new ServiceErrorException(repoStats);
}
const userRoleInOrg = await getCurrentUserRole();
return (
<div className="min-h-screen flex flex-col">
<NavigationMenu domain={domain} />
{(repoStats.numberOfRepos === 0 && userRoleInOrg === OrgRole.OWNER) && (
<div className="w-full flex flex-row justify-center items-center bg-accent py-0.5">
<InfoIcon className="w-4 h-4 mr-1" />
<span><span className="font-medium">No repositories configured.</span> Create a <Link href={`/${SINGLE_TENANT_ORG_DOMAIN}/settings/connections`} className="text-link hover:underline">connection</Link> to get started.</span>
</div>
)}
<main className="flex-grow flex justify-center p-4 bg-backgroundSecondary relative">
<div className="w-full max-w-6xl rounded-lg p-6">
<div className="container mx-auto">
{children}
</div>
</div>
</main>
</div>
)
}