Skip to content

Commit a03e01e

Browse files
christianalfoniSaraVieira
authored andcommitted
removed connector (codesandbox#3255)
1 parent bce0796 commit a03e01e

File tree

7 files changed

+60
-93
lines changed

7 files changed

+60
-93
lines changed

packages/app/src/app/componentConnectors.ts

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

packages/app/src/app/overmind/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
IOperator,
77
IReaction,
88
IState,
9+
Overmind,
910
} from 'overmind';
1011
import { createHook } from 'overmind-react';
1112
import { merge, namespaced } from 'overmind/config';
@@ -77,3 +78,14 @@ export interface Reaction extends IReaction<Config> {}
7778
export const connect = createConnect<typeof config>();
7879

7980
export const useOvermind = createHook<typeof config>();
81+
82+
export const Observer: React.FC<{
83+
children: <T>(overmind: {
84+
state: Overmind<Config>['state'];
85+
actions: Overmind<Config>['actions'];
86+
}) => T;
87+
}> = ({ children }) => {
88+
const overmind = useOvermind();
89+
90+
return children(overmind);
91+
};

packages/app/src/app/pages/Dashboard/Content/routes/DeletedSandboxes/index.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
import { Observer } from 'app/overmind';
12
import React from 'react';
2-
import { Observer } from 'app/componentConnectors';
3-
import Helmet from 'react-helmet';
43
import { Query } from 'react-apollo';
4+
import Helmet from 'react-helmet';
55
import RemoveIcon from 'react-icons/lib/md/highlight-remove';
66

7-
import { Content as Sandboxes } from '../../Sandboxes';
8-
97
import { DELETED_SANDBOXES_CONTENT_QUERY } from '../../../queries';
8+
import { Content as Sandboxes } from '../../Sandboxes';
109
import { getPossibleTemplates } from '../../Sandboxes/utils';
1110

