Skip to content

Commit 3d2a7be

Browse files
committed
merge master to feature/public-api branch
2 parents 5c54983 + d5dfe39 commit 3d2a7be

File tree

17 files changed

+76
-50
lines changed

17 files changed

+76
-50
lines changed

.github/config.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Configuration for welcome - https://github.com/behaviorbot/welcome
2+
3+
# Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome
4+
5+
# Comment to be posted to on first time issues
6+
newIssueWelcomeComment: >
7+
Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already.
8+
9+
# Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome
10+
11+
# Comment to be posted to on PRs from first time contributors in your repository
12+
newPRWelcomeComment: >
13+
🎉 Thanks for opening this pull request! Please check out our [contributing guidelines](https://github.com/processing/p5.js-web-editor/blob/master/CONTRIBUTING.md) if you haven't already.
14+
15+
# Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge
16+
17+
# Comment to be posted to on pull requests merged by a first time user

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ deploy:
4646

4747
env:
4848
global:
49-
- APP_IMAGE_NAME=p5jswebeditor_app
49+
- APP_IMAGE_NAME=p5js-web-editor_app

client/components/Nav.jsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ class Nav extends React.PureComponent {
131131
}
132132

133133
handleAddFile() {
134-
this.props.newFile();
134+
this.props.newFile(this.props.rootFile.id);
135135
this.setDropdown('none');
136136
}
137137

138138
handleAddFolder() {
139-
this.props.newFolder();
139+
this.props.newFolder(this.props.rootFile.id);
140140
this.setDropdown('none');
141141
}
142142

@@ -174,7 +174,7 @@ class Nav extends React.PureComponent {
174174

175175
handleDownload() {
176176
this.props.autosaveProject();
177-
this.props.exportProjectAsZip(this.props.project.id);
177+
projectActions.exportProjectAsZip(this.props.project.id);
178178
this.setDropdown('none');
179179
}
180180

@@ -694,7 +694,6 @@ Nav.propTypes = {
694694
setToastText: PropTypes.func.isRequired,
695695
saveProject: PropTypes.func.isRequired,
696696
autosaveProject: PropTypes.func.isRequired,
697-
exportProjectAsZip: PropTypes.func.isRequired,
698697
cloneProject: PropTypes.func.isRequired,
699698
user: PropTypes.shape({
700699
authenticated: PropTypes.bool.isRequired,
@@ -725,7 +724,10 @@ Nav.propTypes = {
725724
setAllAccessibleOutput: PropTypes.func.isRequired,
726725
newFile: PropTypes.func.isRequired,
727726
newFolder: PropTypes.func.isRequired,
728-
layout: PropTypes.oneOf(['dashboard', 'project'])
727+
layout: PropTypes.oneOf(['dashboard', 'project']),
728+
rootFile: PropTypes.shape({
729+
id: PropTypes.string.isRequired
730+
}).isRequired
729731
};
730732

731733
Nav.defaultProps = {
@@ -742,7 +744,8 @@ function mapStateToProps(state) {
742744
return {
743745
project: state.project,
744746
user: state.user,
745-
unsavedChanges: state.ide.unsavedChanges
747+
unsavedChanges: state.ide.unsavedChanges,
748+
rootFile: state.files.filter(file => file.name === 'root')[0]
746749
};
747750
}
748751

client/components/__test__/Nav.test.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ describe('Nav', () => {
3939
},
4040
startSketch: jest.fn(),
4141
stopSketch: jest.fn(),
42-
setAllAccessibleOutput: jest.fn()
42+
setAllAccessibleOutput: jest.fn(),
43+
showToast: jest.fn(),
44+
setToastText: jest.fn(),
45+
rootFile: {
46+
id: 'root-file'
47+
}
4348
};
4449
const getWrapper = () => shallow(<NavComponent {...props} />);
4550

client/modules/IDE/actions/files.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,7 @@ export function updateFileContent(id, content) {
4141
export function createFile(formProps) {
4242
return (dispatch, getState) => {
4343
const state = getState();
44-
const selectedFile = state.files.find(file => file.isSelectedFile);
45-
const rootFile = state.files.find(file => file.name === 'root');
46-
let parentId;
47-
if (selectedFile.fileType === 'folder') {
48-
parentId = selectedFile.id;
49-
} else {
50-
parentId = rootFile.id;
51-
}
44+
const { parentId } = state.ide;
5245
if (state.project.id) {
5346
const postParams = {
5447
name: createUniqueName(formProps.name, parentId, state.files),
@@ -99,14 +92,7 @@ export function createFile(formProps) {
9992
export function createFolder(formProps) {
10093
return (dispatch, getState) => {
10194
const state = getState();
102-
const selectedFile = state.files.find(file => file.isSelectedFile);
103-
const rootFile = state.files.find(file => file.name === 'root');
104-
let parentId;
105-
if (selectedFile.fileType === 'folder') {
106-
parentId = selectedFile.id;
107-
} else {
108-
parentId = rootFile.id;
109-
}
95+
const { parentId } = state.ide;
11096
if (state.project.id) {
11197
const postParams = {
11298
name: createUniqueName(formProps.name, parentId, state.files),

client/modules/IDE/actions/ide.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,10 @@ export function resetSelectedFile(previousId) {
6262
};
6363
}
6464

65-
export function newFile() {
65+
export function newFile(parentId) {
6666
return {
67-
type: ActionTypes.SHOW_MODAL
67+
type: ActionTypes.SHOW_MODAL,
68+
parentId
6869
};
6970
}
7071

@@ -122,9 +123,10 @@ export function closeProjectOptions() {
122123
};
123124
}
124125

125-
export function newFolder() {
126+
export function newFolder(parentId) {
126127
return {
127-
type: ActionTypes.SHOW_NEW_FOLDER_MODAL
128+
type: ActionTypes.SHOW_NEW_FOLDER_MODAL,
129+
parentId
128130
};
129131
}
130132

client/modules/IDE/actions/uploader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export function dropzoneSendingCallback(file, xhr, formData) {
8282
Object.keys(file.postData).forEach((key) => {
8383
formData.append(key, file.postData[key]);
8484
});
85-
formData.append('Content-type', '');
85+
formData.append('Content-type', file.type);
8686
formData.append('Content-length', '');
8787
formData.append('acl', 'public-read');
8888
}

client/modules/IDE/components/Editor.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,15 @@ class Editor extends React.Component {
108108
delete this._cm.options.lint.options.errors;
109109

110110
this._cm.setOption('extraKeys', {
111-
Tab: cm => cm.replaceSelection(' '.repeat(INDENTATION_AMOUNT)),
111+
Tab: (cm) => {
112+
// might need to specify and indent more?
113+
const selection = cm.doc.getSelection();
114+
if (selection.length > 0) {
115+
cm.execCommand('indentMore');
116+
} else {
117+
cm.replaceSelection(' '.repeat(INDENTATION_AMOUNT));
118+
}
119+
},
112120
[`${metaKey}-Enter`]: () => null,
113121
[`Shift-${metaKey}-Enter`]: () => null,
114122
[`${metaKey}-F`]: 'findPersistent',
@@ -126,7 +134,7 @@ class Editor extends React.Component {
126134
this.props.clearConsole();
127135
this.props.startRefreshSketch();
128136
}
129-
}, 400));
137+
}, 1000));
130138

131139
this._cm.on('keyup', () => {
132140
const temp = `line ${parseInt((this._cm.getCursor().line) + 1, 10)}`;

client/modules/IDE/components/FileNode.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ export class FileNode extends React.Component {
188188
<button
189189
aria-label="add file"
190190
onClick={() => {
191-
this.props.newFile();
191+
this.props.newFile(this.props.id);
192192
setTimeout(() => this.hideFileOptions(), 0);
193193
}}
194194
onBlur={this.onBlurComponent}
@@ -208,7 +208,7 @@ export class FileNode extends React.Component {
208208
<button
209209
aria-label="add folder"
210210
onClick={() => {
211-
this.props.newFolder();
211+
this.props.newFolder(this.props.id);
212212
setTimeout(() => this.hideFileOptions(), 0);
213213
}}
214214
onBlur={this.onBlurComponent}

client/modules/IDE/components/NewFileModal.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import classNames from 'classnames';
55
import InlineSVG from 'react-inlinesvg';
66
import NewFileForm from './NewFileForm';
77
import FileUploader from './FileUploader';
8+
import { CREATE_FILE_REGEX } from '../../../../server/utils/fileUtils';
89

910
const exitUrl = require('../../../images/exit.svg');
1011

@@ -71,8 +72,8 @@ function validate(formProps) {
7172

7273
if (!formProps.name) {
7374
errors.name = 'Please enter a name';
74-
} else if (!formProps.name.match(/(.+\.js$|.+\.css$|.+\.json$|.+\.txt$|.+\.csv$|.+\.tsv$)/i)) {
75-
errors.name = 'File must be of type JavaScript, CSS, JSON, TXT, CSV, or TSV.';
75+
} else if (!formProps.name.match(CREATE_FILE_REGEX)) {
76+
errors.name = 'Invalid file type. Valid extensions are .js, .css, .json, .txt, .csv, .tsv, .frag, and .vert.';
7677
}
7778

7879
return errors;

0 commit comments

Comments
 (0)