Merge branch 'refs/heads/main' into production

This commit is contained in:
James Murdza 2024-08-19 17:51:02 -07:00
commit 171a9ce3c6
3 changed files with 14 additions and 6 deletions

View File

@ -65,6 +65,7 @@ export default function Navbar({
<RunButtonModal <RunButtonModal
isRunning={isRunning} isRunning={isRunning}
setIsRunning={setIsRunning} setIsRunning={setIsRunning}
sandboxData={sandboxData}
/> />
<div className="flex items-center h-full space-x-4"> <div className="flex items-center h-full space-x-4">
<Avatars /> <Avatars />

View File

@ -5,16 +5,19 @@ import { Button } from "@/components/ui/button";
import { useTerminal } from "@/context/TerminalContext"; import { useTerminal } from "@/context/TerminalContext";
import { usePreview } from "@/context/PreviewContext"; import { usePreview } from "@/context/PreviewContext";
import { toast } from "sonner"; import { toast } from "sonner";
import { Sandbox } from "@/lib/types";
export default function RunButtonModal({ export default function RunButtonModal({
isRunning, isRunning,
setIsRunning, setIsRunning,
sandboxData,
}: { }: {
isRunning: boolean; isRunning: boolean;
setIsRunning: (running: boolean) => void; setIsRunning: (running: boolean) => void;
sandboxData: Sandbox;
}) { }) {
const { createNewTerminal, terminals, closeTerminal } = useTerminal(); const { createNewTerminal, terminals, closeTerminal } = useTerminal();
const { setIsPreviewCollapsed, previewPanelRef} = usePreview(); const { setIsPreviewCollapsed, previewPanelRef } = usePreview();
const handleRun = () => { const handleRun = () => {
if (isRunning) { if (isRunning) {
@ -36,12 +39,16 @@ export default function RunButtonModal({
console.log('Opening Preview Window'); console.log('Opening Preview Window');
if (terminals.length < 4) { if (terminals.length < 4) {
if (sandboxData.type === "streamlit") {
createNewTerminal(
"pip install -r requirements.txt && streamlit run main.py --server.runOnSave true"
);
} else {
createNewTerminal("yarn install && yarn start"); createNewTerminal("yarn install && yarn start");
// For testing: }
//createNewTerminal("echo http://localhost:3000");
} else { } else {
toast.error("You reached the maximum # of terminals."); toast.error("You reached the maximum # of terminals.");
console.error('Maximum number of terminals reached.'); console.error("Maximum number of terminals reached.");
} }
setIsPreviewCollapsed(false); setIsPreviewCollapsed(false);

View File

@ -12,7 +12,7 @@ export type User = {
export type Sandbox = { export type Sandbox = {
id: string; id: string;
name: string; name: string;
type: "react" | "node"; type: string;
visibility: "public" | "private"; visibility: "public" | "private";
createdAt: Date; createdAt: Date;
userId: string; userId: string;