Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions frontend/src/pages/Analyze.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export default function App() {
const [focusMode, setFocusMode] = useState(true);
const [depth, setDepth] = useState(2);
const [loading, setLoading] = useState(false);
const [repoUrl, setRepoUrl] = useState<string>("");

const API = import.meta.env.DEV
? "http://localhost:8080"
: "https://codeatlas-production-e4f8.up.railway.app";
Expand All @@ -28,7 +30,17 @@ export default function App() {
setCopied(true);
setTimeout(() => setCopied(false), 1500);
}, [selectedFile]);

const handleOpenInGitHub = useCallback((): void => {
if (!selectedFile || !repoUrl) return;

const cleanRepoUrl = repoUrl.replace(/\.git$/, "");
const branch = "main";

const url = `${cleanRepoUrl}/blob/${branch}/${selectedFile}`;

window.open(url, "_blank");
}, [selectedFile, repoUrl]);

const displayData = useMemo(() => {
if (!graphData) return null;
Expand Down Expand Up @@ -77,6 +89,7 @@ export default function App() {
})),
backLinks: graph.backLinks || {},
});
setRepoUrl(url);
} catch (err) {
console.error("Analyze error:", err);
setGraphData(null);
Expand Down Expand Up @@ -104,6 +117,7 @@ export default function App() {
return "plaintext";
};


return (
<>

Expand Down Expand Up @@ -187,7 +201,17 @@ export default function App() {
>
{copied ? "✓" : "Copy"}
</button>
<div className="ca-copy"> | </div>
<button
onClick={handleOpenInGitHub}
className="ca-copy"
title="Open in GitHub"
disabled={!selectedFile}
>
GitHub
</button>
</div>


<div className="ca-label">Imports</div>
<ul className="ca-list">
Expand Down
Loading