Skip to content

Commit 324d1c6

Browse files
authored
move loading and place in correct page (codesandbox#3971)
1 parent f0a1a23 commit 324d1c6

File tree

7 files changed

+161
-125
lines changed

7 files changed

+161
-125
lines changed

packages/app/src/app/overmind/effects/gql/dashboard/queries.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export const ownedTemplates: Query<
8484
`;
8585

8686
export const getTeams: Query<TeamsQuery, TeamsQueryVariables> = gql`
87-
query TeamsSidebar {
87+
query Teams {
8888
me {
8989
teams {
9090
id
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import css from '@styled-system/css';
3+
import { Element, Text } from '@codesandbox/components';
4+
5+
export const Loading = () => (
6+
<Element
7+
css={css({
8+
width: '100%',
9+
height: '100%',
10+
backgroundColor: 'sideBar.background',
11+
color: 'sideBar.foreground',
12+
position: 'absolute',
13+
zIndex: 2,
14+
display: 'flex',
15+
alignItems: 'center',
16+
justifyContent: 'center',
17+
})}
18+
>
19+
<Text>Loading</Text>
20+
</Element>
21+
);

packages/app/src/app/pages/NewDashboard/Content/routes/Deleted/index.tsx

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React, { useEffect } from 'react';
22
import { Element, Text } from '@codesandbox/components';
33
import { useOvermind } from 'app/overmind';
4-
import { SandboxCard } from '../../../Components/SandboxCard';
4+
import { SandboxCard } from 'app/pages/NewDashboard/Components/SandboxCard';
5+
import { Loading } from 'app/pages/NewDashboard/Components/Loading';
56

67
export const Deleted = () => {
78
const {
@@ -16,37 +17,39 @@ export const Deleted = () => {
1617
actions.dashboard.getDeletedSandboxes();
1718
}, [actions.dashboard, user]);
1819

19-
if (loadingPage) {
20-
return <Text>loading</Text>;
21-
}
22-
2320
return (
24-
<Element>
21+
<Element style={{ position: 'relative' }}>
2522
<Text marginBottom={2} block>
2623
Recently Deleted
2724
</Text>
2825
<Text variant="muted" block marginBottom={11}>
2926
Sandboxes, Templates and Folders are permanently deleted after 30 days{' '}
3027
</Text>
31-
{deletedSandboxesByTime.week.length && (
32-
<Element marginBottom={14}>
33-
<Text marginBottom={6} block>
34-
Archived this week
35-
</Text>
36-
{deletedSandboxesByTime.week.map(sandbox => (
37-
<SandboxCard sandbox={sandbox} key={sandbox.id} />
38-
))}
39-
</Element>
40-
)}
41-
{deletedSandboxesByTime.older.length && (
28+
{!loadingPage ? (
4229
<>
43-
<Text marginBottom={6} block>
44-
Archived Earlier
45-
</Text>
46-
{deletedSandboxesByTime.older.map(sandbox => (
47-
<SandboxCard sandbox={sandbox} key={sandbox.id} />
48-
))}
30+
{deletedSandboxesByTime.week.length && (
31+
<Element marginBottom={14}>
32+
<Text marginBottom={6} block>
33+
Archived this week
34+
</Text>
35+
{deletedSandboxesByTime.week.map(sandbox => (
36+
<SandboxCard sandbox={sandbox} key={sandbox.id} />
37+
))}
38+
</Element>
39+
)}
40+
{deletedSandboxesByTime.older.length && (
41+
<>
42+
<Text marginBottom={6} block>
43+
Archived Earlier
44+
</Text>
45+
{deletedSandboxesByTime.older.map(sandbox => (
46+
<SandboxCard sandbox={sandbox} key={sandbox.id} />
47+
))}
48+
</>
49+
)}
4950
</>
51+
) : (
52+
<Loading />
5053
)}
5154
</Element>
5255
);

packages/app/src/app/pages/NewDashboard/Content/routes/Drafts/index.tsx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Element, Text } from '@codesandbox/components';
44
import { Filters } from 'app/pages/NewDashboard/Components/Filters';
55
import { useOvermind } from 'app/overmind';
66
import { AutoSizer, List } from 'react-virtualized';
7+
import { Loading } from 'app/pages/NewDashboard/Components/Loading';
78
import { getPossibleTemplates } from '../../utils';
89
import { SandboxCard } from '../../../Components/SandboxCard';
910

@@ -25,34 +26,33 @@ export const Drafts = () => {
2526
actions.dashboard.getDrafts();
2627
}, [actions.dashboard, user, activeTeam]);
2728

28-
if (loadingPage) {
29-
return <Text>loading</Text>;
30-
}
31-
32-
const filtered = getFilteredSandboxes(draftSandboxes);
33-
3429
function rowRenderer({ key, index, style }) {
3530
return <SandboxCard sandbox={filtered[index]} key={key} style={style} />;
3631
}
3732

33+
const filtered = getFilteredSandboxes(draftSandboxes);
34+
3835
return (
39-
<Element style={{ height: '100%' }}>
36+
<Element style={{ height: '100%', position: 'relative' }}>
4037
<Text marginBottom={4} block>
4138
Drafts
4239
</Text>
4340
<Filters possibleTemplates={getPossibleTemplates(draftSandboxes)} />
44-
<AutoSizer>
45-
{({ height, width }) => (
46-
<List
47-
width={width}
48-
height={height}
49-
rowCount={filtered.length}
50-
rowHeight={240}
51-
rowRenderer={rowRenderer}
52-
/>
53-
)}
54-
</AutoSizer>
55-
,
41+
{!loadingPage ? (
42+
<AutoSizer>
43+
{({ height, width }) => (
44+
<List
45+
width={width}
46+
height={height}
47+
rowCount={filtered.length}
48+
rowHeight={240}
49+
rowRenderer={rowRenderer}
50+
/>
51+
)}
52+
</AutoSizer>
53+
) : (
54+
<Loading />
55+
)}
5656
</Element>
5757
);
5858
};

packages/app/src/app/pages/NewDashboard/Content/routes/Recent/index.tsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useEffect } from 'react';
22
import { useOvermind } from 'app/overmind';
33
import { Text, Element, Grid, Column, Stack } from '@codesandbox/components';
44
import css from '@styled-system/css';
5-
5+
import { Loading } from 'app/pages/NewDashboard/Components/Loading';
66
import { Filters } from 'app/pages/NewDashboard/Components/Filters';
77
import { getPossibleTemplates } from '../../utils';
88
import { SandboxCard } from '../../../Components/SandboxCard';
@@ -27,10 +27,6 @@ export const Recent = () => {
2727

2828
const possibleTemplates = getPossibleTemplates(recentSandboxes);
2929

30-
if (loadingPage) {
31-
return <Element>Loading</Element>;
32-
}
33-
3430
const Group = ({ title, time }) =>
3531
getFilteredSandboxes(recentSandboxesByTime[time]).length ? (
3632
<Element marginBottom={14}>
@@ -56,17 +52,23 @@ export const Recent = () => {
5652

5753
return (
5854
<>
59-
<section>
55+
<section style={{ position: 'relative' }}>
6056
<Stack>
6157
<Text marginBottom={4} block>
6258
Recently Modified Sandboxes
6359
</Text>
6460
<Filters possibleTemplates={possibleTemplates} />
6561
</Stack>
66-
<Group title="Today" time="day" />
67-
<Group title="Last 7 Days" time="week" />
68-
<Group title="Earlier this month" time="month" />
69-
<Group title="Older" time="older" />
62+
{!loadingPage ? (
63+
<>
64+
<Group title="Today" time="day" />
65+
<Group title="Last 7 Days" time="week" />
66+
<Group title="Earlier this month" time="month" />
67+
<Group title="Older" time="older" />
68+
</>
69+
) : (
70+
<Loading />
71+
)}
7072
</section>
7173
</>
7274
);

packages/app/src/app/pages/NewDashboard/Content/routes/StartSandboxes/index.tsx

Lines changed: 65 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import React, { useEffect } from 'react';
22
import { useOvermind } from 'app/overmind';
3-
import { Text, Button, Grid, Column, Element } from '@codesandbox/components';
3+
import { Text, Button, Grid, Column } from '@codesandbox/components';
44
import css from '@styled-system/css';
5-
import { SandboxCard } from '../../../Components/SandboxCard';
5+
import { SandboxCard } from 'app/pages/NewDashboard/Components/SandboxCard';
6+
import { Loading } from 'app/pages/NewDashboard/Components/Loading';
67

78
export const StartSandboxes = () => {
89
const {
@@ -17,70 +18,78 @@ export const StartSandboxes = () => {
1718
actions.dashboard.getStartPageSandboxes();
1819
}, [actions.dashboard, user]);
1920

20-
if (loadingPage) {
21-
return <Element>Loading</Element>;
22-
}
23-
2421
return (
2522
<>
26-
<section>
23+
<section style={{ position: 'relative' }}>
2724
<Text marginBottom={4} block>
2825
Recently used Templates
2926
</Text>
30-
<Grid
31-
rowGap={6}
32-
columnGap={6}
33-
marginBottom={8}
34-
css={css({
35-
gridTemplateColumns: 'repeat(auto-fit, minmax(220px, 1fr))',
36-
})}
37-
>
38-
{startPageSandboxes.templates.map(({ sandbox }) => (
39-
<Column key={sandbox.id}>
40-
<SandboxCard sandbox={sandbox} />
41-
</Column>
42-
))}
43-
</Grid>
27+
{!loadingPage ? (
28+
<Grid
29+
rowGap={6}
30+
columnGap={6}
31+
marginBottom={8}
32+
css={css({
33+
gridTemplateColumns: 'repeat(auto-fit, minmax(220px, 1fr))',
34+
})}
35+
>
36+
{startPageSandboxes.templates.map(({ sandbox }) => (
37+
<Column key={sandbox.id}>
38+
<SandboxCard sandbox={sandbox} />
39+
</Column>
40+
))}
41+
</Grid>
42+
) : (
43+
<Loading />
44+
)}
4445
</section>
4546

46-
<section>
47-
<Text marginBottom={4} block>
47+
<section style={{ position: 'relative' }}>
48+
<Text
49+
marginBottom={4}
50+
block
51+
css={css({ position: 'relative', zIndex: 99 })}
52+
>
4853
Your Recent Sandboxes
4954
</Text>
50-
<Grid
51-
rowGap={6}
52-
columnGap={6}
53-
marginBottom={8}
54-
css={css({
55-
gridTemplateColumns: 'repeat(auto-fit, minmax(220px, 1fr))',
56-
})}
57-
>
58-
<Column>
59-
<Button
60-
variant="link"
61-
onClick={() => actions.modalOpened({ modal: 'newSandbox' })}
62-
css={css({
63-
height: 240,
64-
fontSize: 3,
65-
border: '1px solid',
66-
borderColor: 'grays.600',
67-
borderRadius: 'medium',
68-
transition: 'all ease-in',
69-
transitionDuration: theme => theme.speeds[2],
70-
':hover, :focus': {
71-
transform: 'scale(0.98)',
72-
},
73-
})}
74-
>
75-
New Sandbox
76-
</Button>
77-
</Column>
78-
{startPageSandboxes.recent.map(sandbox => (
79-
<Column key={sandbox.id}>
80-
<SandboxCard sandbox={sandbox} />
55+
{!loadingPage ? (
56+
<Grid
57+
rowGap={6}
58+
columnGap={6}
59+
marginBottom={8}
60+
css={css({
61+
gridTemplateColumns: 'repeat(auto-fit, minmax(220px, 1fr))',
62+
})}
63+
>
64+
<Column>
65+
<Button
66+
variant="link"
67+
onClick={() => actions.modalOpened({ modal: 'newSandbox' })}
68+
css={css({
69+
height: 240,
70+
fontSize: 3,
71+
border: '1px solid',
72+
borderColor: 'grays.600',
73+
borderRadius: 'medium',
74+
transition: 'all ease-in',
75+
transitionDuration: theme => theme.speeds[2],
76+
':hover, :focus': {
77+
transform: 'scale(0.98)',
78+
},
79+
})}
80+
>
81+
New Sandbox
82+
</Button>
8183
</Column>
82-
))}
83-
</Grid>
84+
{startPageSandboxes.recent.map(sandbox => (
85+
<Column key={sandbox.id}>
86+
<SandboxCard sandbox={sandbox} />
87+
</Column>
88+
))}
89+
</Grid>
90+
) : (
91+
<Loading />
92+
)}
8493
</section>
8594
</>
8695
);

0 commit comments

Comments
 (0)