Skip to content

Commit 8e4d02b

Browse files
committed
Merge branch 'master' into prototype-common-sync
2 parents e7c9575 + e6648ae commit 8e4d02b

File tree

17 files changed

+237
-436
lines changed

17 files changed

+237
-436
lines changed

packages/app/scripts/deploy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const fetch = require('cross-fetch');
22

3-
fetch('https://deployment-api.lbogdan.ro/image', {
3+
fetch('https://deploy-api.ops.csb.dev/image', {
44
method: 'POST',
55
headers: {
66
'Content-Type': 'application/json',

packages/app/src/app/components/Preview/DevTools/Tests/TestSummary/elements.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import styled, { css } from 'styled-components';
1+
import styled from 'styled-components';
22
import SyncIcon from 'react-icons/lib/go/sync';
33

44
export const Container = styled.div`
@@ -49,13 +49,9 @@ export const TestData = styled.div`
4949
`;
5050

5151
export const SyncIconStyled = styled(SyncIcon)<{ watching: boolean }>`
52-
opacity: 0.7;
53-
color: ${props => props.theme['button.hoverBackground']};
54-
${props =>
55-
props.watching &&
56-
css`
57-
opacity: 1;
58-
`}
52+
&& {
53+
opacity: ${props => (props.watching ? 1 : undefined)};
54+
}
5955
`;
6056

6157
export const Actions = styled.div`
@@ -69,7 +65,6 @@ export const Actions = styled.div`
6965
cursor: pointer;
7066
opacity: 0.8;
7167
color: ${props => props.theme['button.hoverBackground']};
72-
7368
margin-left: 0.5rem;
7469
7570
&:hover {

packages/app/src/app/overmind/effects/zip/create-zip/index.ts

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,6 @@ export async function createDirectoryWithFiles(
196196
);
197197
}
198198

199-
const DEFAULT_IGNORE = ['yarn.lock', 'package-lock.json'];
200-
201199
export async function createZip(
202200
sandbox: Sandbox,
203201
modules: Array<Module>,
@@ -206,7 +204,7 @@ export async function createZip(
206204
useGitIgnore: boolean = false
207205
) {
208206
const zip = new JSZip();
209-
const ignorer = ignore().add(DEFAULT_IGNORE);
207+
const ignorer = ignore();
210208

211209
if (useGitIgnore) {
212210
const gitIgnore = modules.find(
@@ -270,33 +268,39 @@ export async function createZip(
270268
// For the new vue cli we want to use the full promise
271269
promise = fullPromise();
272270
} else {
273-
promise = import(/* webpackChunkName: 'vue-zip' */ './vue-cli').then(
274-
generator =>
275-
generator.default(zip, sandbox, filteredModules, directories)
271+
promise = import(
272+
/* webpackChunkName: 'vue-zip' */ './vue-cli'
273+
).then(generator =>
274+
generator.default(zip, sandbox, filteredModules, directories)
276275
);
277276
}
278277
} catch (e) {
279278
promise = fullPromise();
280279
}
281280
} else if (sandbox.template === preact.name) {
282-
promise = import(/* webpackChunkName: 'preact-zip' */ './preact-cli').then(
283-
generator => generator.default(zip, sandbox, filteredModules, directories)
281+
promise = import(
282+
/* webpackChunkName: 'preact-zip' */ './preact-cli'
283+
).then(generator =>
284+
generator.default(zip, sandbox, filteredModules, directories)
284285
);
285286
} else if (sandbox.template === svelte.name) {
286-
promise = import(/* webpackChunkName: 'svelte-zip' */ './svelte').then(
287-
generator => generator.default(zip, sandbox, filteredModules, directories)
287+
promise = import(
288+
/* webpackChunkName: 'svelte-zip' */ './svelte'
289+
).then(generator =>
290+
generator.default(zip, sandbox, filteredModules, directories)
288291
);
289292
} else {
290293
// If no specific zip generator is found we will default to the full generator
291-
promise = import(/* webpackChunkName: 'full-zip' */ './full').then(
292-
generator =>
293-
generator.default(
294-
zip,
295-
sandbox,
296-
filteredModules,
297-
directories,
298-
downloadBlobs
299-
)
294+
promise = import(
295+
/* webpackChunkName: 'full-zip' */ './full'
296+
).then(generator =>
297+
generator.default(
298+
zip,
299+
sandbox,
300+
filteredModules,
301+
directories,
302+
downloadBlobs
303+
)
300304
);
301305
}
302306

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,9 @@ export const onApiError: Action<ApiError> = (
371371
const result = response.data;
372372

373373
if (result) {
374-
if ('errors' in result) {
374+
if (typeof result === 'string') {
375+
error.message = result;
376+
} else if ('errors' in result) {
375377
const errors = values(result.errors)[0];
376378
if (Array.isArray(errors)) {
377379
if (errors[0]) {

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
import { AxiosError } from 'axios';
2+
import { get } from 'lodash-es';
13
import { Action, AsyncAction } from 'app/overmind';
24
import * as internalActions from './internalActions';
35

46
export const internal = internalActions;
57

8+
const getZeitErrorMessage = (error: AxiosError) =>
9+
get(
10+
error,
11+
'response.data.error.message',
12+
'An unknown error occurred when connecting to ZEIT'
13+
);
14+
615
export const deployWithNetlify: AsyncAction = async ({
716
effects,
817
actions,
@@ -67,9 +76,7 @@ export const getDeploys: AsyncAction = async ({ state, effects }) => {
6776
zeitConfig.name
6877
);
6978
} catch (error) {
70-
effects.notificationToast.error(
71-
'An unknown error occurred when connecting to ZEIT'
72-
);
79+
effects.notificationToast.error(getZeitErrorMessage(error));
7380
}
7481

7582
state.deployment.gettingDeploys = false;
@@ -80,19 +87,16 @@ export const deployClicked: AsyncAction = async ({
8087
effects,
8188
actions,
8289
}) => {
83-
state.deployment.deploying = true;
84-
const zip = await effects.zip.create(state.editor.currentSandbox);
85-
const contents = await effects.jsZip.loadAsync(zip.file);
86-
8790
try {
91+
state.deployment.deploying = true;
92+
const zip = await effects.zip.create(state.editor.currentSandbox);
93+
const contents = await effects.jsZip.loadAsync(zip.file);
8894
state.deployment.url = await effects.zeit.deploy(
8995
contents,
9096
state.editor.currentSandbox
9197
);
9298
} catch (error) {
93-
effects.notificationToast.error(
94-
'An unknown error occurred when connecting to ZEIT'
95-
);
99+
effects.notificationToast.error(getZeitErrorMessage(error));
96100
}
97101

98102
state.deployment.deploying = false;

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -574,13 +574,17 @@ export const previewActionReceived: Action<{
574574

575575
if (newErrors.length !== currentErrors.length) {
576576
state.editor.errors.forEach(error => {
577-
const module = resolveModule(
578-
error.path,
579-
state.editor.currentSandbox.modules,
580-
state.editor.currentSandbox.directories
581-
);
577+
try {
578+
const module = resolveModule(
579+
error.path,
580+
state.editor.currentSandbox.modules,
581+
state.editor.currentSandbox.directories
582+
);
582583

583-
module.errors = [];
584+
module.errors = [];
585+
} catch (e) {
586+
// Module doesn't exist anymore
587+
}
584588
});
585589
state.editor.errors = newErrors;
586590
}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,17 @@ export const recoverFiles: Action = ({ effects, actions, state }) => {
4242
return false;
4343
})
4444
.filter(Boolean);
45+
const numRecoveredFiles = recoveredList.length;
4546

46-
if (recoveredList.length > 0) {
47+
if (numRecoveredFiles > 0) {
4748
effects.analytics.track('Files Recovered', {
48-
fileCount: recoveredList.length,
49+
fileCount: numRecoveredFiles,
4950
});
5051

5152
effects.notificationToast.add({
52-
message: `We recovered ${
53-
recoveredList.length
54-
} unsaved files from a previous session`,
53+
message: `We recovered ${numRecoveredFiles} unsaved ${
54+
numRecoveredFiles > 1 ? 'files' : 'file'
55+
} from a previous session`,
5556
status: NotificationStatus.NOTICE,
5657
});
5758
}

packages/app/src/app/pages/Dashboard/Content/CreateNewSandbox/index.tsx

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,29 @@ export const CreateNewSandbox: FunctionComponent<Props> = ({
8282
setCreating(true);
8383
};
8484

85-
const buttonName = `Create ${mostUsedSandboxTemplate.niceName} Sandbox`;
86-
const mostUsedSandboxComponent = collectionId ? (
87-
<Container
88-
color={mostUsedSandboxTemplate.color}
89-
onClick={() => createSandbox(mostUsedSandboxTemplate)}
90-
ref={ref}
91-
role="button"
92-
tabIndex={0}
93-
>
94-
{buttonName}
95-
</Container>
96-
) : (
97-
<ContainerLink
98-
color={mostUsedSandboxTemplate.color}
99-
to={sandboxUrl({ id: mostUsedSandboxTemplate.shortid })}
100-
>
101-
{buttonName}
102-
</ContainerLink>
103-
);
85+
let mostUsedSandboxComponent = null;
86+
87+
if (mostUsedSandboxTemplate) {
88+
const buttonName = `Create ${mostUsedSandboxTemplate.niceName} Sandbox`;
89+
mostUsedSandboxComponent = collectionId ? (
90+
<Container
91+
color={mostUsedSandboxTemplate.color}
92+
onClick={() => createSandbox(mostUsedSandboxTemplate)}
93+
ref={ref}
94+
role="button"
95+
tabIndex={0}
96+
>
97+
{buttonName}
98+
</Container>
99+
) : (
100+
<ContainerLink
101+
color={mostUsedSandboxTemplate.color}
102+
to={sandboxUrl({ id: mostUsedSandboxTemplate.shortid })}
103+
>
104+
{buttonName}
105+
</ContainerLink>
106+
);
107+
}
104108

105109
const fromRectDOM = ref.current
106110
? ref.current.getBoundingClientRect()

packages/app/src/app/pages/Sandbox/Editor/Header/CollectionInfo/elements.js

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

0 commit comments

Comments
 (0)