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:
+5
-3
@@ -16,9 +16,11 @@ BACKEND_URL=http://localhost:8000
|
||||
# so for LAN access this must be the host's LAN IP, not localhost (e.g.
|
||||
# http://192.168.1.190:8000). Leave unset for localhost-only access.
|
||||
NEXT_PUBLIC_API_URL=http://localhost:8000
|
||||
# "Git Repository" link on the landing page header, next to Sign in - only
|
||||
# rendered when this is set (e.g. https://git.ciagent.org/you/ci-agent).
|
||||
# Leave blank if you don't run a public git server for this deployment.
|
||||
# "Git Repository" link on the landing page header, next to Sign in.
|
||||
# Defaults to the canonical upstream repo (git.ciagent.org) when unset - the
|
||||
# button always shows, even on a clone that hasn't set this at all. Only set
|
||||
# this if you run your own self-hosted git server and want the button to
|
||||
# point at your fork instead of upstream.
|
||||
NEXT_PUBLIC_GIT_REPO_URL=
|
||||
|
||||
# --- Reverse proxy (only relevant once deployed behind Cloudflare/Nginx) -----
|
||||
|
||||
@@ -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}
|
||||
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");
|
||||
});
|
||||
|
||||
+3
-2
@@ -97,8 +97,9 @@ services:
|
||||
# (not the container) can reach, so a LAN client needs this set to
|
||||
# the host machine's LAN IP, not localhost. See .env.example.
|
||||
NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-http://localhost:8000}
|
||||
# "Git Repository" landing-page link - blank by default so it's
|
||||
# hidden unless you actually run a git server for this deployment.
|
||||
# "Git Repository" landing-page link - blank here so the frontend
|
||||
# falls back to its own hardcoded default (the canonical upstream
|
||||
# repo). Only set this to point the button at a different git server.
|
||||
NEXT_PUBLIC_GIT_REPO_URL: ${NEXT_PUBLIC_GIT_REPO_URL:-}
|
||||
ports:
|
||||
- "3000:3000"
|
||||
|
||||
Reference in New Issue
Block a user