| 1 | import { notFound } from "next/navigation"; |
| 2 | |
| 3 | import { RepositoryGeneralSettings } |
| 4 | import { |
| 5 | createServerClient, |
| 6 | getAdminOrganizations, |
| 7 | getServerSession, |
| 8 | } from "@/lib/api/server"; |
| 9 | import { atLeast } |
| 10 | |
| 11 | export default async function |
| 12 | params, |
| 13 | }: PageProps< |
| 14 | const { username, |
| 15 | const client = |
| 16 | const path = |
| 17 | |
| 18 | const [repository, |
| 19 | client.GET("/api/repositories/{username}/{slug} |
| 20 | client.GET("/api/repositories/{username}/{slug}/branches |
| 21 | params: { path |
| 22 | }), |
| 23 | ]); |
| 24 | if (!repository.data |
| 25 | |
| 26 | return ( |
| 27 | <RepositoryGeneralSettings |
| 28 | // Remount after a save so each card starts from what was stored. |
| 29 | key={repository.data |
| 30 | username={username} |
| 31 | slug={repository.data |
| 32 | name={repository.data |
| 33 | description={repository.data |
| 34 | visibility={repository.data |
| 35 | defaultBranch={branches.data |
| 36 | branches={branches.data |
| 37 | isAdmin={atLeast(repository |
| 38 | transferTargets={ |
| 39 | atLeast(repository.data |
| 40 | ? await transferTargets( |
| 41 | : [] |
| 42 | } |
| 43 | canTransfer={atLeast(repository |
| 44 | /> |
| 45 | ); |
| 46 | } |
| 47 | |
| 48 | /** The viewer's own account and the organizations they administer, less the current owner. */ |
| 49 | async function transferTargets( |
| 50 | const [session, |
| 51 | getServerSession(), |
| 52 | getAdminOrganizations(), |
| 53 | ]); |
| 54 | return [session?.user |
| 55 | (owner): owner |
| 56 | ); |
| 57 | } |