fix(codebase): remove legacy single-codebase hint description from api endpoints
This commit is contained in:
@@ -48,22 +48,48 @@ export default function CodeTab() {
|
||||
const showLoading = loading && !anatomy;
|
||||
|
||||
return (
|
||||
<div style={{ minHeight: "100vh", background: THEME.canvasGradient, fontFamily: THEME.font, padding: "36px 48px" }}>
|
||||
<div
|
||||
style={{
|
||||
minHeight: "100vh",
|
||||
background: THEME.canvasGradient,
|
||||
fontFamily: THEME.font,
|
||||
padding: "36px 48px",
|
||||
}}
|
||||
>
|
||||
<div style={{ maxWidth: 1400, margin: "0 auto" }}>
|
||||
<PageHeader title="Codebase" subtitle="Explore the repository files for your application." />
|
||||
<PageHeader
|
||||
title="Codebase"
|
||||
subtitle="Explore the repository files for your application."
|
||||
/>
|
||||
<div style={grid}>
|
||||
{/* ── Left rail ── */}
|
||||
<section style={leftCol}>
|
||||
{showLoading && (
|
||||
<Card>
|
||||
<div style={{ display: "flex", alignItems: "center", gap: 8, color: THEME.mid, fontSize: "0.875rem" }}>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
gap: 8,
|
||||
color: THEME.mid,
|
||||
fontSize: "0.875rem",
|
||||
}}
|
||||
>
|
||||
<Loader2 size={15} className="animate-spin" /> Loading…
|
||||
</div>
|
||||
</Card>
|
||||
)}
|
||||
{error && !showLoading && (
|
||||
<Card>
|
||||
<div style={{ display: "flex", alignItems: "center", gap: 8, color: THEME.danger, fontSize: "0.875rem" }}>
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
gap: 8,
|
||||
color: THEME.danger,
|
||||
fontSize: "0.875rem",
|
||||
}}
|
||||
>
|
||||
<AlertCircle size={15} /> {error}
|
||||
</div>
|
||||
</Card>
|
||||
@@ -97,7 +123,10 @@ export default function CodeTab() {
|
||||
<article key={cb.id} style={codebaseTile}>
|
||||
<div style={tileHeader}>
|
||||
<span style={chevronCell}>
|
||||
<ChevronDown size={13} style={{ color: THEME.mid }} />
|
||||
<ChevronDown
|
||||
size={13}
|
||||
style={{ color: THEME.mid }}
|
||||
/>
|
||||
</span>
|
||||
<Box
|
||||
size={13}
|
||||
@@ -150,7 +179,18 @@ export default function CodeTab() {
|
||||
<GiteaFileViewer projectId={projectId} path={selection.path} />
|
||||
)}
|
||||
{!selection && (
|
||||
<div style={{ flex: 1, display: "flex", alignItems: "center", justifyContent: "center", color: THEME.muted, fontSize: "0.85rem", padding: "32px 16px", textAlign: "center" }}>
|
||||
<div
|
||||
style={{
|
||||
flex: 1,
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
color: THEME.muted,
|
||||
fontSize: "0.85rem",
|
||||
padding: "32px 16px",
|
||||
textAlign: "center",
|
||||
}}
|
||||
>
|
||||
Pick a codebase file on the left.
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -254,7 +254,7 @@ async function discoverCodebases(giteaRepo: string): Promise<{
|
||||
id: "root",
|
||||
label: repoName,
|
||||
path: "",
|
||||
hint: "Single-codebase project — repository root.",
|
||||
hint: "",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -35,14 +35,17 @@ interface GiteaItem {
|
||||
type: "file" | "dir" | "symlink";
|
||||
}
|
||||
|
||||
async function giteaList(repo: string, path: string): Promise<GiteaItem[] | null> {
|
||||
async function giteaList(
|
||||
repo: string,
|
||||
path: string,
|
||||
): Promise<GiteaItem[] | null> {
|
||||
const encoded = path ? encodeURIComponent(path).replace(/%2F/g, "/") : "";
|
||||
const res = await fetch(
|
||||
`${GITEA_API_URL}/api/v1/repos/${repo}/contents/${encoded}`,
|
||||
{
|
||||
headers: { Authorization: `token ${GITEA_API_TOKEN}` },
|
||||
next: { revalidate: 30 },
|
||||
}
|
||||
},
|
||||
);
|
||||
if (res.status === 404) return null;
|
||||
if (!res.ok) throw new Error(`Gitea ${res.status} listing ${repo}/${path}`);
|
||||
@@ -52,7 +55,7 @@ async function giteaList(repo: string, path: string): Promise<GiteaItem[] | null
|
||||
|
||||
export async function GET(
|
||||
_req: Request,
|
||||
{ params }: { params: Promise<{ projectId: string }> }
|
||||
{ params }: { params: Promise<{ projectId: string }> },
|
||||
) {
|
||||
try {
|
||||
const { projectId } = await params;
|
||||
@@ -65,7 +68,7 @@ export async function GET(
|
||||
`SELECT p.data FROM fs_projects p
|
||||
JOIN fs_users u ON u.id = p.user_id
|
||||
WHERE p.id = $1 AND u.data->>'email' = $2 LIMIT 1`,
|
||||
[projectId, session.user.email]
|
||||
[projectId, session.user.email],
|
||||
);
|
||||
if (rows.length === 0) {
|
||||
return NextResponse.json({ error: "Project not found" }, { status: 404 });
|
||||
@@ -89,15 +92,17 @@ export async function GET(
|
||||
});
|
||||
}
|
||||
|
||||
const appsDir = root.find(item => item.type === "dir" && item.name === "apps");
|
||||
const appsDir = root.find(
|
||||
(item) => item.type === "dir" && item.name === "apps",
|
||||
);
|
||||
let codebases: Codebase[] = [];
|
||||
|
||||
if (appsDir) {
|
||||
const appsChildren = await giteaList(giteaRepo, "apps");
|
||||
if (appsChildren) {
|
||||
codebases = appsChildren
|
||||
.filter(item => item.type === "dir")
|
||||
.map(item => ({
|
||||
.filter((item) => item.type === "dir")
|
||||
.map((item) => ({
|
||||
id: item.name,
|
||||
label: item.name,
|
||||
path: `apps/${item.name}`,
|
||||
@@ -114,7 +119,7 @@ export async function GET(
|
||||
id: "root",
|
||||
label: repoName,
|
||||
path: "",
|
||||
hint: "Single-codebase project — repository root.",
|
||||
hint: "",
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -122,6 +127,9 @@ export async function GET(
|
||||
return NextResponse.json({ codebases });
|
||||
} catch (err) {
|
||||
console.error("[codebases API]", err);
|
||||
return NextResponse.json({ error: "Failed to list codebases" }, { status: 500 });
|
||||
return NextResponse.json(
|
||||
{ error: "Failed to list codebases" },
|
||||
{ status: 500 },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user