| 1 | import { |
| 2 | CloneTransports, |
| 3 | CloneUrlField, |
| 4 | } from "@/components/repositories/clone-popover"; |
| 5 | |
| 6 | export function RepositoryEmptyState({ |
| 7 | cloneUrl, |
| 8 | sshCloneUrl, |
| 9 | defaultBranch, |
| 10 | }: { |
| 11 | cloneUrl: string |
| 12 | sshCloneUrl?: string |
| 13 | defaultBranch: string |
| 14 | }) { |
| 15 | return ( |
| 16 | <div className="flex flex-col gap-6 rounded-lg border p-6 |
| 17 | <div className="flex flex-col gap-2 |
| 18 | <h2 className="text-base font-semibold |
| 19 | <p className="text-sm text-muted-foreground |
| 20 | This repository is empty. Push a commit and it shows up here. |
| 21 | </p> |
| 22 | </div> |
| 23 | |
| 24 | <CloneTransports |
| 25 | http={<QuickSetup |
| 26 | ssh={ |
| 27 | sshCloneUrl && ( |
| 28 | <QuickSetup |
| 29 | cloneUrl={sshCloneUrl} |
| 30 | defaultBranch={defaultBranch} |
| 31 | note="Add an SSH key under Settings → Security first, or these commands will be refused." |
| 32 | /> |
| 33 | ) |
| 34 | } |
| 35 | /> |
| 36 | </div> |
| 37 | ); |
| 38 | } |
| 39 | |
| 40 | function QuickSetup({ |
| 41 | cloneUrl, |
| 42 | defaultBranch, |
| 43 | note, |
| 44 | }: { |
| 45 | cloneUrl: string |
| 46 | defaultBranch: string |
| 47 | note?: string |
| 48 | }) { |
| 49 | return ( |
| 50 | <div className="flex flex-col gap-6 |
| 51 | <CloneUrlField cloneUrl={ |
| 52 | {note && <p |
| 53 | |
| 54 | <Setup |
| 55 | title="Create a new repository on the command line" |
| 56 | commands={[ |
| 57 | 'echo "# repository" >> README.md', |
| 58 | "git init", |
| 59 | "git add README.md", |
| 60 | 'git commit -m "first commit"', |
| 61 | `git branch -M ${defaultBranch}`, |
| 62 | `git remote add origin ${cloneUrl}`, |
| 63 | `git push -u origin ${defaultBranch}`, |
| 64 | ]} |
| 65 | /> |
| 66 | |
| 67 | <Setup |
| 68 | title="Push an existing repository from the command line" |
| 69 | commands={[ |
| 70 | `git remote add origin ${cloneUrl}`, |
| 71 | `git branch -M ${defaultBranch}`, |
| 72 | `git push -u origin ${defaultBranch}`, |
| 73 | ]} |
| 74 | /> |
| 75 | </div> |
| 76 | ); |
| 77 | } |
| 78 | |
| 79 | function Setup({ title |
| 80 | return ( |
| 81 | <div className="flex flex-col gap-2 |
| 82 | <h3 className="text-sm font-semibold |
| 83 | {/* one block, so selecting it copies the whole sequence */ |
| 84 | <pre className="overflow-x-auto rounded-md border bg-muted/40 p-3 text-xs leading-relaxed |
| 85 | <code>{commands.join |
| 86 | </pre> |
| 87 | </div> |
| 88 | ); |
| 89 | } |