Skip to content

Commit c751d63

Browse files
authored
Merge pull request #1 from codesandbox/pr-christianalfoni-2774
Fixes import
2 parents 5cdb82f + 1f30ae4 commit c751d63

File tree

15 files changed

+208
-96
lines changed

15 files changed

+208
-96
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ merge of your pull request!
1818

1919
<!-- if this is a feature change -->
2020

21-
## What steps did you take to test this? This is required before we can merge.
21+
## What steps did you take to test this? This is required before we can merge, make sure to test the flow you've updated.
2222

2323
1. Step A
2424
2. Step B

packages/app/src/app/overmind/internalActions.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,12 @@ export const signInGithub: Action<
9898
{ useExtraScopes: boolean },
9999
Promise<string>
100100
> = ({ effects }, options) => {
101-
const popup = effects.browser.openPopup(
102-
`/auth/github${options.useExtraScopes ? '?scope=user:email,repo' : ''}`,
103-
'sign in'
104-
);
101+
const authPath =
102+
process.env.LOCAL_SERVER || 'STAGING_BRANCH' in process.env
103+
? '/auth/dev'
104+
: `/auth/github${options.useExtraScopes ? '?scope=user:email,repo' : ''}`;
105+
106+
const popup = effects.browser.openPopup(authPath, 'sign in');
105107

106108
return effects.browser
107109
.waitForMessage<{ jwt: string }>('signin')
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import styled from 'styled-components';
2+
3+
export const Container = styled.div`
4+
display: flex;
5+
flex-direction: column;
6+
align-items: center;
7+
8+
height: 100%;
9+
width: 100%;
10+
margin: 1rem;
11+
margin-top: 10%;
12+
`;
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import React from 'react';
2+
3+
import { Title } from 'app/components/Title';
4+
import { SubTitle } from 'app/components/SubTitle';
5+
import Input from '@codesandbox/common/lib/components/Input';
6+
import { Button } from '@codesandbox/common/lib/components/Button';
7+
import { protocolAndHost } from '@codesandbox/common/lib/utils/url-generator';
8+
9+
import { Container } from './elements';
10+
11+
export const DevAuthPage = () => {
12+
const [authCode, setAuthCode] = React.useState('');
13+
const [error, setError] = React.useState<string | null>(null);
14+
15+
const getJWTToken = () => {
16+
setError(null);
17+
let ok = true;
18+
fetch(`/api/v1/auth/verify/${authCode}`)
19+
.then(res => {
20+
ok = res.ok;
21+
return res.json();
22+
})
23+
.then(res => {
24+
if (!ok) {
25+
throw new Error(res.errors.detail[0]);
26+
}
27+
if (
28+
window.opener &&
29+
window.opener.location.origin === window.location.origin
30+
) {
31+
window.opener.postMessage(
32+
{
33+
type: 'signin',
34+
data: {
35+
jwt: res.data.token,
36+
},
37+
},
38+
protocolAndHost()
39+
);
40+
}
41+
})
42+
.catch(e => {
43+
setError(e.message);
44+
});
45+
};
46+
47+
return (
48+
<Container>
49+
<Title>Developer Sign In</Title>
50+
<SubTitle style={{ width: 800 }}>
51+
Please enter the token you get from{' '}
52+
<a
53+
href="https://codesandbox.io/cli/login"
54+
target="popup"
55+
rel="noreferrer noopener"
56+
onClick={e => {
57+
e.preventDefault();
58+
window.open(
59+
'https://codesandbox.io/cli/login',
60+
'popup',
61+
'width=600,height=600'
62+
);
63+
return false;
64+
}}
65+
>
66+
here
67+
</a>
68+
. This token will sign you in with your account from codesandbox.io.
69+
</SubTitle>
70+
<div
71+
style={{ display: 'flex', justifyContent: 'center', marginTop: '2rem' }}
72+
>
73+
<Input
74+
style={{ width: 600, fontSize: '1.5rem' }}
75+
placeholder="Auth Code"
76+
value={authCode}
77+
onChange={e => {
78+
setAuthCode(e.target.value);
79+
}}
80+
/>
81+
<Button onClick={getJWTToken}>Submit</Button>
82+
</div>
83+
84+
{error && <div style={{ marginTop: '1rem' }}>Error: {error}</div>}
85+
</Container>
86+
);
87+
};
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import React, { useEffect } from 'react';
2+
import { SubscribeForm } from 'app/components/SubscribeForm';
3+
import { useOvermind } from 'app/overmind';
4+
import { Card } from './Card';
5+
import { Title, Subheading } from '../elements';
6+
import { Container, CustomSubHeading } from './elements';
7+
8+
export const PaymentInfo: React.FunctionComponent = () => {
9+
const {
10+
state: {
11+
preferences: {
12+
paymentDetailError,
13+
paymentDetails: paymentDetailsFromHooks,
14+
isLoadingPaymentDetails,
15+
},
16+
},
17+
actions: {
18+
preferences: { paymentDetailsRequested, paymentDetailsUpdated },
19+
},
20+
} = useOvermind();
21+
useEffect(() => {
22+
paymentDetailsRequested();
23+
}, [paymentDetailsRequested]);
24+
25+
const updatePaymentDetails = ({ token }) => {
26+
paymentDetailsUpdated({ token });
27+
};
28+
29+
const paymentDetails = () => {
30+
const { last4, name, brand } = paymentDetailsFromHooks;
31+
if (paymentDetailError)
32+
return <div>An error occurred: {paymentDetailError}</div>;
33+
34+
return (
35+
<div>
36+
<Subheading>Current card</Subheading>
37+
<Card last4={last4} name={name} brand={brand} />
38+
39+
<CustomSubHeading>Update card info</CustomSubHeading>
40+
<SubscribeForm
41+
buttonName="Update"
42+
loadingText="Updating Card Info..."
43+
name={name}
44+
subscribe={updatePaymentDetails}
45+
/>
46+
</div>
47+
);
48+
};
49+
50+
return (
51+
<Container>
52+
<Title>Payment Info</Title>
53+
{isLoadingPaymentDetails ? (
54+
<div>Loading payment details...</div>
55+
) : (
56+
paymentDetails()
57+
)}
58+
</Container>
59+
);
60+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import styled from 'styled-components';
2+
import { Subheading } from '../elements';
23

34
export const Container = styled.div`
45
font-weight: 400;
56
color: rgba(255, 255, 255, 0.6);
67
`;
8+
9+
export const CustomSubHeading = styled(Subheading)`
10+
margin-top: 2rem;
11+
`;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { PaymentInfo } from './PaymentInfo';
2+
3+
export default PaymentInfo;

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

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { Appearance } from './Appearance';
1717
import { EditorSettings } from './EditorPageSettings/EditorSettings';
1818
import { PreviewSettings } from './EditorPageSettings/PreviewSettings';
1919
import { CodeFormatting } from './CodeFormatting';
20-
import { PaymentInfo } from './PaymentInfo';
20+
import PaymentInfo from './PaymentInfo';
2121
import { Integrations } from './Integrations';
2222
import { Badges } from './Badges';
2323
import { Experiments } from './Experiments';

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
import React, { Component } from 'react';
1+
import getTemplateDefinition from '@codesandbox/common/lib/templates';
2+
import codesandbox from '@codesandbox/common/lib/themes/codesandbox.json';
23
import { inject, observer } from 'app/componentConnectors';
3-
import { ThemeProvider } from 'styled-components';
44
import Modal from 'app/components/Modal';
5+
import getVSCodeTheme from 'app/src/app/pages/Sandbox/Editor/utils/get-vscode-theme';
56
import Loadable from 'app/utils/Loadable';
67
import { templateColor } from 'app/utils/template-color';
7-
import getTemplateDefinition from '@codesandbox/common/lib/templates';
8-
import codesandbox from '@codesandbox/common/lib/themes/codesandbox.json';
9-
import getVSCodeTheme from 'app/src/app/pages/Sandbox/Editor/utils/get-vscode-theme';
8+
import React, { Component } from 'react';
9+
import { ThemeProvider } from 'styled-components';
1010

11-
import NewSandbox from './NewSandbox';
12-
import PreferencesModal from './PreferencesModal';
13-
import DeleteSandboxModal from './DeleteSandboxModal';
14-
import DeleteDeploymentModal from './DeleteDeploymentModal';
15-
import ShareModal from './ShareModal';
16-
import DeploymentModal from './DeploymentModal';
17-
import ExportGitHubModal from './ExportGitHubModal';
1811
import CommitModal from './CommitModal';
19-
import PRModal from './PRModal';
20-
import SelectSandboxModal from './SelectSandboxModal';
21-
import SearchDependenciesModal from './SearchDependenciesModal';
12+
import DeleteDeploymentModal from './DeleteDeploymentModal';
2213
import DeleteProfileSandboxModal from './DeleteProfileSandboxModal';
14+
import DeleteSandboxModal from './DeleteSandboxModal';
15+
import DeploymentModal from './DeploymentModal';
2316
import EmptyTrash from './EmptyTrash';
17+
import ExportGitHubModal from './ExportGitHubModal';
18+
import FeedbackModal from './FeedbackModal';
19+
import { ForkServerModal } from './ForkServerModal';
2420
import LiveSessionEnded from './LiveSessionEnded';
2521
import LiveSessionVersionMismatch from './LiveSessionVersionMismatch';
26-
import UploadModal from './UploadModal';
27-
import StorageManagementModal from './StorageManagementModal';
28-
import ForkServerModal from './ForkServerModal';
29-
import PrivacyServerWarning from './PrivacyServerWarning';
30-
import PickSandboxModal from './PickSandboxModal';
31-
import FeedbackModal from './FeedbackModal';
3222
import NetlifyLogs from './NetlifyLogs';
23+
import NewSandbox from './NewSandbox';
24+
import PickSandboxModal from './PickSandboxModal';
25+
import PreferencesModal from './PreferencesModal';
26+
import PrivacyServerWarning from './PrivacyServerWarning';
27+
import PRModal from './PRModal';
28+
import SearchDependenciesModal from './SearchDependenciesModal';
29+
import SelectSandboxModal from './SelectSandboxModal';
30+
import ShareModal from './ShareModal';
3331
// eslint-disable-next-line
3432
import SignInForTemplates from './SignInForTemplates/index.ts';
33+
import StorageManagementModal from './StorageManagementModal';
3534
import { SurveyModal } from './SurveyModal';
35+
import UploadModal from './UploadModal';
3636

3737
const MoveSandboxFolderModal = Loadable(() =>
3838
import('./MoveSandboxFolderModal')

0 commit comments

Comments
 (0)