Skip to content

Commit 2783b46

Browse files
christianalfoniCompuIves
authored andcommitted
THIS IS THE FLIP PR (codesandbox#2444)
* removed cerebral instantiation * remove experiment * Style experiments * Fix
1 parent 02e5372 commit 2783b46

File tree

3 files changed

+45
-117
lines changed

3 files changed

+45
-117
lines changed

packages/app/src/app/componentConnectors.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { inject as mobxInject, observer as mobxObserver } from 'mobx-react';
33
import { observer as mobxHooksObserver } from 'mobx-react-lite';
44
import { connect } from './overmind';
55

6-
const isOvermind = localStorage.getItem('overmind') === 'true';
6+
const isOvermind = true;
77

88
export const inject: any = isOvermind
99
? () => component => component

packages/app/src/app/index.js

Lines changed: 31 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,14 @@ import { render } from 'react-dom';
33
import { ThemeProvider } from 'styled-components';
44
import { Router } from 'react-router-dom';
55
import { ApolloProvider } from 'react-apollo';
6-
import { reaction } from 'mobx';
76
import { ApolloProvider as HooksProvider } from '@apollo/react-hooks';
8-
import { Provider } from 'mobx-react';
97
import _debug from '@codesandbox/common/lib/utils/debug';
8+
import { createOvermind } from 'overmind';
109
import {
1110
initializeSentry,
1211
logError,
1312
} from '@codesandbox/common/lib/utils/analytics';
1413
import '@codesandbox/common/lib/global.css';
15-
16-
import store, { Signals, Store } from 'app/store';
1714
import history from 'app/utils/history';
1815
import { client } from 'app/graphql/client';
1916
import registerServiceWorker from '@codesandbox/common/lib/registerServiceWorker';
@@ -29,12 +26,11 @@ import { isSafari } from '@codesandbox/common/lib/utils/platform';
2926

3027
// eslint-disable-next-line
3128
import * as childProcess from 'node-services/lib/child_process';
32-
import { Controller } from '@cerebral/mobx-state-tree';
3329
import { Routes as App } from './pages';
3430
import { Provider as OvermindProvider } from './overmind/Provider';
31+
import { config } from './overmind';
3532
import './split-pane.css';
3633
import { getTypeFetcher } from './vscode/extensionHostWorker/common/type-downloader';
37-
import overmindLogo from './overmind.png';
3834
import { vscode } from './vscode';
3935
import {
4036
initializeThemeCache,
@@ -72,7 +68,7 @@ window.__isTouch = !matchMedia('(pointer:fine)').matches;
7268
let getState;
7369
let getSignal;
7470

75-
async function boot(state, signals, overmind) {
71+
async function boot(overmind) {
7672
requirePolyfills().then(() => {
7773
if (isSafari) {
7874
import('subworkers');
@@ -122,27 +118,17 @@ async function boot(state, signals, overmind) {
122118

123119
try {
124120
render(
125-
<Signals.Provider value={signals}>
126-
<Store.Provider value={state}>
127-
<Provider
128-
store={state}
129-
signals={signals}
130-
reaction={(cbA, cbB) => reaction(() => cbA(state), cbB)}
131-
>
132-
<ApolloProvider client={client}>
133-
<OvermindProvider value={overmind}>
134-
<HooksProvider client={client}>
135-
<ThemeProvider theme={theme}>
136-
<Router history={history}>
137-
<App />
138-
</Router>
139-
</ThemeProvider>
140-
</HooksProvider>
141-
</OvermindProvider>
142-
</ApolloProvider>
143-
</Provider>
144-
</Store.Provider>
145-
</Signals.Provider>,
121+
<ApolloProvider client={client}>
122+
<OvermindProvider value={overmind}>
123+
<HooksProvider client={client}>
124+
<ThemeProvider theme={theme}>
125+
<Router history={history}>
126+
<App />
127+
</Router>
128+
</ThemeProvider>
129+
</HooksProvider>
130+
</OvermindProvider>
131+
</ApolloProvider>,
146132
rootEl
147133
);
148134
} catch (e) {
@@ -155,85 +141,24 @@ async function initialize() {
155141
/*
156142
Configure Cerebral and Overmind
157143
*/
158-
let signals = null;
159-
let state = null;
160-
let overmind = null;
161-
162-
window.useOvermind = useIt => {
163-
if (typeof useIt === 'undefined') {
164-
return localStorage.getItem('overmind');
165-
}
166-
167-
localStorage.setItem('overmind', JSON.stringify(useIt));
168-
location.reload(true);
169-
170-
return useIt;
171-
};
172144

173-
if (localStorage.getItem('overmind') === 'true') {
174-
await Promise.all([import('overmind'), import('./overmind')]).then(
175-
modules => {
176-
const createOvermind = modules[0].createOvermind;
177-
const config = modules[1].config;
178-
179-
overmind = createOvermind(config, {
180-
devtools:
181-
(window.opener && window.opener !== window) || !window.chrome
182-
? false
183-
: 'localhost:3031',
184-
name:
185-
'CodeSandbox - ' +
186-
(navigator.userAgent.indexOf('Chrome/76') > 0
187-
? 'Chrome'
188-
: 'Canary'),
189-
logProxies: true,
190-
});
191-
192-
getState = path =>
193-
path
194-
? path.split('.').reduce((aggr, key) => aggr[key], overmind.state)
195-
: overmind.state;
196-
getSignal = path =>
197-
path.split('.').reduce((aggr, key) => aggr[key], overmind.actions);
198-
199-
const logoContainer = document.createElement('div');
200-
logoContainer.style.position = 'fixed';
201-
logoContainer.style.bottom = '30px';
202-
logoContainer.style.left = '10px';
203-
logoContainer.style.zIndex = '999999';
204-
logoContainer.style.width = '40px';
205-
logoContainer.style.height = '40px';
206-
logoContainer.style.borderRadius = '3px';
207-
logoContainer.style.backgroundImage = `url(${overmindLogo})`;
208-
logoContainer.style.backgroundSize = 'cover';
209-
logoContainer.style.backgroundSize = 'cover';
210-
document.body.appendChild(logoContainer);
211-
}
212-
);
213-
} else {
214-
let Devtools = null;
215-
216-
if (process.env.NODE_ENV !== 'production') {
217-
Devtools = require('cerebral/devtools').default; // eslint-disable-line
218-
}
219-
220-
const controller = Controller(store, {
221-
devtools:
222-
Devtools &&
223-
Devtools({
224-
host: 'localhost:8383',
225-
reconnect: false,
226-
}),
227-
});
228-
229-
const controllerProvided = controller.provide();
230-
231-
state = controllerProvided.store;
232-
signals = controllerProvided.signals;
145+
const overmind = createOvermind(config, {
146+
devtools:
147+
(window.opener && window.opener !== window) || !window.chrome
148+
? false
149+
: 'localhost:3031',
150+
name:
151+
'CodeSandbox - ' +
152+
(navigator.userAgent.indexOf('Chrome/76') > 0 ? 'Chrome' : 'Canary'),
153+
logProxies: true,
154+
});
233155

234-
getState = controller.getState.bind(controller);
235-
getSignal = controller.getSignal.bind(controller);
236-
}
156+
getState = path =>
157+
path
158+
? path.split('.').reduce((aggr, key) => aggr[key], overmind.state)
159+
: overmind.state;
160+
getSignal = path =>
161+
path.split('.').reduce((aggr, key) => aggr[key], overmind.actions);
237162

238163
window.getState = getState;
239164
window.getSignal = getSignal;
@@ -334,7 +259,7 @@ async function initialize() {
334259
// }
335260
// );
336261
}
337-
boot(state, signals, overmind);
262+
boot(overmind);
338263
}
339264
);
340265
}

packages/app/src/app/pages/common/Modals/PreferencesModal/Experiments/index.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
import React from 'react';
2-
import track from '@codesandbox/common/lib/utils/analytics';
3-
// import { inject, observer } from 'app/componentConnectors';
42

53
import {
64
Title,
75
SubContainer,
86
SubDescription,
97
PreferenceContainer,
10-
PaddedPreference,
118
} from '../elements';
129

13-
const windowWithOvermind: {
14-
useOvermind?: (val?: boolean) => 'true' | null;
15-
} = window as any;
10+
// const windowWithOvermind: {
11+
// useOvermind?: (val?: boolean) => 'true' | null;
12+
// } = window as any;
1613

1714
export function Experiments() {
1815
// const bindValue = name => ({
@@ -24,17 +21,22 @@ export function Experiments() {
2421
// }),
2522
// });
2623

27-
const [usingOvermind, setUsingOvermind] = React.useState(
28-
typeof windowWithOvermind.useOvermind !== 'undefined' &&
29-
windowWithOvermind.useOvermind() === 'true'
30-
);
24+
// const [usingOvermind, setUsingOvermind] = React.useState(
25+
// typeof windowWithOvermind.useOvermind !== 'undefined' &&
26+
// windowWithOvermind.useOvermind() === 'true'
27+
// );
3128

3229
return (
3330
<div>
3431
<Title>Experiments</Title>
3532

3633
<SubContainer>
3734
<PreferenceContainer>
35+
<SubDescription>
36+
There are no experiments running at the moment. Stay tuned for new
37+
experiments!
38+
</SubDescription>
39+
{/*
3840
<PaddedPreference
3941
title="Use Overmind"
4042
type="boolean"
@@ -51,6 +53,7 @@ export function Experiments() {
5153
Use Overmind (an evolution of our current state management) as the
5254
state management
5355
</SubDescription>
56+
*/}
5457
</PreferenceContainer>
5558
</SubContainer>
5659
</div>

0 commit comments

Comments
 (0)