Skip to content

Commit 731edc9

Browse files
fix: fixes for broken project (#19)
* fix: #codio-16210 broken projects: no save, no reload * chore: bump storage. vm * chore: fix readme * fix: use scratch-storage built files * chore: try local build * chore: bump storage, vm versions * chore: remove extra * chore: bump storage, vm, lint happy
1 parent e9400f7 commit 731edc9

File tree

9 files changed

+119
-56
lines changed

9 files changed

+119
-56
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,5 +308,5 @@ resource development efforts. Donations of any size are appreciated. Thank you!
308308
## Codio
309309
Added `codio-client.js` link to `index.ejs`
310310
WARNING: The build takes too much resources!!!
311-
Build minified client with `export NODE_OPTIONS=--max-old-space-size=4000 export NODE_ENV=production npm run build`
311+
Build minified client with `NODE_ENV=production npm run build`
312312
Upload to S3 `./s3-upload.sh "s3_assets_access_key" "s3_assets_access_secret"`

package-lock.json

Lines changed: 84 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
"redux-mock-store": "1.5.5",
140140
"rimraf": "2.7.1",
141141
"scratch-semantic-release-config": "1.0.16",
142-
"scratch-webpack-configuration": "1.5.1",
142+
"scratch-webpack-configuration": "1.6.0",
143143
"selenium-webdriver": "3.6.0",
144144
"semantic-release": "19.0.5",
145145
"stream-browserify": "3.0.0",

src/components/crash-message/crash-message.jsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,25 @@ const CrashMessage = props => (
4141
/>
4242
</p>
4343
)}
44-
<button
45-
className={styles.reloadButton}
46-
onClick={props.onReload}
47-
>
48-
<FormattedMessage
49-
defaultMessage="Reload"
50-
description="Button to reload the page when page crashes"
51-
id="gui.crashMessage.reload"
52-
/>
53-
</button>
44+
{props.onReload && (
45+
<button
46+
className={styles.reloadButton}
47+
onClick={props.onReload}
48+
>
49+
<FormattedMessage
50+
defaultMessage="Reload"
51+
description="Button to reload the page when page crashes"
52+
id="gui.crashMessage.reload"
53+
/>
54+
</button>
55+
)}
5456
</Box>
5557
</div>
5658
);
5759

5860
CrashMessage.propTypes = {
5961
eventId: PropTypes.string,
60-
onReload: PropTypes.func.isRequired
62+
onReload: PropTypes.func
6163
};
6264

6365
export default CrashMessage;

src/containers/error-boundary.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ class ErrorBoundary extends React.Component {
5050
}
5151

5252
handleReload () {
53-
window.location.replace(window.location.origin + window.location.pathname);
53+
// do nothing. maybe in the future create new default project.
54+
// window.location.replace(window.location.origin + window.location.pathname);
55+
return;
5456
}
5557

5658
render () {
5759
if (this.state.error) {
5860
if (recommendedBrowser()) {
5961
return (
60-
<CrashMessageComponent
61-
onReload={this.handleReload}
62-
/>
62+
<CrashMessageComponent />
6363
);
6464
}
6565
return (<BrowserModalComponent

src/containers/library-item.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ LibraryItem.propTypes = {
157157
md5ext: PropTypes.string // 3.0 library format
158158
})
159159
),
160-
id: PropTypes.number.isRequired,
160+
id: PropTypes.string.isRequired,
161161
insetIconURL: PropTypes.string,
162162
internetConnectionRequired: PropTypes.bool,
163163
isPlaying: PropTypes.bool,

src/lib/project-saver-hoc.jsx

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,12 @@ const ProjectSaverHOC = function (WrappedComponent) {
7070
if (codio) {
7171
codio.loaded()
7272
.then(() => {
73-
codio.subscribe('callSave', () => this.storeProjectToCodio());
73+
codio.subscribe('callSave', () => this.storeProjectToCodio()
74+
.catch(msg => {
75+
/* eslint-disable-next-line no-console */
76+
console.log(`error on save codio project: ${msg}`);
77+
})
78+
);
7479
})
7580
.fail(msg => {
7681
/* eslint-disable-next-line no-console */
@@ -249,31 +254,6 @@ const ProjectSaverHOC = function (WrappedComponent) {
249254
this.props.onSetProjectUnchanged();
250255
});
251256
}
252-
saveCodioFile (data) {
253-
return new Promise((resolve, reject) => {
254-
const {codio} = window;
255-
if (codio) {
256-
codio.loaded()
257-
.then(() => {
258-
const saveFile = codio.getFileName();
259-
window.codio.saveFile(saveFile, data)
260-
.then(resolve)
261-
.fail(msg => {
262-
const err = `saveCodioFile - error saving scratch file: ${msg}`;
263-
/* eslint-disable-next-line no-console */
264-
console.log(err);
265-
reject(new Error(err));
266-
});
267-
})
268-
.fail(msg => {
269-
const err = `codio loaded - error: ${msg}`;
270-
/* eslint-disable-next-line no-console */
271-
console.log(err);
272-
reject(new Error(err));
273-
});
274-
}
275-
});
276-
}
277257
/**
278258
* storeProject:
279259
* @param {number|string|undefined} projectId - defined value will PUT/update; undefined/null will POST/create

test/unit/util/project-saver-hoc.test.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ describe('projectSaverHOC', () => {
299299
expect(mockedShowCreatingAlert).not.toHaveBeenCalled();
300300
});
301301

302-
test('if user saves, inline saving alert should show', () => {
302+
// skipped due to not allowing empty projects (without targets) to save
303+
test.skip('if user saves, inline saving alert should show', () => {
303304
const mockedShowSavingAlert = jest.fn();
304305
const Component = () => <div />;
305306
const WrappedComponent = projectSaverHOC(Component);

webpack.config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ const baseConfig = new ScratchWebpackConfigBuilder(
1414
{
1515
rootPath: path.resolve(__dirname),
1616
enableReact: true,
17-
shouldSplitChunks: false
17+
shouldSplitChunks: false,
18+
publicPath: ''
1819
})
1920
.setTarget('browserslist')
2021
.merge({
@@ -60,6 +61,11 @@ const baseConfig = new ScratchWebpackConfigBuilder(
6061
to: 'static/blocks-media/high-contrast',
6162
force: true
6263
},
64+
{
65+
context: 'node_modules/scratch-storage/dist/web/chunks',
66+
from: '*.{js,js.map}',
67+
to: 'chunks'
68+
},
6369
{
6470
context: 'node_modules/scratch-vm/dist/web',
6571
from: 'extension-worker.{js,js.map}',

0 commit comments

Comments
 (0)