Skip to content

Commit c1d3de6

Browse files
authored
Private GitHub import (codesandbox#1082)
Fixes codesandbox#860
1 parent 22af7b7 commit c1d3de6

File tree

5 files changed

+66
-29
lines changed

5 files changed

+66
-29
lines changed

packages/app/src/app/pages/Sandbox/index.js

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ import { inject, observer } from 'mobx-react';
33
import { Link } from 'react-router-dom';
44
import QuickActions from 'app/pages/Sandbox/QuickActions';
55

6+
import Button from 'app/components/Button';
7+
import NotFound from 'app/pages/common/NotFound';
68
import Navigation from 'app/pages/common/Navigation';
79
import Title from 'app/components/Title';
810
import Centered from 'common/components/flex/Centered';
911
import Fullscreen from 'common/components/flex/Fullscreen';
1012
import Padding from 'common/components/spacing/Padding';
1113
import Skeleton from 'app/components/Skeleton';
14+
import GithubIntegration from 'app/src/app/pages/common/GithubIntegration';
1215

1316
import Editor from './Editor';
1417

@@ -54,29 +57,15 @@ class SandboxPage extends React.Component {
5457
getContent() {
5558
const { store } = this.props;
5659

60+
const { hasLogIn } = store;
61+
5762
if (store.editor.notFound) {
58-
return (
59-
<React.Fragment>
60-
<div
61-
style={{
62-
fontWeight: 300,
63-
color: 'rgba(255, 255, 255, 0.5)',
64-
marginBottom: '1rem',
65-
fontSize: '1.5rem',
66-
}}
67-
>
68-
404 Not Found
69-
</div>
70-
<Title style={{ fontSize: '1.25rem' }}>
71-
We could not find the sandbox you{"'"}re looking for
72-
</Title>
73-
<br />
74-
<Link to="/s">Create Sandbox</Link>
75-
</React.Fragment>
76-
);
63+
return <NotFound />;
7764
}
7865

7966
if (store.editor.error) {
67+
const isGithub = this.props.match.params.id.indexOf('github') > -1;
68+
const hasPrivateAccess = store.user && store.user.integrations.github;
8069
return (
8170
<React.Fragment>
8271
<div
@@ -89,9 +78,41 @@ class SandboxPage extends React.Component {
8978
>
9079
Something went wrong
9180
</div>
92-
<Title style={{ fontSize: '1.25rem' }}>{store.editor.error}</Title>
81+
<Title style={{ fontSize: '1.25rem', marginBottom: 0 }}>
82+
{store.editor.error}
83+
</Title>
9384
<br />
94-
<Link to="/s">Create Sandbox</Link>
85+
<div style={{ display: 'flex', maxWidth: 400, width: '100%' }}>
86+
<Button block small style={{ margin: '.5rem' }} href="/s">
87+
Create Sandbox
88+
</Button>
89+
<Button block small style={{ margin: '.5rem' }} href="/">
90+
{hasLogIn ? 'Dashboard' : 'Homepage'}
91+
</Button>
92+
</div>
93+
{hasLogIn &&
94+
isGithub &&
95+
!hasPrivateAccess && (
96+
<div
97+
style={{ maxWidth: 400, marginTop: '2.5rem', width: '100%' }}
98+
>
99+
<div
100+
style={{
101+
fontWeight: 300,
102+
color: 'rgba(255, 255, 255, 0.7)',
103+
marginBottom: '1rem',
104+
fontSize: '1rem',
105+
textAlign: 'center',
106+
lineHeight: 1.6,
107+
}}
108+
>
109+
Did you try to open a private GitHub repository and are you a{' '}
110+
<Link to="/patron">patron</Link>? Then you might need to get
111+
private access:
112+
</div>
113+
<GithubIntegration small />
114+
</div>
115+
)}
95116
</React.Fragment>
96117
);
97118
}

packages/app/src/app/pages/common/NotFound/elements.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,27 @@ export const Container = styled.div`
66
align-items: center;
77
justify-content: center;
88
flex-direction: column;
9-
font-size: 1.5rem;
109
color: white;
1110
height: 100vh;
1211
`;
1312

1413
export const Title = styled.h1`
15-
margin-bottom: 0;
14+
font-weight: 300;
15+
color: rgba(255, 255, 255, 0.5);
16+
margin-bottom: 1rem;
17+
font-size: 1.5rem;
18+
`;
19+
20+
export const SubTitle = styled.h2`
21+
font-weight: 300;
22+
margin-top: 0;
23+
margin-bottom: 1rem;
24+
font-size: 1.25rem;
1625
`;
1726

1827
export const Buttons = styled.div`
1928
display: flex;
2029
justify-content: space-around;
2130
min-width: 450px;
22-
flex-wrap: wrap;
2331
margin-top: 0.5rem;
2432
`;

packages/app/src/app/pages/common/NotFound/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
import React from 'react';
22

33
import { inject } from 'mobx-react';
4-
import SubTitle from 'app/components/SubTitle';
4+
55
import Button from 'app/components/Button';
66
import { newSandboxWizard } from 'common/utils/url-generator';
77

8-
import { Container, Title, Buttons } from './elements';
8+
import { Container, Title, SubTitle, Buttons } from './elements';
99

1010
function NotFound({ store }) {
1111
const { hasLogIn } = store;
1212

1313
return (
1414
<Container>
1515
<Title>404</Title>
16-
<SubTitle>We could not find the page you{"'"}re looking for :(</SubTitle>
16+
<SubTitle>We could not find the page you{"'"}re looking for.</SubTitle>
1717
<Buttons>
1818
<Button small block style={{ margin: '.5rem' }} to={newSandboxWizard()}>
1919
Create Sandbox
2020
</Button>
2121
<Button small block style={{ margin: '.5rem' }} href="/">
22-
To {hasLogIn ? 'Dashboard' : 'Homepage'}
22+
{hasLogIn ? 'Dashboard' : 'Homepage'}
2323
</Button>
2424
</Buttons>
2525
</Container>

packages/app/src/app/store/actions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ export function closeTabByIndex({ state, props }) {
232232
export function signInGithub({ browser, path, props }) {
233233
const { useExtraScopes } = props;
234234
const popup = browser.openPopup(
235-
`/auth/github${useExtraScopes ? '?scope=user:email,public_repo' : ''}`,
235+
`/auth/github${useExtraScopes ? '?scope=user:email,repo' : ''}`,
236236
'sign in'
237237
);
238238

yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23729,6 +23729,14 @@ uglify-es@^3.3.4, uglify-es@^3.3.7, uglify-es@^3.3.9:
2372923729
source-map "~0.6.1"
2373023730
source-map-support "~0.5.6"
2373123731

23732+
uglify-es@^3.3.4, uglify-es@^3.3.7, uglify-es@^3.3.9, "uglify-es@npm:terser":
23733+
version "3.8.1"
23734+
resolved "https://registry.yarnpkg.com/terser/-/terser-3.8.1.tgz#cb70070ac9e0a71add169dfb63c0a64fca2738ac"
23735+
dependencies:
23736+
commander "~2.16.0"
23737+
source-map "~0.6.1"
23738+
source-map-support "~0.5.6"
23739+
2373223740
uglify-js@3.3.x:
2373323741
version "3.3.28"
2373423742
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.3.28.tgz#0efb9a13850e11303361c1051f64d2ec68d9be06"

0 commit comments

Comments
 (0)