From 7559e9804fcae10a2220c847f2c9db5fb8e14a0d Mon Sep 17 00:00:00 2001 From: Akhilesh Rangani Date: Mon, 19 Aug 2024 20:39:04 -0400 Subject: [PATCH] feat: different run commands based on file types --- frontend/components/editor/navbar/index.tsx | 1 + frontend/components/editor/navbar/run.tsx | 17 ++++++++++++----- frontend/lib/types.ts | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/frontend/components/editor/navbar/index.tsx b/frontend/components/editor/navbar/index.tsx index c9572b7..0408f1a 100644 --- a/frontend/components/editor/navbar/index.tsx +++ b/frontend/components/editor/navbar/index.tsx @@ -65,6 +65,7 @@ export default function Navbar({
diff --git a/frontend/components/editor/navbar/run.tsx b/frontend/components/editor/navbar/run.tsx index d206a65..c69c66f 100644 --- a/frontend/components/editor/navbar/run.tsx +++ b/frontend/components/editor/navbar/run.tsx @@ -5,16 +5,19 @@ import { Button } from "@/components/ui/button"; import { useTerminal } from "@/context/TerminalContext"; import { usePreview } from "@/context/PreviewContext"; import { toast } from "sonner"; +import { Sandbox } from "@/lib/types"; export default function RunButtonModal({ isRunning, setIsRunning, + sandboxData, }: { isRunning: boolean; setIsRunning: (running: boolean) => void; + sandboxData: Sandbox; }) { const { createNewTerminal, terminals, closeTerminal } = useTerminal(); - const { setIsPreviewCollapsed, previewPanelRef} = usePreview(); + const { setIsPreviewCollapsed, previewPanelRef } = usePreview(); const handleRun = () => { if (isRunning) { @@ -36,12 +39,16 @@ export default function RunButtonModal({ console.log('Opening Preview Window'); if (terminals.length < 4) { - createNewTerminal("yarn install && yarn start"); - // For testing: - //createNewTerminal("echo http://localhost:3000"); + if (sandboxData.type === "streamlit") { + createNewTerminal( + "pip install -r requirements.txt && streamlit run main.py --server.runOnSave true" + ); + } else { + createNewTerminal("yarn install && yarn start"); + } } else { toast.error("You reached the maximum # of terminals."); - console.error('Maximum number of terminals reached.'); + console.error("Maximum number of terminals reached."); } setIsPreviewCollapsed(false); diff --git a/frontend/lib/types.ts b/frontend/lib/types.ts index 78e1ee9..c6d144b 100644 --- a/frontend/lib/types.ts +++ b/frontend/lib/types.ts @@ -12,7 +12,7 @@ export type User = { export type Sandbox = { id: string; name: string; - type: "react" | "node"; + type: string; visibility: "public" | "private"; createdAt: Date; userId: string;