diff --git a/client/src/App.tsx b/client/src/App.tsx index f20834e..c181483 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -4,7 +4,6 @@ import ConnectPage from "./pages/ConnectPage"; import ConfigurePage from "./pages/ConfigurePage"; import SecretsPage from "./pages/SecretsPage"; import DashboardPage from "./pages/DashboardPage"; -import Jenkins from "./routes/Jenkins"; import { useRepoStore } from "./store/useRepoStore"; import { usePipelineStore } from "./store/usePipelineStore"; @@ -56,7 +55,6 @@ export default function App() { 2 Configure 3 Secrets 4 Dashboard - 5 Jenkins @@ -90,7 +88,6 @@ export default function App() { } /> - } /> diff --git a/client/src/lib/api.ts b/client/src/lib/api.ts index c93e969..f2855d9 100644 --- a/client/src/lib/api.ts +++ b/client/src/lib/api.ts @@ -1,3 +1,5 @@ +import { usePipelineStore } from "../store/usePipelineStore"; + // In dev: talk to Vite dev server proxy at /api // In prod: use the real backend URL from VITE_API_BASE (e.g. https://api.autodeploy.app) const DEFAULT_API_BASE = diff --git a/client/src/pages/DashboardPage.tsx b/client/src/pages/DashboardPage.tsx index 8e9315b..317539e 100644 --- a/client/src/pages/DashboardPage.tsx +++ b/client/src/pages/DashboardPage.tsx @@ -19,7 +19,7 @@ function formatDate(iso: string) { } export default function DashboardPage() { - const { repo } = useRepoStore(); + const { repo, branch: selectedBranch } = useRepoStore(); const { result, setResultYaml } = usePipelineStore(); const cfg = useConfigStore(); @@ -36,7 +36,8 @@ export default function DashboardPage() { }, [clear]); const repoFullName = result?.repo || repo || ""; - const branch = (result as any)?.branch || "main"; + const branchName = + (result as any)?.branch || selectedBranch || "main"; const [versions, setVersions] = useState([]); const [loadingHistory, setLoadingHistory] = useState(false); @@ -65,7 +66,7 @@ export default function DashboardPage() { try { const rows = await api.getPipelineHistory({ repoFullName, - branch, + branch: branchName, limit: 20, }); if (!cancelled) { @@ -87,11 +88,11 @@ export default function DashboardPage() { cancelled = true; }; // eslint-disable-next-line react-hooks/exhaustive-deps - }, [repoFullName, branch]); + }, [repoFullName, branchName]); async function handleRollback(version: PipelineVersion) { if (!version?.id) return; - const confirmMsg = `Rollback ${repoFullName}@${branch} to version created at ${formatDate( + const confirmMsg = `Rollback ${repoFullName}@${branchName} to version created at ${formatDate( version.created_at )}?`; if (!window.confirm(confirmMsg)) return; @@ -119,7 +120,7 @@ export default function DashboardPage() { function handleCommitClick() { const repoFullNameLocal = result?.repo || repo; const yaml = result?.generated_yaml; - const branchLocal = result?.branch || "main"; + const branchLocal = (result as any)?.branch || branchName || "main"; const environment = cfg.env || "dev"; const provider = "aws"; const path = `.github/workflows/${environment}-deploy.yml`; @@ -146,7 +147,7 @@ export default function DashboardPage() {

Pipeline Dashboard

{repoFullName ? (

- {repoFullName} @ {branch} + {repoFullName} @ {branchName}

) : (

diff --git a/client/src/routes/Jenkins.tsx b/client/src/routes/Jenkins.tsx deleted file mode 100644 index 1ffa13e..0000000 --- a/client/src/routes/Jenkins.tsx +++ /dev/null @@ -1,149 +0,0 @@ -import { useEffect, useState } from "react"; -import { BASE } from "../lib/api"; - -const SERVER_BASE = BASE.replace(/\/api$/, ""); -const MCP_URL_FALLBACK = "http://192.168.1.35/mcp-server/mcp"; -const MCP_URL_GENERAL_HINT = "Enter the MCP server URL (e.g. https:///mcp-server/mcp)"; - -export default function Jenkins() { - const [question, setQuestion] = useState(""); - const [answer, setAnswer] = useState(""); - const [error, setError] = useState(null); - const [loading, setLoading] = useState(false); - const [mcpUrl, setMcpUrl] = useState(MCP_URL_FALLBACK); - const [jenkinsToken, setJenkinsToken] = useState(""); - const [mcpUrlHint, setMcpUrlHint] = useState(MCP_URL_FALLBACK); - const [tokenHint, setTokenHint] = useState(""); - const [configError, setConfigError] = useState(null); - - useEffect(() => { - let isMounted = true; - async function loadHints() { - try { - const res = await fetch(`${SERVER_BASE}/jenkins/config`, { - credentials: "include", - }); - if (!res.ok) { - throw new Error(res.statusText); - } - const data = await res.json().catch(() => ({})); - if (!isMounted) return; - const hintUrl = data?.mcpUrlHint || MCP_URL_FALLBACK; - const hintToken = data?.tokenHint || ""; - setMcpUrlHint(hintUrl); - setTokenHint(hintToken); - setMcpUrl(hintUrl); - setJenkinsToken(hintToken); - setConfigError(null); - } catch (err: any) { - if (!isMounted) return; - setConfigError(err?.message || "Unable to load Jenkins defaults"); - } - } - - loadHints(); - return () => { - isMounted = false; - }; - }, []); - - async function handleAsk() { - if (!question.trim() || !mcpUrl.trim() || !jenkinsToken.trim()) return; - setLoading(true); - setError(null); - setAnswer(""); - try { - const res = await fetch(`${SERVER_BASE}/jenkins/ask`, { - method: "POST", - headers: { "Content-Type": "application/json" }, - credentials: "include", - body: JSON.stringify({ - question: question.trim(), - mcpUrl: mcpUrl.trim() || undefined, - token: jenkinsToken.trim() || undefined, - }), - }); - const data = await res.json().catch(() => ({})); - if (!res.ok) throw new Error((data as any)?.error || res.statusText); - setAnswer(data?.answer ?? ""); - } catch (err: any) { - setError(err?.message ?? "Request failed"); - } finally { - setLoading(false); - } - } - - return ( -

-

Jenkins

- - -