-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat: add restart sandbox button to toolbar #2843
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
34bfd35
804a1ea
a3f45d2
fa834eb
0025f42
da4ab4d
f897610
4cb140a
ab76b25
45456c8
5d7cc0e
ccf112f
cb0293e
eaaa718
ebc7297
dcfada1
367678f
1638260
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,5 +1,6 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { useEditorEngine } from '@/components/store/editor'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Icons } from '@onlook/ui/icons'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { toast } from '@onlook/ui/sonner'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Tabs, TabsContent, TabsList, TabsTrigger } from '@onlook/ui/tabs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Tooltip, TooltipContent, TooltipTrigger } from '@onlook/ui/tooltip'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { cn } from '@onlook/ui/utils'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -53,6 +54,38 @@ export const TerminalArea = observer(({ children }: { children: React.ReactNode | |||||||||||||||||||||||||||||||||||||||||||||||||||
| {terminalHidden ? ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <motion.div layout className="flex items-center gap-1"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| {children} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Tooltip> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <TooltipTrigger asChild> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| onClick={async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const activeBranch = branches.activeBranch; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (activeBranch) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const sandbox = branches.getSandboxById(activeBranch.id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (sandbox?.session) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const success = await sandbox.session.restartDevServer(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (success) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| toast.success('Sandbox restarted successfully', { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| icon: <Icons.Cube className="h-4 w-4" />, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| toast.error('Failed to restart sandbox'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| disabled={!branches.activeBranch} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| className={cn( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "h-9 w-9 flex items-center justify-center rounded-md border border-transparent", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| branches.activeBranch | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? "hover:text-foreground-hover text-foreground-tertiary hover:bg-accent/50" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| : "text-foreground-disabled cursor-not-allowed opacity-50" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| )} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Icons.Reload className="h-4 w-4" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| </button> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| </TooltipTrigger> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <TooltipContent sideOffset={5} hideArrow>Restart Sandbox</TooltipContent> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Tooltip> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Tooltip> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <TooltipTrigger asChild> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -81,6 +114,31 @@ export const TerminalArea = observer(({ children }: { children: React.ReactNode | |||||||||||||||||||||||||||||||||||||||||||||||||||
| </motion.span> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex items-center gap-1"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <motion.div layout>{/* <RunButton /> */}</motion.div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Tooltip> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <TooltipTrigger asChild> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <button | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| onClick={async () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const activeBranch = branches.activeBranch; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (activeBranch) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| const sandbox = branches.getSandboxById(activeBranch.id); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (sandbox?.session) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| await sandbox.session.restartDevServer(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| onClick={async () => { | |
| const activeBranch = branches.activeBranch; | |
| if (activeBranch) { | |
| const sandbox = branches.getSandboxById(activeBranch.id); | |
| if (sandbox?.session) { | |
| await sandbox.session.restartDevServer(); | |
| } | |
| } | |
| }} | |
| onClick={async () => { | |
| const activeBranch = branches.activeBranch; | |
| if (activeBranch) { | |
| const sandbox = branches.getSandboxById(activeBranch.id); | |
| if (sandbox?.session) { | |
| const success = await sandbox.session.restartDevServer(); | |
| if (success) { | |
| toast.success('Sandbox restarted successfully', { | |
| icon: <Icons.Cube className="h-4 w-4" />, | |
| }); | |
| } else { | |
| toast.error('Failed to restart sandbox'); | |
| } | |
| } | |
| } | |
| }} |
Spotted by Diamond
Is this helpful? React 👍 or 👎 to let us know.
Uh oh!
There was an error while loading. Please reload this page.