Git Repository link always shows, defaulting to the canonical upstream repo
Previously hidden entirely when NEXT_PUBLIC_GIT_REPO_URL was unset, which meant it never appeared on localhost or on anyone else's clone that hadn't explicitly configured it. It should always point somewhere - the canonical repo (git.ciagent.org) is the sensible default everywhere, overridable only by a deployment that runs its own separate git server. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
+14
-10
@@ -5,6 +5,12 @@ import { Building2, LineChart, Mail, Radar, ShieldCheck, Sparkles } from "lucide
|
||||
import { useSystemStatus } from "@/hooks/use-auth";
|
||||
import { isLocalConvenience } from "@/lib/auth";
|
||||
|
||||
// The canonical, authoritative repo - shown by default on every deployment
|
||||
// (including someone else's clone running on their own machine) unless
|
||||
// NEXT_PUBLIC_GIT_REPO_URL overrides it, e.g. because that clone runs its
|
||||
// own self-hosted git server instead of pointing back at this one.
|
||||
const CANONICAL_GIT_REPO_URL = "https://git.ciagent.org/saksham/CIAgent";
|
||||
|
||||
const steps = [
|
||||
{
|
||||
title: "Add a company",
|
||||
@@ -48,16 +54,14 @@ export default function LandingPage() {
|
||||
<div className="mx-auto flex max-w-6xl items-center justify-between px-6 py-4">
|
||||
<span className="text-lg font-semibold tracking-tight text-slate-900">CI Agent</span>
|
||||
<nav className="flex items-center gap-3">
|
||||
{process.env.NEXT_PUBLIC_GIT_REPO_URL && (
|
||||
<a
|
||||
href={process.env.NEXT_PUBLIC_GIT_REPO_URL}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="rounded-md px-3 py-2 text-sm font-medium text-slate-700 hover:bg-slate-100"
|
||||
>
|
||||
Git Repository
|
||||
</a>
|
||||
)}
|
||||
<a
|
||||
href={process.env.NEXT_PUBLIC_GIT_REPO_URL || CANONICAL_GIT_REPO_URL}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="rounded-md px-3 py-2 text-sm font-medium text-slate-700 hover:bg-slate-100"
|
||||
>
|
||||
Git Repository
|
||||
</a>
|
||||
<Link
|
||||
href="/login"
|
||||
className="rounded-md px-3 py-2 text-sm font-medium text-slate-700 hover:bg-slate-100"
|
||||
|
||||
@@ -68,17 +68,21 @@ describe("LandingPage", () => {
|
||||
expect(screen.queryByText(/local mode/i)).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("hides the Git Repository link when no NEXT_PUBLIC_GIT_REPO_URL is configured", () => {
|
||||
renderWithQueryClient(<LandingPage />);
|
||||
expect(screen.queryByRole("link", { name: /git repository/i })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows a Git Repository link opening in a new tab when configured", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_GIT_REPO_URL", "https://git.ciagent.org/admin/ci-agent");
|
||||
it("falls back to the canonical upstream repo when NEXT_PUBLIC_GIT_REPO_URL is unset", () => {
|
||||
renderWithQueryClient(<LandingPage />);
|
||||
|
||||
const link = screen.getByRole("link", { name: /git repository/i });
|
||||
expect(link).toHaveAttribute("href", "https://git.ciagent.org/admin/ci-agent");
|
||||
expect(link).toHaveAttribute("href", "https://git.ciagent.org/saksham/CIAgent");
|
||||
expect(link).toHaveAttribute("target", "_blank");
|
||||
expect(link).toHaveAttribute("rel", "noopener noreferrer");
|
||||
});
|
||||
|
||||
it("points the Git Repository link at a custom fork when configured", () => {
|
||||
vi.stubEnv("NEXT_PUBLIC_GIT_REPO_URL", "https://git.example.com/someone/ci-agent");
|
||||
renderWithQueryClient(<LandingPage />);
|
||||
|
||||
const link = screen.getByRole("link", { name: /git repository/i });
|
||||
expect(link).toHaveAttribute("href", "https://git.example.com/someone/ci-agent");
|
||||
expect(link).toHaveAttribute("target", "_blank");
|
||||
expect(link).toHaveAttribute("rel", "noopener noreferrer");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user