Skip to content

Commit 18bc6bf

Browse files
committed
Fix TypeScript errors
1 parent 6bdd548 commit 18bc6bf

File tree

6 files changed

+67
-30
lines changed

6 files changed

+67
-30
lines changed

packages/app/src/app/pages/Sandbox/Editor/Workspace/WorkspaceItem/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
} from './elements';
1111

1212
type Props = {
13-
children: React.ReactChildren;
13+
children: React.ReactNode;
1414
title: string;
1515
keepState?: boolean;
1616
disabled?: boolean;
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
import * as React from 'react';
2-
import { inject, observer } from 'mobx-react';
3-
41
import VERSION from '@codesandbox/common/lib/version';
2+
import { observer } from 'mobx-react-lite';
3+
import * as React from 'react';
4+
// Fix css prop types in styled-components (see https://github.com/DefinitelyTyped/DefinitelyTyped/issues/31245#issuecomment-463640878)
5+
import {} from 'styled-components/cssprop'; // eslint-disable-line
56

6-
import getWorkspaceItems from 'app/store/modules/workspace/items';
77
import SocialInfo from 'app/components/SocialInfo';
8+
import { useStore } from 'app/store';
9+
import getWorkspaceItems from 'app/store/modules/workspace/items';
810

911
import Files from './items/Files';
1012
import ProjectInfo from './items/ProjectInfo';
@@ -16,11 +18,11 @@ import Deployment from './items/Deployment';
1618
import ConfigurationFiles from './items/ConfigurationFiles';
1719
import NotOwnedSandboxInfo from './items/NotOwnedSandboxInfo';
1820

19-
import ConnectionNotice from './ConnectionNotice';
2021
import Advertisement from './Advertisement';
21-
import WorkspaceItem from './WorkspaceItem';
2222
import Chat from './Chat';
23+
import { ConnectionNotice } from './ConnectionNotice';
2324
import { SSEDownNotice } from './SSEDownNotice';
25+
import WorkspaceItem from './WorkspaceItem';
2426

2527
import {
2628
Container,
@@ -41,45 +43,62 @@ const idToItem = {
4143
more: More,
4244
};
4345

44-
function Workspace({ store }) {
45-
const sandbox = store.editor.currentSandbox;
46-
const preferences = store.preferences;
47-
48-
const currentItem = store.workspace.openedWorkspaceItem;
46+
const Workspace = () => {
47+
const store = useStore();
48+
const {
49+
editor: {
50+
currentSandbox: { owned },
51+
},
52+
isPatron,
53+
live: {
54+
isLive,
55+
roomInfo: { chatEnabled },
56+
},
57+
preferences: {
58+
settings: { zenMode },
59+
},
60+
workspace: { openedWorkspaceItem: currentItem },
61+
} = store;
4962

5063
if (!currentItem) {
5164
return null;
5265
}
5366

5467
const Component = idToItem[currentItem];
68+
const item = getWorkspaceItems(store).find(({ id }) => id === currentItem);
5569

56-
const item = getWorkspaceItems(store).find(i => i.id === currentItem);
5770
return (
5871
<Container>
5972
{item && !item.hasCustomHeader && <ItemTitle>{item.name}</ItemTitle>}
6073
<div style={{ flex: 1, overflowY: 'auto' }}>
6174
<Component />
6275
</div>
63-
{store.live.isLive && store.live.roomInfo.chatEnabled && (
76+
77+
{isLive && chatEnabled && (
6478
<WorkspaceItem defaultOpen title="Chat">
6579
<Chat />
6680
</WorkspaceItem>
6781
)}
68-
{!preferences.settings.zenMode && (
82+
83+
{!zenMode && (
6984
<div>
70-
{!store.isPatron && !sandbox.owned && <Advertisement />}
85+
{!(isPatron || owned) && <Advertisement />}
86+
7187
<ContactContainer>
7288
<SocialInfo style={{ display: 'inline-block' }} />
89+
7390
<VersionContainer className="codesandbox-version">
7491
{VERSION}
7592
</VersionContainer>
7693
</ContactContainer>
94+
7795
<SSEDownNotice />
96+
7897
<ConnectionNotice />
7998
</div>
8099
)}
81100
</Container>
82101
);
83-
}
102+
};
84103

85-
export default inject('signals', 'store')(observer(Workspace));
104+
export default observer(Workspace);

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/GitHub/CreateRepo/CreateRepo.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { useSignals, useStore } from 'app/store';
1313
import { Error } from './elements';
1414

1515
type Props = {
16-
style: React.CSSProperties;
16+
style?: React.CSSProperties;
1717
};
1818
export const CreateRepo = observer(({ style }: Props) => {
1919
const {

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/GitHub/Git/Git.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const Git = observer(() => {
4747
}: React.ChangeEvent<HTMLInputElement>) => subjectChanged({ subject: value });
4848
const changeDescription = ({
4949
target: { value },
50-
}: React.ChangeEvent<HTMLInputElement>) =>
50+
}: React.ChangeEvent<HTMLTextAreaElement>) =>
5151
descriptionChanged({ description: value });
5252

5353
const modulesNotSaved = !isAllModulesSynced;

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/GitHub/GitHub.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,12 @@ export const GitHub = observer(() => {
3838
)
3939
) : (
4040
<>
41-
<Description margin={1} top={0}>
41+
<Description
42+
css={`
43+
margin: 1;
44+
top: 0;
45+
`}
46+
>
4247
You can create commits and open pull requests if you add GitHub to your
4348
integrations.
4449
</Description>
Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,35 @@
1+
import { observer } from 'mobx-react-lite';
12
import React from 'react';
2-
import { inject, observer } from 'mobx-react';
33
import GithubLogo from 'react-icons/lib/go/mark-github';
4+
45
import Integration from 'app/components/Integration';
6+
import { useSignals, useStore } from 'app/store';
7+
8+
type Props = {
9+
small?: boolean,
10+
};
11+
const GithubIntegration = ({ small = false }: Props) => {
12+
const { signInGithubClicked, signOutGithubIntegration } = useSignals();
13+
const {
14+
isLoadingGithub,
15+
signOutGithubIntegration: {
16+
integrations: { github },
17+
},
18+
} = useStore();
519

6-
function GithubIntegration({ store, signals, small }) {
720
return (
821
<Integration
9-
name="GitHub"
1022
color="#4078c0"
1123
description={small ? 'Commits & PRs' : 'Committing & Pull Requests'}
1224
Icon={GithubLogo}
25+
loading={isLoadingGithub}
26+
name="GitHub"
27+
signIn={() => signInGithubClicked({ useExtraScopes: true })}
28+
signOut={signOutGithubIntegration}
1329
small={small}
14-
userInfo={store.user.integrations.github}
15-
signOut={() => signals.signOutGithubIntegration()}
16-
signIn={() => signals.signInGithubClicked({ useExtraScopes: true })}
17-
loading={store.isLoadingGithub}
30+
userInfo={github}
1831
/>
1932
);
20-
}
33+
};
2134

22-
export default inject('store', 'signals')(observer(GithubIntegration));
35+
export default observer(GithubIntegration);

0 commit comments

Comments
 (0)