Skip to content

Commit a5893ea

Browse files
authored
fix: redirect v2 sandbox to the v2 editor (#7058)
* fix: redirect v2 sandboxes to the v2 editor * chore: add explanatory comment
1 parent 62338a9 commit a5893ea

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

packages/app/src/app/overmind/namespaces/editor/actions.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ import { isAbsoluteVersion } from '@codesandbox/common/lib/utils/dependencies';
1717
import { getTextOperation } from '@codesandbox/common/lib/utils/diff';
1818
import { convertTypeToStatus } from '@codesandbox/common/lib/utils/notifications';
1919
import { hasPermission } from '@codesandbox/common/lib/utils/permission';
20-
import { signInPageUrl } from '@codesandbox/common/lib/utils/url-generator';
20+
import {
21+
sandboxUrl,
22+
signInPageUrl,
23+
} from '@codesandbox/common/lib/utils/url-generator';
2124
import { NotificationStatus } from '@codesandbox/notifications';
2225
import {
2326
Authorization,
@@ -301,6 +304,17 @@ export const sandboxChanged = withLoadApp<{
301304
const params = state.activeTeam ? { teamId: state.activeTeam } : undefined;
302305
const sandbox = await effects.api.getSandbox(newId, params);
303306

307+
// Failsafe, in case someone types in the URL to load a v2 sandbox in v1
308+
if (sandbox.v2) {
309+
const sandboxV2Url = sandboxUrl({
310+
id: sandbox.id,
311+
alias: sandbox.alias,
312+
isV2: true,
313+
});
314+
315+
window.location.href = sandboxV2Url;
316+
}
317+
304318
actions.internal.setCurrentSandbox(sandbox);
305319
} catch (error) {
306320
const data = error.response?.data;

packages/common/src/types/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ export type Sandbox = {
405405
alias: string | null;
406406
title: string | null;
407407
description: string;
408+
v2: boolean;
408409
viewCount: number;
409410
likeCount: number;
410411
forkCount: number;

0 commit comments

Comments
 (0)