Skip to content

Commit 64d7a86

Browse files
committed
fix: set localStorage for IncompatibleWorkspace story to display error view
1 parent 012e3c1 commit 64d7a86

File tree

1 file changed

+62
-40
lines changed

1 file changed

+62
-40
lines changed

src/browser/App.stories.tsx

Lines changed: 62 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -386,49 +386,71 @@ export const ManyWorkspaces: Story = {
386386
*/
387387
export const IncompatibleWorkspace: Story = {
388388
render: () => {
389-
const workspaceId = "incompatible-ws";
389+
const AppWithIncompatibleWorkspace = () => {
390+
const initialized = useRef(false);
390391

391-
const projects = new Map<string, ProjectConfig>([
392-
[
393-
"/home/user/projects/my-app",
394-
{
395-
workspaces: [
396-
{ path: "/home/user/.mux/src/my-app/main", id: "my-app-main", name: "main" },
397-
{
398-
path: "/home/user/.mux/src/my-app/incompatible",
399-
id: workspaceId,
400-
name: "incompatible",
401-
},
402-
],
403-
},
404-
],
405-
]);
392+
if (!initialized.current) {
393+
const workspaceId = "incompatible-ws";
406394

407-
const workspaces: FrontendWorkspaceMetadata[] = [
408-
{
409-
id: "my-app-main",
410-
name: "main",
411-
projectPath: "/home/user/projects/my-app",
412-
projectName: "my-app",
413-
namedWorkspacePath: "/home/user/.mux/src/my-app/main",
414-
runtimeConfig: DEFAULT_RUNTIME_CONFIG,
415-
},
416-
{
417-
id: workspaceId,
418-
name: "incompatible",
419-
projectPath: "/home/user/projects/my-app",
420-
projectName: "my-app",
421-
namedWorkspacePath: "/home/user/.mux/src/my-app/incompatible",
422-
runtimeConfig: DEFAULT_RUNTIME_CONFIG,
423-
// This field is set when a workspace has an incompatible runtime config
424-
incompatibleRuntime:
425-
"This workspace was created with a newer version of mux.\nPlease upgrade mux to use this workspace.",
426-
},
427-
];
395+
const workspaces: FrontendWorkspaceMetadata[] = [
396+
{
397+
id: "my-app-main",
398+
name: "main",
399+
projectPath: "/home/user/projects/my-app",
400+
projectName: "my-app",
401+
namedWorkspacePath: "/home/user/.mux/src/my-app/main",
402+
runtimeConfig: DEFAULT_RUNTIME_CONFIG,
403+
},
404+
{
405+
id: workspaceId,
406+
name: "incompatible",
407+
projectPath: "/home/user/projects/my-app",
408+
projectName: "my-app",
409+
namedWorkspacePath: "/home/user/.mux/src/my-app/incompatible",
410+
runtimeConfig: DEFAULT_RUNTIME_CONFIG,
411+
// This field is set when a workspace has an incompatible runtime config
412+
incompatibleRuntime:
413+
"This workspace was created with a newer version of mux.\nPlease upgrade mux to use this workspace.",
414+
},
415+
];
416+
417+
setupMockAPI({
418+
projects: new Map([
419+
[
420+
"/home/user/projects/my-app",
421+
{
422+
workspaces: [
423+
{ path: "/home/user/.mux/src/my-app/main", id: "my-app-main", name: "main" },
424+
{
425+
path: "/home/user/.mux/src/my-app/incompatible",
426+
id: workspaceId,
427+
name: "incompatible",
428+
},
429+
],
430+
},
431+
],
432+
]),
433+
workspaces,
434+
});
435+
436+
// Set initial workspace selection to the incompatible workspace
437+
localStorage.setItem(
438+
"selectedWorkspace",
439+
JSON.stringify({
440+
workspaceId: workspaceId,
441+
projectPath: "/home/user/projects/my-app",
442+
projectName: "my-app",
443+
namedWorkspacePath: "/home/user/.mux/src/my-app/incompatible",
444+
})
445+
);
446+
447+
initialized.current = true;
448+
}
449+
450+
return <AppLoader />;
451+
};
428452

429-
return (
430-
<AppWithMocks projects={projects} workspaces={workspaces} selectedWorkspaceId={workspaceId} />
431-
);
453+
return <AppWithIncompatibleWorkspace />;
432454
},
433455
};
434456

0 commit comments

Comments
 (0)