Skip to content

Commit 84252eb

Browse files
SaerisCompuIves
authored andcommitted
🔨 Refactor More Workspace to use hooks
1 parent feba530 commit 84252eb

File tree

4 files changed

+52
-56
lines changed

4 files changed

+52
-56
lines changed

‎packages/app/src/app/pages/Sandbox/Editor/Workspace/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import ProjectInfo from './items/ProjectInfo';
1111
import { GitHub } from './items/GitHub';
1212
import Server from './items/Server';
1313
import Live from './items/Live';
14-
import More from './items/More';
14+
import { More } from './items/More';
1515
import Deployment from './items/Deployment';
1616
import ConfigurationFiles from './items/ConfigurationFiles';
1717
import NotOwnedSandboxInfo from './items/NotOwnedSandboxInfo';
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import ProgressButton from '@codesandbox/common/lib/components/ProgressButton';
2+
import Margin from '@codesandbox/common/lib/components/spacing/Margin';
3+
import track from '@codesandbox/common/lib/utils/analytics';
4+
import { observer } from 'mobx-react-lite';
5+
import React, { useEffect } from 'react';
6+
7+
import SignInButton from 'app/pages/common/SignInButton';
8+
import { useSignals, useStore } from 'app/store';
9+
10+
import { Description } from '../../elements';
11+
12+
const NOT_OWNED_MESSAGE = `Fork this sandbox to make deployments, commit to GitHub, create live sessions with others and more!`;
13+
const NOT_SIGNED_IN_MESSAGE = `Sign in to be able to organize your sandboxes with a dashboard, make deployments, collaborate live with others, make commits to GitHub and more!`;
14+
15+
export const More = observer(() => {
16+
const {
17+
editor: { forkSandboxClicked },
18+
} = useSignals();
19+
const {
20+
editor: {
21+
currentSandbox: { owned },
22+
isForkingSandbox,
23+
},
24+
} = useStore();
25+
26+
useEffect(() => track('Workspace - More Opened'), []);
27+
28+
const message = !owned ? NOT_OWNED_MESSAGE : NOT_SIGNED_IN_MESSAGE;
29+
30+
return (
31+
<div>
32+
<Description>{message}</Description>
33+
34+
<Margin margin={1}>
35+
{!owned ? (
36+
<ProgressButton
37+
block
38+
loading={isForkingSandbox}
39+
onClick={() => forkSandboxClicked()}
40+
small
41+
>
42+
{isForkingSandbox ? 'Forking Sandbox...' : 'Fork Sandbox'}
43+
</ProgressButton>
44+
) : (
45+
<SignInButton block />
46+
)}
47+
</Margin>
48+
</div>
49+
);
50+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { More } from './More';

‎packages/app/src/app/pages/Sandbox/Editor/Workspace/items/More/index.tsx‎

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)