Skip to content

Commit fe01df6

Browse files
committed
refactor: RecentSandboxes to use overmind
1 parent 4d80e45 commit fe01df6

File tree

1 file changed

+52
-52
lines changed
  • packages/app/src/app/pages/Dashboard/Content/routes/RecentSandboxes

1 file changed

+52
-52
lines changed
Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,66 @@
11
import React from 'react';
2-
import { observer, inject } from 'app/componentConnectors';
32
import Helmet from 'react-helmet';
4-
53
import { Query } from 'react-apollo';
64

5+
import { useOvermind } from 'app/overmind';
76
import getMostUsedTemplate from '../../../utils/get-most-used-template';
8-
97
import { Content as Sandboxes } from '../../Sandboxes';
10-
118
import CreateNewSandbox from '../../CreateNewSandbox';
129
import { RECENT_SANDBOXES_CONTENT_QUERY } from '../../../queries';
1310

14-
const RecentSandboxes = ({ store }) => (
15-
<>
16-
<Helmet>
17-
<title>Recent Sandboxes - CodeSandbox</title>
18-
</Helmet>
19-
<Query
20-
variables={{
21-
orderField: store.dashboard.orderBy.field,
22-
orderDirection: store.dashboard.orderBy.order.toUpperCase(),
23-
}}
24-
query={RECENT_SANDBOXES_CONTENT_QUERY}
25-
>
26-
{({ loading, error, data }) => {
27-
if (error) {
28-
return <div>Error!</div>;
29-
}
11+
const RecentSandboxes = () => {
12+
const { state } = useOvermind();
13+
return (
14+
<>
15+
<Helmet>
16+
<title>Recent Sandboxes - CodeSandbox</title>
17+
</Helmet>
18+
<Query
19+
variables={{
20+
orderField: state.dashboard.orderBy.field,
21+
orderDirection: state.dashboard.orderBy.order.toUpperCase(),
22+
}}
23+
query={RECENT_SANDBOXES_CONTENT_QUERY}
24+
>
25+
{({ loading, error, data }) => {
26+
if (error) {
27+
return <div>Error!</div>;
28+
}
3029

31-
const sandboxes = loading
32-
? []
33-
: (data && data.me && data.me.sandboxes) || [];
30+
const sandboxes = loading
31+
? []
32+
: (data && data.me && data.me.sandboxes) || [];
3433

35-
let mostUsedTemplate = null;
36-
try {
37-
mostUsedTemplate = getMostUsedTemplate(sandboxes);
38-
} catch (e) {
39-
// Not critical
40-
}
34+
let mostUsedTemplate = null;
35+
try {
36+
mostUsedTemplate = getMostUsedTemplate(sandboxes);
37+
} catch (e) {
38+
// Not critical
39+
}
4140

42-
// We want to hide all templates
43-
// TODO: make this a query variable for graphql and move the logic to the server
44-
const noTemplateSandboxes = sandboxes.filter(s => !s.customTemplate);
41+
// We want to hide all templates
42+
// TODO: make this a query variable for graphql and move the logic to the server
43+
const noTemplateSandboxes = sandboxes.filter(s => !s.customTemplate);
4544

46-
return (
47-
<Sandboxes
48-
isLoading={loading}
49-
Header="Recent Sandboxes"
50-
ExtraElement={({ style }) => (
51-
<CreateNewSandbox
52-
mostUsedSandboxTemplate={mostUsedTemplate}
53-
style={style}
54-
/>
55-
)}
56-
hideFilters
57-
sandboxes={noTemplateSandboxes}
58-
page="recent"
59-
/>
60-
);
61-
}}
62-
</Query>
63-
</>
64-
);
45+
return (
46+
<Sandboxes
47+
isLoading={loading}
48+
Header="Recent Sandboxes"
49+
ExtraElement={({ style }) => (
50+
<CreateNewSandbox
51+
mostUsedSandboxTemplate={mostUsedTemplate}
52+
style={style}
53+
/>
54+
)}
55+
hideFilters
56+
sandboxes={noTemplateSandboxes}
57+
page="recent"
58+
/>
59+
);
60+
}}
61+
</Query>
62+
</>
63+
);
64+
};
6565

66-
export default inject('signals', 'store')(observer(RecentSandboxes));
66+
export default RecentSandboxes;

0 commit comments

Comments
 (0)