phase 3 bug repositories fixes

This commit is contained in:
2026-05-07 01:15:32 +02:00
parent 200c4f43ea
commit 44359c1bb0
29 changed files with 1223 additions and 51 deletions
+87 -18
View File
@@ -15,6 +15,7 @@ export default function RepoPage() {
if (isError || !repo) return <div className="p-6 text-sm text-[#DE350B]">Repository not found.</div>
const branch = ref || repo.defaultBranch
const cloneUrl = `http://localhost:8080/${owner}/${repoName}.git`
return (
<div className="max-w-5xl mx-auto px-4 md:px-6 py-6 space-y-6">
@@ -30,29 +31,97 @@ export default function RepoPage() {
)}
</div>
{/* Description */}
{repo.description && (
<p className="text-sm text-[#5E6C84]">{repo.description}</p>
)}
{/* Branch + nav tabs */}
<div className="flex items-center gap-3 flex-wrap">
<div className="flex items-center gap-1.5 px-2.5 py-1.5 border border-[#DFE1E6] rounded text-sm text-[#172B4D]">
<svg width="14" height="14" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" d="M9.568 3H5.25A2.25 2.25 0 0 0 3 5.25v4.318c0 .597.237 1.17.659 1.591l9.581 9.581c.699.699 1.78.872 2.607.33a18.095 18.095 0 0 0 5.223-5.223c.542-.827.369-1.908-.33-2.607L11.16 3.66A2.25 2.25 0 0 0 9.568 3Z" />
</svg>
{branch}
</div>
<Link
to={`/repos/${owner}/${repoName}/pulls`}
className="text-sm text-[#0052CC] hover:underline"
>
Pull requests
</Link>
</div>
{repo.isEmpty ? (
<GettingStarted owner={owner} repoName={repoName} branch={branch} cloneUrl={cloneUrl} />
) : (
<>
{/* Branch pill + PR link */}
<div className="flex items-center gap-3 flex-wrap">
<div className="flex items-center gap-1.5 px-2.5 py-1.5 border border-[#DFE1E6] rounded text-sm text-[#172B4D]">
<svg width="14" height="14" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" d="M9.568 3H5.25A2.25 2.25 0 0 0 3 5.25v4.318c0 .597.237 1.17.659 1.591l9.581 9.581c.699.699 1.78.872 2.607.33a18.095 18.095 0 0 0 5.223-5.223c.542-.827.369-1.908-.33-2.607L11.16 3.66A2.25 2.25 0 0 0 9.568 3Z" />
</svg>
{branch}
</div>
<Link to={`/repos/${owner}/${repoName}/pulls`} className="text-sm text-[#0052CC] hover:underline">
Pull requests
</Link>
</div>
{/* File tree */}
<TreeBrowser owner={owner} repo={repoName} ref={branch} path={path} />
<TreeBrowser owner={owner} repo={repoName} ref={branch} path={path} />
</>
)}
</div>
)
}
function GettingStarted({ owner, repoName, branch, cloneUrl }: {
owner: string; repoName: string; branch: string; cloneUrl: string
}) {
return (
<div className="border border-[#DFE1E6] rounded-lg overflow-hidden">
<div className="px-5 py-4 bg-[#FAFBFC] border-b border-[#DFE1E6]">
<h2 className="text-sm font-semibold text-[#172B4D]">Getting started</h2>
<p className="text-xs text-[#5E6C84] mt-0.5">
This repository is empty. Push your first commit to get started.
</p>
</div>
<div className="px-5 py-5 space-y-6 text-sm">
{/* Quick setup */}
<div>
<p className="text-xs font-semibold text-[#5E6C84] uppercase tracking-wide mb-2">
Quick setup clone over HTTP
</p>
<CopyBlock value={cloneUrl} />
</div>
{/* Push an existing repo */}
<div>
<p className="text-xs font-semibold text-[#5E6C84] uppercase tracking-wide mb-2">
or push an existing repository
</p>
<CopyBlock value={`git remote add origin ${cloneUrl}
git branch -M ${branch}
git push -u origin ${branch}`} multiline />
</div>
{/* Create new */}
<div>
<p className="text-xs font-semibold text-[#5E6C84] uppercase tracking-wide mb-2">
or create a new repository on the command line
</p>
<CopyBlock value={`echo "# ${repoName}" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M ${branch}
git remote add origin ${cloneUrl}
git push -u origin ${branch}`} multiline />
</div>
</div>
</div>
)
}
function CopyBlock({ value, multiline }: { value: string; multiline?: boolean }) {
const copy = () => navigator.clipboard.writeText(value).catch(() => {})
return (
<div className="relative group">
<pre className={`font-mono text-xs bg-[#F4F5F7] border border-[#DFE1E6] rounded px-4 py-3 overflow-x-auto text-[#172B4D] ${multiline ? 'whitespace-pre' : 'whitespace-nowrap'}`}>
{value}
</pre>
<button
onClick={copy}
className="absolute top-2 right-2 px-2 py-1 rounded text-[10px] font-medium bg-white border border-[#DFE1E6] text-[#5E6C84] hover:text-[#172B4D] opacity-0 group-hover:opacity-100 transition-opacity"
>
Copy
</button>
</div>
)
}