File
Blob: src/client/islands/repo-admin/index.tsx
| 1 | /// <reference lib="dom" /> |
| 2 | |
| 3 | import { TriangleAlert } from "lucide-react"; |
| 4 | import { hydrateIsland } from "@/client/hydrate"; |
| 5 | import { countRefsByKind } from "@/shared/git/ref-display"; |
| 6 | |
| 7 | export type { RepoAdminProps } from "./types"; |
| 8 | import type { RepoAdminProps } from "./types"; |
| 9 | import { useRepoAdminActions } from "./useRepoAdminActions"; |
| 10 | import { RepoOverviewCard } from "./RepoOverviewCard"; |
| 11 | import { CompactionCard } from "./CompactionCard"; |
| 12 | import { PackFilesCard } from "./PackFilesCard"; |
| 13 | import { RefsCard } from "./RefsCard"; |
| 14 | import { DebugToolsCard } from "./DebugToolsCard"; |
| 15 | import { DangerZoneCard } from "./DangerZoneCard"; |
| 16 | |
| 17 | export function RepoAdminIsland(props: RepoAdminProps) { |
| 18 | const { |
| 19 | owner, |
| 20 | repo, |
| 21 | head, |
| 22 | refs, |
| 23 | storageSize, |
| 24 | packCount, |
| 25 | packList, |
| 26 | state, |
| 27 | defaultBranch, |
| 28 | compactionStatus, |
| 29 | compactionStartedAt, |
| 30 | compactionData, |
| 31 | supersededPackCount, |
| 32 | } = props; |
| 33 | |
| 34 | const { |
| 35 | compactionResult, |
| 36 | oidResult, |
| 37 | stateDump, |
| 38 | pending, |
| 39 | startCompaction, |
| 40 | clearCompaction, |
| 41 | removePack, |
| 42 | checkOid, |
| 43 | dumpState, |
| 44 | purgeRepo, |
| 45 | } = useRepoAdminActions(owner, repo); |
| 46 | |
| 47 | const { branchCount, tagCount } = countRefsByKind(refs); |
| 48 | const packStats = Array.isArray(state.packStats) ? state.packStats : []; |
| 49 | |
| 50 | return ( |
| 51 | <div className="space-y-6"> |
| 52 | <div className="rounded-xl border border-amber-500/20 bg-amber-500/10 p-4 text-sm text-amber-700 dark:text-amber-300"> |
| 53 | <strong> |
| 54 | <TriangleAlert |
| 55 | className="mr-2 inline h-4 w-4 align-[-2px] text-amber-600 dark:text-amber-400" |
| 56 | aria-hidden="true" |
| 57 | /> |
| 58 | Admin Area |
| 59 | </strong>{" "} |
| 60 | - Actions here can permanently modify repository data |
| 61 | </div> |
| 62 | |
| 63 | <RepoOverviewCard |
| 64 | storageSize={storageSize} |
| 65 | packCount={packCount} |
| 66 | supersededPackCount={supersededPackCount} |
| 67 | compactionStatus={compactionStatus} |
| 68 | state={state} |
| 69 | head={head} |
| 70 | branchCount={branchCount} |
| 71 | tagCount={tagCount} |
| 72 | /> |
| 73 | |
| 74 | <CompactionCard |
| 75 | compactionData={compactionData} |
| 76 | compactionStartedAt={compactionStartedAt} |
| 77 | compactionStatus={compactionStatus} |
| 78 | state={state} |
| 79 | pending={pending} |
| 80 | startCompaction={startCompaction} |
| 81 | clearCompaction={clearCompaction} |
| 82 | compactionResult={compactionResult} |
| 83 | /> |
| 84 | |
| 85 | <PackFilesCard |
| 86 | packCount={packCount} |
| 87 | packStats={packStats} |
| 88 | pending={pending} |
| 89 | removePack={removePack} |
| 90 | /> |
| 91 | |
| 92 | <RefsCard refs={refs} /> |
| 93 | |
| 94 | <DebugToolsCard |
| 95 | oidResult={oidResult} |
| 96 | stateDump={stateDump} |
| 97 | pending={pending} |
| 98 | checkOid={checkOid} |
| 99 | dumpState={dumpState} |
| 100 | /> |
| 101 | |
| 102 | <DangerZoneCard |
| 103 | defaultBranch={defaultBranch} |
| 104 | packList={packList} |
| 105 | pending={pending} |
| 106 | purgeRepo={purgeRepo} |
| 107 | /> |
| 108 | </div> |
| 109 | ); |
| 110 | } |
| 111 | |
| 112 | export function initRepoAdmin() { |
| 113 | hydrateIsland<RepoAdminProps>("repo-admin", RepoAdminIsland); |
| 114 | } |