Skip to content

Commit cf2ee4f

Browse files
committed
Merge branch 'master' into feature/sketch-list
2 parents cfaa774 + e37926d commit cf2ee4f

File tree

12 files changed

+1067
-1451
lines changed

12 files changed

+1067
-1451
lines changed

.github/CONTRIBUTING.md

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,17 @@ Here are links to all the sections in this document:
66

77
<!-- If you change any of the headings in this document, remember to update the table of contents. -->
88

9-
- [Code of Conduct](#code-of-conduct)
10-
- [How Can I Contribute?](#how-can-i-contribute)
11-
- [First Timers](#first-timers)
12-
- [Want something more challenging](#want-something-more-challenging)
13-
- [Feature Enhancement](#feature-enhancement)
14-
- [Creating a Pull request](#creating-a-pull-request)
15-
- - [Tips](#tips)
9+
- [Contributing to the p5.js Web Editor](#contributing-to-the-p5js-web-editor)
10+
- [Code of Conduct](#code-of-conduct)
11+
- [How Can I Contribute?](#how-can-i-contribute)
12+
- [First Timers](#first-timers)
13+
- [Milestones](#milestones)
14+
- [Project Ideas](#project-ideas)
15+
- [Issue Search and Tagging](#issue-search-and-tagging)
16+
- [Beginning Work](#beginning-work)
17+
- [Contribution Guides](#contribution-guides)
18+
- [Writing Commit Messages](#writing-commit-messages)
19+
- [Tips](#tips)
1620

1721
## Code of Conduct
1822

@@ -23,21 +27,27 @@ Please follow the guidelines mentioned at [CODE OF CONDUCT.md](https://github.co
2327
### First Timers
2428
For first-time contributors or those who want to start with a small task: [check out our list of good first bugs](https://github.com/processing/p5.js-web-editor/labels/good%20first%20issue). First read the github discussion on that issue and find out if there's currently a person working on that or not. If no one is working on it or if there has was one claimed to but has not been active for a while, ask if it is up for grabs. It's okay to not know how to fix an issue and feel free to ask questions about to approach the problem! We are all just here to learn and make something awesome. Someone from the community would help you out and these are great issues for learning about the web editor, its file structure and its development process.
2529

26-
### Want something more challenging
27-
If you're already familiar with the project or would like take on something a little more challenging, please take a look at the [priority: high](https://github.com/processing/p5.js-web-editor/labels/priority%3Ahigh) issues.
30+
### Milestones
31+
A good place to check for tickets to work on is [milestones](https://github.com/processing/p5.js-web-editor/milestones), as miletones have a due date, and will give you a sense of tickets the tickets that maintainers would like to be completed sooner rather than later.
2832

29-
### Feature Enhancement
30-
If you want to work on building new things, please take a look at [type: feature](https://github.com/processing/p5.js-web-editor/labels/type%3Afeature).
33+
### Project Ideas
34+
If you're looking for inspiration for Google Summer of Code or a bigger project, there's a [project list](https://github.com/processing/processing/wiki/Project-List#p5js-web-editor) maintained on the Processing wiki.
3135

32-
If you'd like to work on a bug, please comment on it to let the maintainers know.
33-
If someone else has already commented and taken up that bug, please refrain from working on it and submitting a PR without asking the maintainers as it leads to unnecessary duplication of effort.
36+
### Issue Search and Tagging
37+
If you're looking for issues to work on, a good place to start is with tickets labeled [high priority](https://github.com/processing/p5.js-web-editor/labels/priority%3Ahigh). You can also look for tickets that are [feature enhancements](https://github.com/processing/p5.js-web-editor/labels/type%3Afeature), [bug fixes](https://github.com/processing/p5.js-web-editor/labels/type%3Abug), and a few other tags.
3438

35-
### Contribution guides
39+
If you feel like an issue is tagged incorrectly (e.g. it's low priority and you think it should be high), please update the issue!
40+
41+
### Beginning Work
42+
43+
If you'd like to work on an issue, please comment on it to let the maintainers know. If someone else has already commented and taken up that issue, please refrain from working on it and submitting a PR without asking the maintainers as it leads to unnecessary duplication of effort.
44+
45+
### Contribution Guides
3646

3747
* [https://guides.github.com/activities/hello-world/](https://guides.github.com/activities/hello-world/)
3848
* [https://guides.github.com/activities/forking/](https://guides.github.com/activities/forking/)
3949

40-
## Writing commit messages
50+
## Writing Commit Messages
4151

4252
Good commit messages serve at least three important purposes:
4353

@@ -69,7 +79,6 @@ Structure your commit message like this:
6979
* Always leave the second line blank.
7080
* Be as descriptive as possible in the description. It helps reasoning about the intention of commits and gives more context about why changes happened.
7181

72-
Tips
73-
----
82+
## Tips
7483

7584
* If it seems difficult to summarize what your commit does, it may be because it includes several logical changes or bug fixes, and are better split up into several commits using `git add -p`.

client/components/Nav.jsx

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3-
import { bindActionCreators } from 'redux';
43
import { connect } from 'react-redux';
54
import { withRouter } from 'react-router';
65
import { Link } from 'react-router';
76
import InlineSVG from 'react-inlinesvg';
87
import classNames from 'classnames';
98
import * as IDEActions from '../modules/IDE/actions/ide';
9+
import * as projectActions from '../modules/IDE/actions/project';
10+
import { setAllAccessibleOutput } from '../modules/IDE/actions/preferences';
11+
import { logoutUser } from '../modules/User/actions';
1012

1113
import { metaKeyName, } from '../utils/metaKey';
1214

@@ -155,7 +157,7 @@ class Nav extends React.PureComponent {
155157
<button
156158
onClick={() => {
157159
if (this.props.user.authenticated) {
158-
this.props.saveProject();
160+
this.props.saveProject(this.props.cmController.getContent());
159161
} else {
160162
this.props.showErrorModal('forceAuthentication');
161163
}
@@ -583,7 +585,8 @@ Nav.propTypes = {
583585
tidyCode: PropTypes.func,
584586
showFind: PropTypes.func,
585587
findNext: PropTypes.func,
586-
findPrev: PropTypes.func
588+
findPrev: PropTypes.func,
589+
getContent: PropTypes.func
587590
}),
588591
startSketch: PropTypes.func.isRequired,
589592
stopSketch: PropTypes.func.isRequired,
@@ -600,15 +603,20 @@ Nav.defaultProps = {
600603
cmController: {}
601604
};
602605

603-
function mapDispatchToProps(dispatch) {
604-
return bindActionCreators(
605-
Object.assign(
606-
{},
607-
IDEActions
608-
),
609-
dispatch
610-
);
606+
function mapStateToProps(state) {
607+
return {
608+
project: state.project,
609+
user: state.user,
610+
unsavedChanges: state.ide.unsavedChanges
611+
};
611612
}
612613

613-
export default withRouter(connect(() => ({}), mapDispatchToProps)(Nav));
614+
const mapDispatchToProps = {
615+
...IDEActions,
616+
...projectActions,
617+
logoutUser,
618+
setAllAccessibleOutput
619+
};
620+
621+
export default withRouter(connect(mapStateToProps, mapDispatchToProps)(Nav));
614622
export { Nav as NavComponent };

client/modules/IDE/actions/files.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ function createUniqueName(name, parentId, files) {
2929
return testName;
3030
}
3131

32-
export function updateFileContent(name, content) {
32+
export function updateFileContent(id, content) {
3333
return {
3434
type: ActionTypes.UPDATE_FILE_CONTENT,
35-
name,
35+
id,
3636
content
3737
};
3838
}
@@ -206,7 +206,7 @@ export function hideFolderChildren(id) {
206206
export function setBlobUrl(file, blobURL) {
207207
return {
208208
type: ActionTypes.SET_BLOB_URL,
209-
name: file.name,
209+
id: file.id,
210210
blobURL
211211
};
212212
}

client/modules/IDE/actions/project.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,19 @@ export function clearPersistedState() {
6666
};
6767
}
6868

69-
export function saveProject(autosave = false) {
69+
export function saveProject(selectedFile = null, autosave = false) {
7070
return (dispatch, getState) => {
7171
const state = getState();
7272
if (state.user.id && state.project.owner && state.project.owner.id !== state.user.id) {
7373
return Promise.reject();
7474
}
7575
const formParams = Object.assign({}, state.project);
7676
formParams.files = [...state.files];
77+
if (selectedFile) {
78+
console.log('selected file being updated');
79+
const fileToUpdate = formParams.files.find(file => file.id === selectedFile.id);
80+
fileToUpdate.content = selectedFile.content;
81+
}
7782
if (state.project.id) {
7883
return axios.put(`${ROOT_URL}/projects/${state.project.id}`, formParams, { withCredentials: true })
7984
.then((response) => {
@@ -156,7 +161,7 @@ export function saveProject(autosave = false) {
156161

157162
export function autosaveProject() {
158163
return (dispatch, getState) => {
159-
saveProject(true)(dispatch, getState);
164+
saveProject(null, true)(dispatch, getState);
160165
};
161166
}
162167

client/modules/IDE/components/Editor.jsx

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class Editor extends React.Component {
6969
this.showFind = this.showFind.bind(this);
7070
this.findNext = this.findNext.bind(this);
7171
this.findPrev = this.findPrev.bind(this);
72+
this.getContent = this.getContent.bind(this);
7273
}
7374

7475
componentDidMount() {
@@ -96,7 +97,7 @@ class Editor extends React.Component {
9697
'asi': true,
9798
'eqeqeq': false,
9899
'-W041': false,
99-
'esversion': 6
100+
'esversion': 7
100101
}
101102
}
102103
});
@@ -116,7 +117,7 @@ class Editor extends React.Component {
116117

117118
this._cm.on('change', debounce(() => {
118119
this.props.setUnsavedChanges(true);
119-
this.props.updateFileContent(this.props.file.name, this._cm.getValue());
120+
this.props.updateFileContent(this.props.file.id, this._cm.getValue());
120121
if (this.props.autorefresh && this.props.isPlaying) {
121122
this.props.clearConsole();
122123
this.props.startRefreshSketch();
@@ -144,7 +145,8 @@ class Editor extends React.Component {
144145
tidyCode: this.tidyCode,
145146
showFind: this.showFind,
146147
findNext: this.findNext,
147-
findPrev: this.findPrev
148+
findPrev: this.findPrev,
149+
getContent: this.getContent
148150
});
149151
}
150152

@@ -230,13 +232,24 @@ class Editor extends React.Component {
230232
return mode;
231233
}
232234

233-
initializeDocuments(files) {
234-
this._docs = {};
235-
files.forEach((file) => {
236-
if (file.name !== 'root') {
237-
this._docs[file.id] = CodeMirror.Doc(file.content, this.getFileMode(file.name)); // eslint-disable-line
238-
}
239-
});
235+
getContent() {
236+
const content = this._cm.getValue();
237+
const updatedFile = Object.assign({}, this.props.file, { content });
238+
return updatedFile;
239+
}
240+
241+
findPrev() {
242+
this._cm.focus();
243+
this._cm.execCommand('findPrev');
244+
}
245+
246+
findNext() {
247+
this._cm.focus();
248+
this._cm.execCommand('findNext');
249+
}
250+
251+
showFind() {
252+
this._cm.execCommand('findPersistent');
240253
}
241254

242255
tidyCode() {
@@ -255,18 +268,13 @@ class Editor extends React.Component {
255268
}
256269
}
257270

258-
showFind() {
259-
this._cm.execCommand('findPersistent');
260-
}
261-
262-
findNext() {
263-
this._cm.focus();
264-
this._cm.execCommand('findNext');
265-
}
266-
267-
findPrev() {
268-
this._cm.focus();
269-
this._cm.execCommand('findPrev');
271+
initializeDocuments(files) {
272+
this._docs = {};
273+
files.forEach((file) => {
274+
if (file.name !== 'root') {
275+
this._docs[file.id] = CodeMirror.Doc(file.content, this.getFileMode(file.name)); // eslint-disable-line
276+
}
277+
});
270278
}
271279

272280
toggleEditorOptions() {

client/modules/IDE/components/Toolbar.jsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import PropTypes from 'prop-types';
22
import React from 'react';
3+
import { connect } from 'react-redux';
34
import { Link } from 'react-router';
45
import classNames from 'classnames';
56
import InlineSVG from 'react-inlinesvg';
67

8+
import * as IDEActions from '../actions/ide';
9+
import * as preferenceActions from '../actions/preferences';
10+
import * as projectActions from '../actions/project';
11+
712
const playUrl = require('../../../images/play.svg');
813
const stopUrl = require('../../../images/stop.svg');
914
const preferencesUrl = require('../../../images/preferences.svg');
@@ -186,4 +191,22 @@ Toolbar.defaultProps = {
186191
currentUser: undefined
187192
};
188193

189-
export default Toolbar;
194+
function mapStateToProps(state) {
195+
return {
196+
autorefresh: state.preferences.autorefresh,
197+
currentUser: state.user.username,
198+
infiniteLoop: state.ide.infiniteLoop,
199+
isPlaying: state.ide.isPlaying,
200+
owner: state.project.owner,
201+
preferencesIsVisible: state.ide.preferencesIsVisible,
202+
project: state.project,
203+
};
204+
}
205+
206+
const mapDispatchToProps = {
207+
...IDEActions,
208+
...preferenceActions,
209+
...projectActions,
210+
};
211+
212+
export default connect(mapStateToProps, mapDispatchToProps)(Toolbar);

0 commit comments

Comments
 (0)