1211
const DeletedSandboxes = () => (
@@ -20,7 +19,7 @@ const DeletedSandboxes = () => (
2019
>
2120
{({ loading, error, data }) => (
2221
<Observer>
23-
{({ store, signals }) => {
22+
{({ state, actions }) => {
2423
if (error) {
2524
return <div>Error!</div>;
2625
}
@@ -31,10 +30,10 @@ const DeletedSandboxes = () => (
3130

3231
const possibleTemplates = getPossibleTemplates(sandboxes);
3332

34-
const orderedSandboxes = store.dashboard.getFilteredSandboxes(
33+
const orderedSandboxes = state.dashboard.getFilteredSandboxes(
3534
sandboxes
3635
);
37-
signals.dashboard.setTrashSandboxes({
36+
actions.dashboard.setTrashSandboxes({
3837
sandboxIds: orderedSandboxes.map(i => i.id),
3938
});
4039

@@ -51,7 +50,7 @@ const DeletedSandboxes = () => (
5150
name: 'Empty Trash',
5251
Icon: <RemoveIcon />,
5352
run: () => {
54-
signals.modalOpened({
53+
actions.modalOpened({
5554
modal: 'emptyTrash',
5655
});
5756
},

packages/app/src/app/pages/Dashboard/Content/routes/PathedSandboxes/index.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import React from 'react';
2-
import Helmet from 'react-helmet';
3-
import { Observer } from 'app/componentConnectors';
4-
import { Query } from 'react-apollo';
51
import { basename } from 'path';
2+
63
import { CreateNewSandboxButton } from 'app/components/CreateNewSandbox';
7-
import { Content as Sandboxes } from '../../Sandboxes';
8-
import { Navigation } from './Navigation';
9-
// import Folders from './Folders';
10-
import getMostUsedTemplate from '../../../utils/get-most-used-template';
4+
import { Observer } from 'app/overmind';
5+
import React from 'react';
6+
import { Query } from 'react-apollo';
7+
import Helmet from 'react-helmet';
118

129
import { PATHED_SANDBOXES_CONTENT_QUERY } from '../../../queries';
10+
// import Folders from './Folders';
11+
import getMostUsedTemplate from '../../../utils/get-most-used-template';
12+
import { Content as Sandboxes } from '../../Sandboxes';
1313
import { getPossibleTemplates } from '../../Sandboxes/utils';
14+
import { Navigation } from './Navigation';
1415

1516
const PathedSandboxes = props => {
1617
const path = '/' + decodeURIComponent(props.match.params.path || '');
@@ -26,7 +27,7 @@ const PathedSandboxes = props => {
2627
>
2728
{({ loading, error, data }) => (
2829
<Observer>
29-
{({ store }) => {
30+
{({ state }) => {
3031
if (error) {
3132
console.error(error);
3233
return <div>Error!</div>;
@@ -44,7 +45,7 @@ const PathedSandboxes = props => {
4445
const noTemplateSandboxes = sandboxes.filter(
4546
s => !s.customTemplate
4647
);
47-
const orderedSandboxes = store.dashboard.getFilteredSandboxes(
48+
const orderedSandboxes = state.dashboard.getFilteredSandboxes(
4849
noTemplateSandboxes
4950
);
5051

packages/app/src/app/pages/Dashboard/Content/routes/SearchSandboxes/index.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
import { Observer } from 'app/overmind';
2+
import Fuse from 'fuse.js';
13
import React from 'react';
2-
import Helmet from 'react-helmet';
3-
import { Observer } from 'app/componentConnectors';
44
import { Query } from 'react-apollo';
5-
import Fuse from 'fuse.js';
6-
7-
import { Content as Sandboxes } from '../../Sandboxes';
5+
import Helmet from 'react-helmet';
86

97
import { SEARCH_SANDBOXES_QUERY } from '../../../queries';
8+
import { Content as Sandboxes } from '../../Sandboxes';
109
import { getPossibleTemplates } from '../../Sandboxes/utils';
1110

1211
let lastSandboxes = null;
@@ -16,12 +15,12 @@ const SearchSandboxes = () => (
1615
<Query query={SEARCH_SANDBOXES_QUERY}>
1716
{({ loading, error, data }) => (
1817
<Observer>
19-
{({ store }) => {
18+
{({ state }) => {
2019
if (error) {
2120
return <div>Error!</div>;
2221
}
2322

24-
const { search } = store.dashboard.filters;
23+
const { search } = state.dashboard.filters;
2524
let sandboxes = data && data.me && data.me.sandboxes;
2625
if (
2726
sandboxes &&
@@ -55,7 +54,7 @@ const SearchSandboxes = () => (
5554
if (sandboxes) {
5655
possibleTemplates = getPossibleTemplates(sandboxes);
5756

58-
sandboxes = store.dashboard
57+
sandboxes = state.dashboard
5958
.getFilteredSandboxes(sandboxes)
6059
.filter(x => !x.customTemplate);
6160
}

packages/app/src/app/pages/Dashboard/Content/routes/TeamView/index.js

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
1-
import React from 'react';
2-
import Helmet from 'react-helmet';
3-
import { Query, Mutation } from 'react-apollo';
4-
import { Observer } from 'app/componentConnectors';
5-
import { sortBy } from 'lodash-es';
6-
7-
import { UserWithAvatar } from '@codesandbox/common/lib/components/UserWithAvatar';
8-
import { Button } from '@codesandbox/common/lib/components/Button';
91
import AutosizeTextArea from '@codesandbox/common/lib/components/AutosizeTextArea';
2+
import { Button } from '@codesandbox/common/lib/components/Button';
103
import Margin from '@codesandbox/common/lib/components/spacing/Margin';
4+
import { UserWithAvatar } from '@codesandbox/common/lib/components/UserWithAvatar';
115
import track from '@codesandbox/common/lib/utils/analytics';
6+
import { Observer } from 'app/overmind';
7+
import { sortBy } from 'lodash-es';
8+
import React from 'react';
9+
import { Mutation, Query } from 'react-apollo';
10+
import Helmet from 'react-helmet';
1211

13-
import { Container, HeaderContainer, Description } from '../../elements';
14-
import {
15-
TeamContainer,
16-
Section,
17-
Members,
18-
MemberHeader,
19-
StyledEditIcon,
20-
} from './elements';
2112
import {
22-
TEAM_QUERY,
2313
REVOKE_TEAM_INVITATION,
2414
SET_TEAM_DESCRIPTION,
15+
TEAM_QUERY,
2516
} from '../../../queries';
26-
17+
import { Container, Description, HeaderContainer } from '../../elements';
2718
import { AddTeamMember } from './AddTeamMember';
19+
import {
20+
MemberHeader,
21+
Members,
22+
Section,
23+
StyledEditIcon,
24+
TeamContainer,
25+
} from './elements';
2826
import { RemoveTeamMember } from './RemoveTeamMember';
2927

3028
const User = ({ user, rightElement }) => (
@@ -64,8 +62,8 @@ class TeamView extends React.PureComponent {
6462
<Query query={TEAM_QUERY} variables={{ id: teamId }}>
6563
{({ data, loading, error }) => (
6664
<Observer>
67-
{({ store }) => {
68-
const currentUser = store.user;
65+
{({ state }) => {
66+
const currentUser = state.user;
6967
if (loading || error) {
7068
return null;
7169
}
@@ -163,8 +161,8 @@ class TeamView extends React.PureComponent {
163161

164162
<StyledEditIcon
165163
onClick={() => {
166-
this.setState(state => ({
167-
editingDescription: !state.editingDescription,
164+
this.setState(currentState => ({
165+
editingDescription: !currentState.editingDescription,
168166
}));
169167
}}
170168
/>

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import React, { FunctionComponent } from 'react';
21
import Tags from '@codesandbox/common/lib/components/Tags';
32
import getTemplateDefinition from '@codesandbox/common/lib/templates';
4-
5-
import { clone } from 'app/componentConnectors';
63
import { EditableTags } from 'app/components/EditableTags';
74
import { useOvermind } from 'app/overmind';
5+
import { json } from 'overmind';
6+
import React, { FunctionComponent } from 'react';
87

98
import { Item } from './elements';
109

@@ -46,7 +45,7 @@ export const Keywords: FunctionComponent<Props> = ({ editable }) => {
4645
tags.length !== 5 ? <input type="text" {...props} /> : null
4746
}
4847
template={getTemplateDefinition(template)}
49-
value={clone(tags)}
48+
value={json(tags)}
5049
/>
5150
) : (
5251
<Tags style={{ fontSize: 13 }} tags={tags} />

0 commit comments

Comments
 (0)