Skip to content

Commit

Permalink
fix: fork browser sandbox if multiple can be created (codesandbox#8537)
Browse files Browse the repository at this point in the history
* fix: fork browser sandbox if multiple can be created

* fix: choose id depending on what's given
  • Loading branch information
CompuIves authored Aug 7, 2024
1 parent 34368f5 commit f8aa866
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/app/src/app/components/Create/CreateBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,14 @@ export const CreateBox: React.FC<CreateBoxProps> = ({

const createFromTemplate = (
sandbox: SandboxToFork,
{ name, createAs, permission, editor, customVMTier }: CreateParams
{
name,
createAs,
permission,
editor,
customVMTier,
sandboxId,
}: CreateParams
) => {
const openInVSCode = editor === 'vscode';

Expand All @@ -177,7 +184,7 @@ export const CreateBox: React.FC<CreateBoxProps> = ({

actions.editor
.forkExternalSandbox({
sandboxId: sandbox.id,
sandboxId,
openInNewWindow: false,
openInVSCode,
autoLaunchVSCode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ export const CreateBoxForm: React.FC<CreateBoxFormProps> = ({
e.preventDefault();

onSubmit({
sandboxId:
runtime === 'browser'
? template.browserSandboxId ?? template.id
: template.id,
name,
createAs: runtime === 'browser' ? 'sandbox' : 'devbox',
permission,
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/app/components/Create/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { GetGithubRepoQuery } from 'app/graphql/types';
import { TemplateType } from '@codesandbox/common/lib/templates';

export type CreateParams = {
sandboxId: string;
name?: string;
createAs: 'devbox' | 'sandbox';
permission: 0 | 1 | 2;
Expand Down

0 comments on commit f8aa866

Please sign in to comment.