Added Jira ticket modal
Browse filesX-Lovable-Edit-ID: edt-f387cdaa-5d77-45fb-a79f-7eb69634e5e4
901 unmodified lines90290390490590690790890960 unmodified lines97097197297397497597697797897998098198298398498598698798898999025 unmodified lines101610171018101910201021102210231 unmodified line1025102610271028102910301031103213 unmodified lines104610471048104910501051105210531054105510561057901 unmodified lines);}function ExportButtons({ result, mode }: { result: DebugResult; mode: "diff" | "snippet" | "unknown" }) {const stamp = new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19);const download = (filename: string, content: string, mime: string) => {const blob = new Blob([content], { type: mime });60 unmodified linesdownload(`branchdebug-report-${stamp}.md`, lines.join("\n"), "text/markdown");};const createJiraTicket = async () => {const stored = typeof window !== "undefined" ? localStorage.getItem("branchdebug.jiraBaseUrl") : "";let base = stored || "";if (!base) {const input = window.prompt("Enter your Jira base URL (e.g. https://acme.atlassian.net):", "https://your-domain.atlassian.net");if (!input) return;base = input.replace(/\/$/, "");localStorage.setItem("branchdebug.jiraBaseUrl", base);}const top = result.suspects[0];const summary = top? `BranchDebug: ${top.changeSummary} (${top.filePath})`: `BranchDebug: ${(result.summary || "Root-cause report").slice(0, 80)}`;const body: string[] = [];body.push(`*Mode:* ${mode === "snippet" ? "Code snippet" : mode === "diff" ? "Git diff" : "Unknown"}`);body.push(`*Generated:* ${new Date().toLocaleString()}`);25 unmodified linesbody.push("");});}const description = body.join("\n");try {await navigator.clipboard.writeText(description);toast.success("Ticket description copied — paste into Jira");1 unmodified linetoast.message("Could not copy automatically — paste manually in Jira");}const url = `${base}/secure/CreateIssue!default.jspa?summary=${encodeURIComponent(summary)}`;window.open(url, "_blank", "noopener,noreferrer");};return (13 unmodified lines<FileJson className="h-3 w-3" /> .json</button><buttononClick={createJiraTicket}className="h-7 px-2 rounded-md border border-[#2684ff]/40 bg-[#2684ff]/10 hover:bg-[#2684ff]/20 hover:border-[#2684ff] text-[#2684ff] text-[10px] font-mono uppercase tracking-widest flex items-center gap-1"title="Create Jira ticket with sanitization stats and ranked suspects"><Ticket className="h-3 w-3" /> Jira</button></div>);}901 unmodified lines90290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193260 unmodified lines99399499599699799899925 unmodified lines102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471 unmodified line10491050105110521053105410551056105710581059106010611062106313 unmodified lines107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142901 unmodified lines);}type JiraConfig = {baseUrl: string;projectKey: string;assignee: string;labels: string;components: string;};const JIRA_CONFIG_KEY = "branchdebug.jiraConfig";function loadJiraConfig(): JiraConfig {if (typeof window === "undefined") return { baseUrl: "", projectKey: "", assignee: "", labels: "", components: "" };try {const raw = localStorage.getItem(JIRA_CONFIG_KEY);if (raw) return { baseUrl: "", projectKey: "", assignee: "", labels: "", components: "", ...JSON.parse(raw) };} catch {}// migrate old keyconst oldBase = localStorage.getItem("branchdebug.jiraBaseUrl") || "";return { baseUrl: oldBase, projectKey: "", assignee: "", labels: "", components: "" };}function ExportButtons({ result, mode }: { result: DebugResult; mode: "diff" | "snippet" | "unknown" }) {const stamp = new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19);const [jiraOpen, setJiraOpen] = useState(false);const [jira, setJira] = useState<JiraConfig>(() => loadJiraConfig());const download = (filename: string, content: string, mime: string) => {const blob = new Blob([content], { type: mime });60 unmodified linesdownload(`branchdebug-report-${stamp}.md`, lines.join("\n"), "text/markdown");};const buildJiraDescription = () => {const body: string[] = [];body.push(`*Mode:* ${mode === "snippet" ? "Code snippet" : mode === "diff" ? "Git diff" : "Unknown"}`);body.push(`*Generated:* ${new Date().toLocaleString()}`);25 unmodified linesbody.push("");});}return body.join("\n");};const createJiraTicket = async () => {if (!jira.baseUrl) {toast.error("Jira base URL is required");return;}const base = jira.baseUrl.replace(/\/$/, "");localStorage.setItem(JIRA_CONFIG_KEY, JSON.stringify({ ...jira, baseUrl: base }));const top = result.suspects[0];const summary = top? `BranchDebug: ${top.changeSummary} (${top.filePath})`: `BranchDebug: ${(result.summary || "Root-cause report").slice(0, 80)}`;const description = buildJiraDescription();try {await navigator.clipboard.writeText(description);toast.success("Ticket description copied — paste into Jira");1 unmodified linetoast.message("Could not copy automatically — paste manually in Jira");}const params = new URLSearchParams();params.set("summary", summary);if (jira.projectKey.trim()) params.set("pid", jira.projectKey.trim());if (jira.assignee.trim()) params.set("assignee", jira.assignee.trim());jira.labels.split(",").map((l) => l.trim()).filter(Boolean).forEach((l) => params.append("labels", l));jira.components.split(",").map((c) => c.trim()).filter(Boolean).forEach((c) => params.append("components", c));window.open(`${base}/secure/CreateIssue!default.jspa?${params.toString()}`, "_blank", "noopener,noreferrer");setJiraOpen(false);};return (13 unmodified lines<FileJson className="h-3 w-3" /> .json</button><buttononClick={() => setJiraOpen(true)}className="h-7 px-2 rounded-md border border-[#2684ff]/40 bg-[#2684ff]/10 hover:bg-[#2684ff]/20 hover:border-[#2684ff] text-[#2684ff] text-[10px] font-mono uppercase tracking-widest flex items-center gap-1"title="Create Jira ticket with sanitization stats and ranked suspects"><Ticket className="h-3 w-3" /> Jira</button>{jiraOpen && (<divclassName="fixed inset-0 z-50 bg-black/70 flex items-center justify-center p-4"onClick={() => setJiraOpen(false)}><divclassName="w-full max-w-md bg-[#0d1520] border border-border rounded-lg p-5 space-y-3"onClick={(e) => e.stopPropagation()}><div className="flex items-center gap-2 text-[#2684ff]"><Ticket className="h-4 w-4" /><h3 className="text-sm font-mono uppercase tracking-widest">Create Jira ticket</h3></div><p className="text-[11px] text-muted-foreground">Optional fields are pre-applied to the new issue. Saved locally for next time.</p>{([{ key: "baseUrl", label: "Base URL *", placeholder: "https://acme.atlassian.net" },{ key: "projectKey", label: "Project key / ID", placeholder: "ENG or 10001" },{ key: "assignee", label: "Assignee (username / accountId)", placeholder: "jdoe" },{ key: "labels", label: "Labels (comma-separated)", placeholder: "bug, regression, branch-debug" },{ key: "components", label: "Components (comma-separated)", placeholder: "API, Auth" },] as const).map((f) => (<label key={f.key} className="block"><span className="text-[10px] font-mono uppercase tracking-widest text-muted-foreground">{f.label}</span><inputtype="text"value={jira[f.key]}onChange={(e) => setJira({ ...jira, [f.key]: e.target.value })}placeholder={f.placeholder}className="mt-1 w-full h-8 px-2 rounded-md bg-[#080c10] border border-border text-xs font-mono text-foreground focus:border-[#2684ff] outline-none"/></label>))}<div className="flex items-center justify-end gap-2 pt-2"><buttononClick={() => setJiraOpen(false)}className="h-8 px-3 rounded-md border border-border text-[10px] font-mono uppercase tracking-widest text-muted-foreground hover:text-foreground">Cancel</button><buttononClick={createJiraTicket}className="h-8 px-3 rounded-md bg-[#2684ff] hover:bg-[#2684ff]/90 text-white text-[10px] font-mono uppercase tracking-widest flex items-center gap-1"><ExternalLink className="h-3 w-3" /> Open in Jira</button></div></div></div>)}</div>);}
src/routes/dashboard.branch-debug.tsx+104-19