Skip to content

Commit d1e68eb

Browse files
committed
Fix forking container from the templatelist
1 parent 41d9803 commit d1e68eb

File tree

1 file changed

+7
-2
lines changed
  • packages/app/src/app/components/CreateNewSandbox/CreateSandbox/TemplateList

1 file changed

+7
-2
lines changed

packages/app/src/app/components/CreateNewSandbox/CreateSandbox/TemplateList/TemplateList.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { TemplateFragment } from 'app/graphql/types';
33
import { sandboxUrl } from '@codesandbox/common/lib/utils/url-generator';
4+
import getTemplateDefinition from '@codesandbox/common/lib/templates';
45
import { useOvermind } from 'app/overmind';
56
import { useKey } from 'react-use';
67
import { isMac } from '@codesandbox/common/lib/utils/platform';
@@ -43,15 +44,19 @@ export const TemplateList = ({
4344
showSecondaryShortcuts,
4445
columnCount = 2,
4546
}: ITemplateListProps) => {
46-
const { actions } = useOvermind();
47+
const { actions, state } = useOvermind();
4748
const [focusedTemplateIndex, setFocusedTemplate] = React.useState(0);
4849
const lastMouseMoveEventAt = React.useRef<number>(Date.now());
4950

5051
const openSandbox = (
5152
sandbox: TemplateFragment['sandbox'],
5253
openInNewWindow = false
5354
) => {
54-
if (forkOnOpen) {
55+
// We can't fork a sandbox that's server and if you're signed in, so then we just go to it
56+
const templateDefinition = getTemplateDefinition(sandbox.source.template);
57+
const cannotFork = templateDefinition.isServer && !state.isLoggedIn;
58+
59+
if (forkOnOpen && !cannotFork) {
5560
actions.editor.forkExternalSandbox({
5661
sandboxId: sandbox.id,
5762
openInNewWindow,

0 commit comments

Comments
 (0)