diff --git a/backend/server/dist/index.js b/backend/server/dist/index.js index cec8a3d..47a8e4a 100644 --- a/backend/server/dist/index.js +++ b/backend/server/dist/index.js @@ -157,6 +157,7 @@ io.on("connection", (socket) => __awaiter(void 0, void 0, void 0, function* () { }); }); const onExit = pty.onExit((code) => console.log("exit :(", code)); + pty.write("clear\r"); terminals[id] = { terminal: pty, onData, diff --git a/backend/server/src/index.ts b/backend/server/src/index.ts index 030d18e..af95922 100644 --- a/backend/server/src/index.ts +++ b/backend/server/src/index.ts @@ -187,6 +187,8 @@ io.on("connection", async (socket) => { const onExit = pty.onExit((code) => console.log("exit :(", code)) + pty.write("clear\r") + terminals[id] = { terminal: pty, onData, diff --git a/frontend/components/dashboard/newProject.tsx b/frontend/components/dashboard/newProject.tsx index cbac721..d0b8cf7 100644 --- a/frontend/components/dashboard/newProject.tsx +++ b/frontend/components/dashboard/newProject.tsx @@ -14,7 +14,6 @@ import { set, z } from "zod" import { zodResolver } from "@hookform/resolvers/zod" import { useForm } from "react-hook-form" -import CustomButton from "@/components/ui/customButton" import { Form, FormControl, @@ -36,6 +35,7 @@ import { useUser } from "@clerk/nextjs" import { createSandbox } from "@/lib/actions" import { useRouter } from "next/navigation" import { Loader2 } from "lucide-react" +import { Button } from "../ui/button" type TOptions = "react" | "node" @@ -160,7 +160,7 @@ export default function NewProjectModal({ )} /> - + diff --git a/frontend/components/editor/navbar/edit.tsx b/frontend/components/editor/navbar/edit.tsx new file mode 100644 index 0000000..4d4c3bb --- /dev/null +++ b/frontend/components/editor/navbar/edit.tsx @@ -0,0 +1,130 @@ +"use client" + +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog" +import { z } from "zod" +import { zodResolver } from "@hookform/resolvers/zod" +import { useForm } from "react-hook-form" + +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form" +import { Input } from "@/components/ui/input" +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select" +import { Loader2 } from "lucide-react" +import { useState } from "react" +import { Sandbox } from "@/lib/types" +import { Button } from "@/components/ui/button" + +const formSchema = z.object({ + name: z.string().min(1).max(16), + visibility: z.enum(["public", "private"]), +}) + +export default function EditSandboxModal({ + open, + setOpen, + data, +}: { + open: boolean + setOpen: (open: boolean) => void + data: Sandbox +}) { + const [loading, setLoading] = useState(false) + + const form = useForm>({ + resolver: zodResolver(formSchema), + defaultValues: { + name: data.name, + visibility: data.visibility, + }, + }) + + async function onSubmit(values: z.infer) { + // if (!user.isSignedIn) return + // const sandboxData = { type: selected, userId: user.user.id, ...values } + // setLoading(true) + // const id = await createSandbox(sandboxData) + + console.log(values) + } + + return ( + + + + Edit Sandbox Info + + +
+ + ( + + Name + + + + + + )} + /> + ( + + Visibility + + + + )} + /> + + + +
+
+ ) +} diff --git a/frontend/components/editor/navbar/index.tsx b/frontend/components/editor/navbar/index.tsx index 11363d3..7dff4f2 100644 --- a/frontend/components/editor/navbar/index.tsx +++ b/frontend/components/editor/navbar/index.tsx @@ -1,9 +1,15 @@ +"use client" + import Image from "next/image" import Logo from "@/assets/logo.svg" -import { Pencil } from "lucide-react" +import { Pencil, Users } from "lucide-react" import Link from "next/link" import { Sandbox, User } from "@/lib/types" import UserButton from "@/components/ui/userButton" +import { Button } from "@/components/ui/button" +import { useState } from "react" +import EditSandboxModal from "./edit" +import ShareSandboxModal from "./share" export default function Navbar({ userData, @@ -12,23 +18,47 @@ export default function Navbar({ userData: User sandboxData: Sandbox }) { + const [isEditOpen, setIsEditOpen] = useState(false) + const [isShareOpen, setIsShareOpen] = useState(false) + return ( -
-
- - Logo - -
- {sandboxData.name} -
- + <> + + +
+
+ + Logo + +
+ {sandboxData.name} +
+
+ + +
- -
+ ) } diff --git a/frontend/components/editor/navbar/share.tsx b/frontend/components/editor/navbar/share.tsx new file mode 100644 index 0000000..e49d1b9 --- /dev/null +++ b/frontend/components/editor/navbar/share.tsx @@ -0,0 +1,127 @@ +"use client" + +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, + DialogTrigger, +} from "@/components/ui/dialog" +import { z } from "zod" +import { zodResolver } from "@hookform/resolvers/zod" +import { useForm } from "react-hook-form" + +import { + Form, + FormControl, + FormDescription, + FormField, + FormItem, + FormLabel, + FormMessage, +} from "@/components/ui/form" +import { Input } from "@/components/ui/input" +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select" +import { Loader2, UserPlus, X } from "lucide-react" +import { useState } from "react" +import { Sandbox } from "@/lib/types" +import { Button } from "@/components/ui/button" + +const formSchema = z.object({ + email: z.string().email(), +}) + +export default function ShareSandboxModal({ + open, + setOpen, + data, +}: { + open: boolean + setOpen: (open: boolean) => void + data: Sandbox +}) { + const [loading, setLoading] = useState(false) + + const form = useForm>({ + resolver: zodResolver(formSchema), + defaultValues: { + email: "", + }, + }) + + async function onSubmit(values: z.infer) { + // if (!user.isSignedIn) return + // const sandboxData = { type: selected, userId: user.user.id, ...values } + // setLoading(true) + // const id = await createSandbox(sandboxData) + + console.log(values) + } + + return ( + + +
+ + Share Sandbox + +
+ + ( + + + + + + + )} + /> + + + +
+
+
+ + Share Sandbox + +
+
+
+
+ Ishaan Dey +
+ +
+
+
+ +
+ ) +} diff --git a/frontend/components/editor/terminal/index.tsx b/frontend/components/editor/terminal/index.tsx index fffc95b..efe4b40 100644 --- a/frontend/components/editor/terminal/index.tsx +++ b/frontend/components/editor/terminal/index.tsx @@ -6,6 +6,7 @@ import "./xterm.css" import { useEffect, useRef, useState } from "react" import { Socket } from "socket.io-client" +import { Loader2 } from "lucide-react" export default function EditorTerminal({ socket }: { socket: Socket }) { const terminalRef = useRef(null) @@ -32,9 +33,8 @@ export default function EditorTerminal({ socket }: { socket: Socket }) { if (!term) return const onConnect = () => { - console.log("Connected to server", socket.connected) + // console.log("Connected to server", socket.connected) setTimeout(() => { - console.log("sending createTerminal") socket.emit("createTerminal", { id: "testId" }) }, 500) } @@ -42,7 +42,6 @@ export default function EditorTerminal({ socket }: { socket: Socket }) { const onTerminalResponse = (response: { data: string }) => { // const res = Buffer.from(response.data, "base64").toString("utf-8") const res = response.data - console.log("terminal response", res) term.write(res) } @@ -71,5 +70,17 @@ export default function EditorTerminal({ socket }: { socket: Socket }) { } }, [term, terminalRef.current]) - return
+ return ( +
+ {term === null ? ( +
+ + Connecting to terminal... +
+ ) : null} +
+ ) }