Skip to content

Commit e83ac7b

Browse files
committed
Merge branch 'master' into login-signup-issue
2 parents 9671cd0 + 33db5fb commit e83ac7b

34 files changed

+1891
-767
lines changed

.github/CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ Don't know where to begin? Here are some suggestions to get started:
3333
- Front end: React/Redux, CSS/Sass, CodeMirror
3434
- Back end: Node, Express, MongoDB, Jest, AWS
3535
- DevOps: Travis CI, Jest, Docker, Kubernetes, AWS
36+
- Documentation
37+
- Translations: Application and documentation
3638
* Use the [p5.js Web Editor](https://editor.p5js.org)! Find a bug? Think of something you think would add to the project? Open an issue.
3739
* Expand an existing issue. Sometimes issues are missing steps to reproduce, or need suggestions for potential solutions. Sometimes they need another voice saying, "this is really important!"
3840
* Try getting the project running locally on your computer by following the [installation steps](./../developer_docs/installation.md).

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
custom: https://processingfoundation.org/support

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# [p5.js Web Editor](https://editor.p5js.org)
22

3+
4+
Documentation is also available in the following languages:
5+
6+
[한국어](https://github.com/processing/p5.js-web-editor/blob/master/translations/ko)
7+
8+
## Welcome! 👋👋🏿👋🏽👋🏻👋🏾👋🏼
9+
310
The p5.js Web Editor is a platform for creative coding, with a focus on making coding accessible for as many people as possible, including artists, designers, educators, beginners, and anyone who wants to learn. Simply by opening the website you can get started writing p5.js sketches without downloading or configuring anything. The editor is designed with simplicity in mind by limiting features and frills. We strive to listen to the community to drive the editor’s development, and to be intentional with every change. The editor is free and open-source.
411

512
We also strive to give the community as much ownership and control as possible. You can download your sketches so that you can edit them locally or host them elsewhere. You can also host your own version of the editor, giving you control over its data.

client/components/Nav.jsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
22
import React from 'react';
33
import { connect } from 'react-redux';
44
import { withRouter } from 'react-router';
5-
import { Link, browserHistory } from 'react-router';
5+
import { Link } from 'react-router';
66
import InlineSVG from 'react-inlinesvg';
77
import classNames from 'classnames';
88
import * as IDEActions from '../modules/IDE/actions/ide';
@@ -167,8 +167,6 @@ class Nav extends React.PureComponent {
167167

168168
handleLogout() {
169169
this.props.logoutUser();
170-
// if you're on the settings page, probably.
171-
browserHistory.push('/');
172170
this.setDropdown('none');
173171
}
174172

@@ -184,7 +182,8 @@ class Nav extends React.PureComponent {
184182
}
185183

186184
handleShare() {
187-
this.props.showShareModal();
185+
const { username } = this.props.params;
186+
this.props.showShareModal(this.props.project.id, this.props.project.name, username);
188187
this.setDropdown('none');
189188
}
190189

@@ -228,7 +227,7 @@ class Nav extends React.PureComponent {
228227

229228
renderDashboardMenu(navDropdownState) {
230229
return (
231-
<ul className="nav__items-left" title="project-menu">
230+
<ul className="nav__items-left">
232231
<li className="nav__item-logo">
233232
<InlineSVG src={logoUrl} alt="p5.js logo" className="svg__logo" />
234233
</li>
@@ -246,7 +245,7 @@ class Nav extends React.PureComponent {
246245

247246
renderProjectMenu(navDropdownState) {
248247
return (
249-
<ul className="nav__items-left" title="project-menu">
248+
<ul className="nav__items-left">
250249
<li className="nav__item-logo">
251250
<InlineSVG src={logoUrl} alt="p5.js logo" className="svg__logo" />
252251
</li>
@@ -717,6 +716,7 @@ Nav.propTypes = {
717716
}).isRequired,
718717
project: PropTypes.shape({
719718
id: PropTypes.string,
719+
name: PropTypes.string,
720720
owner: PropTypes.shape({
721721
id: PropTypes.string
722722
})
@@ -742,7 +742,10 @@ Nav.propTypes = {
742742
layout: PropTypes.oneOf(['dashboard', 'project']),
743743
rootFile: PropTypes.shape({
744744
id: PropTypes.string.isRequired
745-
}).isRequired
745+
}).isRequired,
746+
params: PropTypes.shape({
747+
username: PropTypes.string
748+
})
746749
};
747750

748751
Nav.defaultProps = {
@@ -752,7 +755,10 @@ Nav.defaultProps = {
752755
},
753756
cmController: {},
754757
layout: 'project',
755-
warnIfUnsavedChanges: undefined
758+
warnIfUnsavedChanges: undefined,
759+
params: {
760+
username: undefined
761+
}
756762
};
757763

758764
function mapStateToProps(state) {

client/components/NavBasic.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class NavBasic extends React.PureComponent {
1313
render() {
1414
return (
1515
<nav className="nav" title="main-navigation" ref={(node) => { this.node = node; }}>
16-
<ul className="nav__items-left" title="project-menu">
16+
<ul className="nav__items-left">
1717
<li className="nav__item-logo">
1818
<InlineSVG src={logoUrl} alt="p5.js logo" className="svg__logo" />
1919
</li>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import React from 'react';
2+
import { shallow } from 'enzyme';
3+
import { FileNode } from '../../modules/IDE/components/FileNode';
4+
5+
beforeAll(() => {});
6+
describe('<FileNode />', () => {
7+
let component;
8+
let props = {};
9+
10+
describe('with valid props', () => {
11+
beforeEach(() => {
12+
props = {
13+
...props,
14+
id: '0',
15+
children: [],
16+
name: 'test.jsx',
17+
fileType: 'dunno',
18+
setSelectedFile: jest.fn(),
19+
deleteFile: jest.fn(),
20+
updateFileName: jest.fn(),
21+
resetSelectedFile: jest.fn(),
22+
newFile: jest.fn(),
23+
newFolder: jest.fn(),
24+
showFolderChildren: jest.fn(),
25+
hideFolderChildren: jest.fn(),
26+
canEdit: true,
27+
authenticated: false
28+
};
29+
component = shallow(<FileNode {...props} />);
30+
});
31+
32+
describe('when changing name', () => {
33+
let input;
34+
let renameTriggerButton;
35+
const changeName = (newFileName) => {
36+
renameTriggerButton.simulate('click');
37+
input.simulate('change', { target: { value: newFileName } });
38+
input.simulate('blur');
39+
};
40+
41+
beforeEach(() => {
42+
input = component.find('.sidebar__file-item-input');
43+
renameTriggerButton = component
44+
.find('.sidebar__file-item-option')
45+
.first();
46+
component.setState({ isEditing: true });
47+
});
48+
it('should render', () => expect(component).toBeDefined());
49+
50+
// it('should debug', () => console.log(component.debug()));
51+
52+
describe('to a valid filename', () => {
53+
const newName = 'newname.jsx';
54+
beforeEach(() => changeName(newName));
55+
56+
it('should save the name', () => {
57+
expect(props.updateFileName).toBeCalledWith(props.id, newName);
58+
});
59+
});
60+
61+
describe('to an empty filename', () => {
62+
const newName = '';
63+
beforeEach(() => changeName(newName));
64+
65+
it('should not save the name', () => {
66+
expect(props.updateFileName).not.toHaveBeenCalled();
67+
});
68+
});
69+
});
70+
});
71+
});

client/components/__test__/__snapshots__/Nav.test.jsx.snap

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ exports[`Nav renders correctly 1`] = `
77
>
88
<ul
99
className="nav__items-left"
10-
title="project-menu"
1110
>
1211
<li
1312
className="nav__item-logo"

client/modules/IDE/actions/collections.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import axios from 'axios';
2+
import { browserHistory } from 'react-router';
23
import * as ActionTypes from '../../../constants';
34
import { startLoader, stopLoader } from './loader';
45
import { setToastText, showToast } from './toast';
@@ -47,20 +48,22 @@ export function createCollection(collection) {
4748
});
4849
dispatch(stopLoader());
4950

50-
const collectionName = response.data.name;
51-
dispatch(setToastText(`Created "${collectionName}"`));
51+
const newCollection = response.data;
52+
dispatch(setToastText(`Created "${newCollection.name}"`));
5253
dispatch(showToast(TOAST_DISPLAY_TIME_MS));
5354

54-
return response.data;
55+
const pathname = `/${newCollection.owner.username}/collections/${newCollection.id}`;
56+
const location = { pathname, state: { skipSavingPath: true } };
57+
58+
browserHistory.push(location);
5559
})
5660
.catch((response) => {
61+
console.error('Error creating collection', response.data);
5762
dispatch({
5863
type: ActionTypes.ERROR,
5964
error: response.data
6065
});
6166
dispatch(stopLoader());
62-
63-
return response.data;
6467
});
6568
};
6669
}

client/modules/IDE/actions/files.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,13 @@ export function createFolder(formProps) {
136136
}
137137

138138
export function updateFileName(id, name) {
139-
return {
140-
type: ActionTypes.UPDATE_FILE_NAME,
141-
id,
142-
name
139+
return (dispatch) => {
140+
dispatch(setUnsavedChanges(true));
141+
dispatch({
142+
type: ActionTypes.UPDATE_FILE_NAME,
143+
id,
144+
name
145+
});
143146
};
144147
}
145148

client/modules/IDE/actions/project.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ export function saveProject(selectedFile = null, autosave = false) {
133133
}
134134
const formParams = Object.assign({}, state.project);
135135
formParams.files = [...state.files];
136+
136137
if (selectedFile) {
137138
const fileToUpdate = formParams.files.find(file => file.id === selectedFile.id);
138139
fileToUpdate.content = selectedFile.content;

0 commit comments

Comments
 (0)