Skip to content

Commit c3dd2d7

Browse files
authored
Merge branch 'master' into refactor/editor-files
2 parents fbbe3cf + a62cec4 commit c3dd2d7

File tree

42 files changed

+1047
-1301
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1047
-1301
lines changed

.all-contributorsrc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1396,10 +1396,19 @@
13961396
]
13971397
},
13981398
{
1399-
"login": "ivandevp",
1399+
"login": "ivandevp",
14001400
"name": "Ivan Medina",
14011401
"avatar_url": "https://avatars3.githubusercontent.com/u/9284690?v=4",
14021402
"profile": "https://twitter.com/ivandevp",
1403+
"contributions": [
1404+
"code"
1405+
]
1406+
},
1407+
{
1408+
"login": "Gobinath-Manokaran",
1409+
"name": "Gobinath-Manokaran",
1410+
"avatar_url": "https://avatars2.githubusercontent.com/u/6711914?v=4",
1411+
"profile": "https://github.com/Gobinath-Manokaran",
14031412
"contributions": [
14041413
"code"
14051414
]

.drone.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name: default
44

55
steps:
66
- name: restore node_modules cache
7-
image: codesandbox-cache:1
7+
image: lbogdan/codesandbox-cache-plugin:1
88
settings:
99
restore: true
1010
volumes:
@@ -15,7 +15,7 @@ steps:
1515
- pull_request
1616

1717
- name: install packages
18-
image: node:10.15.3-jessie
18+
image: node:10.16.3-jessie
1919
volumes:
2020
- name: yarn-cache
2121
path: /usr/local/share/.cache/yarn/v4
@@ -26,7 +26,7 @@ steps:
2626
- pull_request
2727

2828
- name: build
29-
image: node:10.15.3-jessie
29+
image: node:10.16.3-jessie
3030
commands:
3131
- export STAGING_BRANCH=pr$DRONE_PULL_REQUEST
3232
- yarn build
@@ -35,7 +35,7 @@ steps:
3535
- pull_request
3636

3737
- name: deploy
38-
image: codesandbox-deploy:1
38+
image: lbogdan/codesandbox-deploy-plugin:1
3939
settings:
4040
domain: &domain build.csb.dev
4141
volumes:
@@ -48,7 +48,7 @@ steps:
4848
- pull_request
4949

5050
- name: create github deployment
51-
image: codesandbox-github-deployment:1
51+
image: lbogdan/github-deployment-plugin:1
5252
settings:
5353
domain: *domain
5454
github_token:
@@ -76,8 +76,23 @@ steps:
7676
- success
7777
- failure
7878

79+
- name: github comment
80+
image: lbogdan/github-comment-plugin:1
81+
settings:
82+
domain: *domain
83+
github_token:
84+
from_secret: github_token
85+
template: |
86+
Build for latest commit https://github.com/{{owner}}/{{repo}}/pull/{{pr}}/commits/{{commitSha}} {{#success}}is at https://pr{{pr}}.{{buildDomain}}/s/new{{/success}}{{^success}}failed{{/success}}.
87+
when:
88+
event:
89+
- pull_request
90+
status:
91+
- success
92+
- failure
93+
7994
- name: rebuild node_modules cache
80-
image: codesandbox-cache:1
95+
image: lbogdan/codesandbox-cache-plugin:1
8196
settings:
8297
rebuild: true
8398
volumes:
@@ -102,6 +117,6 @@ volumes:
102117
path: /root/docker/deployments
103118
---
104119
kind: signature
105-
hmac: 4d9c06dbed6f93871c3a0bb5b80b35e353d8a5254d84ba07c0fb14e4f6ea9ecd
120+
hmac: c3f983c3f9243b3da5fd33f2d22435338c96486e27d5fb569455c05e55353a51
106121

107122
...

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ Thanks goes to these wonderful people
236236
<tr>
237237
<td align="center"><a href="http://hetpatel33.github.io"><img src="https://avatars0.githubusercontent.com/u/13877514?v=4" width="100px;" alt="Het Patel"/><br /><sub><b>Het Patel</b></sub></a><br /><a href="https://github.com/codesandbox/codesandbox-client/commits?author=hetpatel33" title="Code">💻</a></td>
238238
<td align="center"><a href="https://twitter.com/ivandevp"><img src="https://avatars3.githubusercontent.com/u/9284690?v=4" width="100px;" alt="Ivan Medina"/><br /><sub><b>Ivan Medina</b></sub></a><br /><a href="https://github.com/codesandbox/codesandbox-client/commits?author=ivandevp" title="Code">💻</a></td>
239+
<td align="center"><a href="https://github.com/milap1296"><img src="https://avatars2.githubusercontent.com/u/19545730?v=4" width="100px;" alt="milap1296"/><br /><sub><b>milap1296</b></sub></a><br /><a href="https://github.com/codesandbox/codesandbox-client/commits?author=milap1296" title="Code">💻</a></td>
240+
<td align="center"><a href="https://github.com/Gobinath-Manokaran"><img src="https://avatars2.githubusercontent.com/u/6711914?v=4" width="100px;" alt="Gobinath-Manokaran"/><br /><sub><b>Gobinath-Manokaran</b></sub></a><br /><a href="https://github.com/codesandbox/codesandbox-client/commits?author=Gobinath-Manokaran" title="Code">💻</a></td>
239241
</tr>
240242
</table>
241243

15.4 MB
Binary file not shown.

packages/app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@
239239
"@types/react-dom": "^16.8.3",
240240
"@types/react-helmet": "^5.0.11",
241241
"@types/react-icons": "2.2.7",
242+
"@types/react-router-dom": "^4.3.1",
242243
"@types/react-stripe-elements": "^1.3.2",
243244
"@types/resolve": "^0.0.8",
244245
"@types/socket.io-client": "^1.4.32",

packages/app/src/app/overmind/actions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export const connectionChanged: Action<boolean> = ({ state }, connected) => {
6464

6565
type ModalName =
6666
| 'deleteDeployment'
67+
| 'deleteSandbox'
6768
| 'feedback'
6869
| 'forkServerModal'
6970
| 'liveSessionEnded'

packages/app/src/app/overmind/effects/api/index.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ import { client } from 'app/graphql/client';
2323
import { LIST_TEMPLATES } from 'app/pages/Dashboard/queries';
2424

2525
import {
26-
transformSandbox,
2726
transformDirectory,
2827
transformModule,
28+
transformSandbox,
2929
} from '../utils/sandbox';
3030
import apiFactory, { Api, ApiConfig } from './apiFactory';
3131
import {
32-
SandboxAPIResponse,
33-
IModuleAPIResponse,
3432
IDirectoryAPIResponse,
33+
IModuleAPIResponse,
34+
SandboxAPIResponse,
3535
} from './types';
3636

3737
let api: Api;
@@ -154,7 +154,9 @@ export default {
154154
},
155155
});
156156
},
157-
getEnvironmentVariables(sandboxId: string): Promise<EnvironmentVariable[]> {
157+
getEnvironmentVariables(
158+
sandboxId: string
159+
): Promise<{ [key: string]: string }> {
158160
return api.get(
159161
`/sandboxes/${sandboxId}/env`,
160162
{},
@@ -164,7 +166,7 @@ export default {
164166
saveEnvironmentVariable(
165167
sandboxId: string,
166168
environmentVariable: EnvironmentVariable
167-
): Promise<EnvironmentVariable[]> {
169+
): Promise<{ [key: string]: string }> {
168170
return api.post(
169171
`/sandboxes/${sandboxId}/env`,
170172
{
@@ -178,7 +180,7 @@ export default {
178180
deleteEnvironmentVariable(
179181
sandboxId: string,
180182
name: string
181-
): Promise<EnvironmentVariable[]> {
183+
): Promise<{ [key: string]: string }> {
182184
return api.delete(
183185
`/sandboxes/${sandboxId}/env/${name}`,
184186
{},
@@ -451,7 +453,7 @@ export default {
451453
},
452454
createTemplate(
453455
sandboxId: string,
454-
template: CustomTemplate
456+
template: { color: string; description: string; title: string }
455457
): Promise<CustomTemplate> {
456458
return api
457459
.post<{ template: CustomTemplate }>(`/sandboxes/${sandboxId}/templates`, {

packages/app/src/app/overmind/factories.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,16 @@ export const withLoadApp = <T>(
6666
};
6767

6868
export const withOwnedSandbox = <T>(
69-
continueAction: AsyncAction<T>
69+
continueAction: AsyncAction<T>,
70+
cancelAction: AsyncAction<T> = () => Promise.resolve()
7071
): AsyncAction<T> => async (context, payload) => {
7172
const { state, actions } = context;
7273

7374
if (!state.editor.currentSandbox.owned) {
75+
if (state.editor.isForkingSandbox) {
76+
return cancelAction(context, payload);
77+
}
78+
7479
await actions.editor.internal.forkSandbox({
7580
sandboxId: state.editor.currentId,
7681
});
@@ -87,11 +92,10 @@ export const withOwnedSandbox = <T>(
8792
} else if (modalResponse === 'unfreeze') {
8893
state.editor.sessionFrozen = false;
8994
} else if (modalResponse === 'cancel') {
90-
return;
95+
return cancelAction(context, payload);
9196
}
9297
}
9398

94-
// eslint-disable-next-line consistent-return
9599
return continueAction(context, payload);
96100
};
97101

packages/app/src/app/overmind/namespaces/editor/actions.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,13 +152,18 @@ export const codeSaved: AsyncAction<{
152152
code: string;
153153
moduleShortid: string;
154154
cbID: string;
155-
}> = withOwnedSandbox(async ({ actions }, { code, moduleShortid, cbID }) => {
156-
actions.editor.internal.saveCode({
157-
code,
158-
moduleShortid,
159-
cbID,
160-
});
161-
});
155+
}> = withOwnedSandbox(
156+
async ({ actions }, { code, moduleShortid, cbID }) => {
157+
actions.editor.internal.saveCode({
158+
code,
159+
moduleShortid,
160+
cbID,
161+
});
162+
},
163+
async ({ effects }, { cbID }) => {
164+
effects.vscode.callCallbackError(cbID);
165+
}
166+
);
162167

163168
export const codeChanged: Action<{
164169
code: string;

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,15 @@ export const saveCode: AsyncAction<{
166166
effects.notificationToast.warning(error.message);
167167

168168
if (cbID) {
169-
effects.vscode.callCallbackError(cbID);
169+
effects.vscode.callCallbackError(cbID, error.message);
170170
}
171171
}
172172
};
173173

174-
export const updateCurrentTemplate: Action = ({ state, effects }) => {
174+
export const updateCurrentTemplate: AsyncAction = async ({
175+
state,
176+
effects,
177+
}) => {
175178
try {
176179
const currentTemplate = state.editor.currentSandbox.template;
177180
const templateDefinition = getTemplateDefinition(currentTemplate);
@@ -201,7 +204,7 @@ export const updateCurrentTemplate: Action = ({ state, effects }) => {
201204
getTemplateDefinition(newTemplate).isServer
202205
) {
203206
state.editor.currentSandbox.template = newTemplate;
204-
effects.api.saveTemplate(state.editor.currentId, newTemplate);
207+
await effects.api.saveTemplate(state.editor.currentId, newTemplate);
205208
}
206209
}
207210
} catch (e) {

0 commit comments

Comments
 (0)