Skip to content

Commit c0e3a31

Browse files
committed
🔨 Switch Project to use useOvermind
1 parent 729d375 commit c0e3a31

File tree

2 files changed

+27
-27
lines changed
  • packages/app/src/app

2 files changed

+27
-27
lines changed

‎packages/app/src/app/overmind/namespaces/workspace/actions.ts‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,17 +177,15 @@ export const sandboxDeleted: AsyncAction = async ({
177177
effects.router.redirectToSandboxWizard();
178178
};
179179

180-
export const sandboxPrivacyChanged: AsyncAction<{
181-
privacy: 0 | 1 | 2;
182-
}> = async ({ state, effects, actions }, { privacy }) => {
180+
export const sandboxPrivacyChanged: AsyncAction<0 | 1 | 2> = async (
181+
{ state, effects, actions },
182+
privacy
183+
) => {
183184
if (
184185
getTemplate(state.editor.currentSandbox.template).isServer &&
185186
privacy === 2
186187
) {
187-
actions.modalOpened({
188-
modal: 'privacyServerWarning',
189-
message: null,
190-
});
188+
actions.modalOpened({ modal: 'privacyServerWarning' });
191189
}
192190

193191
await effects.api.updatePrivacy(state.editor.currentId, privacy);

‎packages/app/src/app/pages/Sandbox/Editor/Workspace/Project/Project.tsx‎

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import {
77
patronUrl,
88
sandboxUrl,
99
} from '@codesandbox/common/lib/utils/url-generator';
10-
import { PrivacyStatus } from 'app/components/PrivacyStatus';
11-
import { Stats } from 'app/pages/common/Stats';
12-
import React from 'react';
10+
import React, { FunctionComponent } from 'react';
1311
import TeamIcon from 'react-icons/lib/md/people';
12+
import { PrivacyStatus } from 'app/components/PrivacyStatus';
1413
import { useOvermind } from 'app/overmind';
14+
import { Stats } from 'app/pages/common/Stats';
1515

16-
// import AliasComponent from './Alias';
16+
// import { Alias } from './Alias';
1717
import { Author } from './Author';
1818
import { Description } from './Description';
1919
import {
@@ -36,31 +36,29 @@ import { Keywords } from './Keywords';
3636
import { SandboxConfig } from './SandboxConfig';
3737
import { Title } from './Title';
3838

39-
interface IProjectProps {
39+
type Props = {
4040
editable?: boolean;
41-
}
42-
43-
export const Project: React.FunctionComponent<IProjectProps> = ({
44-
editable,
45-
}) => {
41+
};
42+
export const Project: FunctionComponent<Props> = ({ editable }) => {
4643
const {
44+
actions: {
45+
workspace: { sandboxPrivacyChanged },
46+
},
4747
state: {
4848
editor: { currentSandbox: sandbox },
4949
isPatron,
5050
},
51-
actions: {
52-
workspace: { sandboxPrivacyChanged },
53-
},
5451
} = useOvermind();
5552

5653
const template = getTemplateDefinition(sandbox.template);
57-
const { isServer } = template;
5854

5955
return (
6056
<Container>
6157
<BasicInfo>
6258
<Title editable={editable} />
59+
6360
<Description editable={editable} />
61+
6462
{/* Disable until we also moved SSE over */}
6563
{/* <Alias editable={editable} /> */}
6664
</BasicInfo>
@@ -71,6 +69,7 @@ export const Project: React.FunctionComponent<IProjectProps> = ({
7169
<Tooltip appendTo="parent" content="This sandbox is owned by this team">
7270
<Item style={{ color: 'white', display: 'flex' }}>
7371
<TeamIcon style={{ fontSize: '1.125em', marginRight: '.5rem' }} />
72+
7473
<div>{sandbox.team.name}</div>
7574
</Item>
7675
</Tooltip>
@@ -96,26 +95,27 @@ export const Project: React.FunctionComponent<IProjectProps> = ({
9695
<Group>
9796
<Item>
9897
<PropertyName>Privacy</PropertyName>
98+
9999
<PropertyValue>
100100
<PrivacyContainer>
101101
{editable ? (
102102
<>
103103
<PrivacySelect
104104
value={sandbox.privacy}
105105
disabled={!isPatron}
106-
onChange={event =>
107-
sandboxPrivacyChanged({
108-
privacy: Number(event.target.value) as 0 | 1 | 2,
109-
})
106+
onChange={({ target: { value } }) =>
107+
sandboxPrivacyChanged(Number(value) as 0 | 1 | 2)
110108
}
111109
>
112110
<option value={0}>Public</option>
111+
113112
{isPatron && (
114113
<option value={1}>
115114
Unlisted (only available by url)
116115
</option>
117116
)}
118-
{!isServer && isPatron && (
117+
118+
{!template.isServer && isPatron && (
119119
<option value={2}>Private</option>
120120
)}
121121
</PrivacySelect>
@@ -142,6 +142,7 @@ export const Project: React.FunctionComponent<IProjectProps> = ({
142142
{sandbox.forkedFromSandbox && (
143143
<Item>
144144
<PropertyName>Forked From</PropertyName>
145+
145146
<PropertyValue>
146147
<TemplateStyledLink to={sandboxUrl(sandbox.forkedFromSandbox)}>
147148
{getSandboxName(sandbox.forkedFromSandbox)}
@@ -160,7 +161,7 @@ export const Project: React.FunctionComponent<IProjectProps> = ({
160161
<>
161162
The environment determines how a sandbox is executed, you can
162163
find more info{' '}
163-
<a target="_blank" href="/docs/environment">
164+
<a href="/docs/environment" target="_blank">
164165
here
165166
</a>
166167
.
@@ -170,6 +171,7 @@ export const Project: React.FunctionComponent<IProjectProps> = ({
170171
<Icon />
171172
</Tooltip>
172173
</PropertyName>
174+
173175
<PropertyValue>
174176
<BundlerLink href={template.url}>{sandbox.template}</BundlerLink>
175177
</PropertyValue>

0 commit comments

Comments
 (0)