Skip to content

Commit 7f2529a

Browse files
committed
merge master
2 parents f09e743 + 8d0e59e commit 7f2529a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+7334
-4552
lines changed

.babelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
"@babel/preset-env",
4646
"@babel/preset-react"
4747
]
48+
},
49+
"development": {
50+
"plugins": [
51+
"react-hot-loader/babel"
52+
]
4853
}
4954
},
5055
"plugins": [

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# [p5.js Web Editor](https://editor.p5js.org)
22

3-
Hello! The p5.js Web Editor is an in-browser editor for creative coding, specifically for writing [p5.js](https://p5js.org/) sketches. p5.js, a separate [open source project](https://github.com/processing/p5.js), is a JavaScript library with the goal of making coding accessible for artists, designers, educators, and beginners. The web editor shares the same spirit as p5.js–it is designed with the beginner in mind. When using the web editor, you don't need to download or configure anything, you can simply open the website, and start writing code. You can also host your work online and share it with others.
3+
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.
4+
5+
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.
46

57
The p5.js Web Editor is currently in active development, and looking for contributions of any type! Please check out the [contribution guide](https://github.com/processing/p5.js-web-editor/blob/master/.github/CONTRIBUTING.md) for more details.
68

client/components/Nav.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ 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';
9+
import * as toastActions from '../modules/IDE/actions/toast';
910
import * as projectActions from '../modules/IDE/actions/project';
1011
import { setAllAccessibleOutput } from '../modules/IDE/actions/preferences';
1112
import { logoutUser } from '../modules/User/actions';
@@ -93,8 +94,12 @@ class Nav extends React.PureComponent {
9394

9495
handleNew() {
9596
if (!this.props.unsavedChanges) {
97+
this.props.showToast(1500);
98+
this.props.setToastText('Opened new sketch.');
9699
this.props.newProject();
97100
} else if (this.props.warnIfUnsavedChanges()) {
101+
this.props.showToast(1500);
102+
this.props.setToastText('Opened new sketch.');
98103
this.props.newProject();
99104
}
100105
this.setDropdown('none');
@@ -682,6 +687,8 @@ class Nav extends React.PureComponent {
682687

683688
Nav.propTypes = {
684689
newProject: PropTypes.func.isRequired,
690+
showToast: PropTypes.func.isRequired,
691+
setToastText: PropTypes.func.isRequired,
685692
saveProject: PropTypes.func.isRequired,
686693
autosaveProject: PropTypes.func.isRequired,
687694
exportProjectAsZip: PropTypes.func.isRequired,
@@ -738,6 +745,7 @@ function mapStateToProps(state) {
738745
const mapDispatchToProps = {
739746
...IDEActions,
740747
...projectActions,
748+
...toastActions,
741749
logoutUser,
742750
setAllAccessibleOutput
743751
};

client/constants.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const STOP_ACCESSIBLE_OUTPUT = 'STOP_ACCESSIBLE_OUTPUT';
1212
export const OPEN_PREFERENCES = 'OPEN_PREFERENCES';
1313
export const CLOSE_PREFERENCES = 'CLOSE_PREFERENCES';
1414
export const SET_FONT_SIZE = 'SET_FONT_SIZE';
15+
export const SET_LINE_NUMBERS = 'SET_LINE_NUMBERS';
1516

1617
export const AUTH_USER = 'AUTH_USER';
1718
export const UNAUTH_USER = 'UNAUTH_USER';
@@ -124,6 +125,9 @@ export const SET_ASSETS = 'SET_ASSETS';
124125

125126
export const TOGGLE_DIRECTION = 'TOGGLE_DIRECTION';
126127
export const SET_SORTING = 'SET_SORTING';
128+
export const SET_SORT_PARAMS = 'SET_SORT_PARAMS';
129+
export const SET_SEARCH_TERM = 'SET_SEARCH_TERM';
130+
export const CLOSE_SKETCHLIST_MODAL = 'CLOSE_SKETCHLIST_MODAL';
127131

128132
export const START_LOADING = 'START_LOADING';
129133
export const STOP_LOADING = 'STOP_LOADING';

client/images/magnifyingglass.svg

Lines changed: 13 additions & 0 deletions
Loading

client/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import { render } from 'react-dom';
3-
import { hot } from 'react-hot-loader';
3+
import { hot } from 'react-hot-loader/root';
44
import { Provider } from 'react-redux';
55
import { Router, browserHistory } from 'react-router';
66
import configureStore from './store';
@@ -22,7 +22,7 @@ const App = () => (
2222
</Provider>
2323
);
2424

25-
const HotApp = hot(module)(App);
25+
const HotApp = hot(App);
2626

2727
render(
2828
<HotApp />,

client/modules/IDE/actions/assets.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,32 @@
11
import axios from 'axios';
2-
32
import * as ActionTypes from '../../../constants';
3+
import { startLoader, stopLoader } from './loader';
44

55
const __process = (typeof global !== 'undefined' ? global : window).process;
66
const ROOT_URL = __process.env.API_URL;
77

8-
function setAssets(assets) {
8+
function setAssets(assets, totalSize) {
99
return {
1010
type: ActionTypes.SET_ASSETS,
11-
assets
11+
assets,
12+
totalSize
1213
};
1314
}
1415

1516
export function getAssets() {
16-
return (dispatch, getState) => {
17+
return (dispatch) => {
18+
dispatch(startLoader());
1719
axios.get(`${ROOT_URL}/S3/objects`, { withCredentials: true })
1820
.then((response) => {
19-
dispatch(setAssets(response.data.assets));
21+
dispatch(setAssets(response.data.assets, response.data.totalSize));
22+
dispatch(stopLoader());
2023
})
21-
.catch(response => dispatch({
22-
type: ActionTypes.ERROR
23-
}));
24+
.catch(() => {
25+
dispatch({
26+
type: ActionTypes.ERROR
27+
});
28+
dispatch(stopLoader());
29+
});
2430
};
2531
}
2632

client/modules/IDE/actions/preferences.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,24 @@ export function setFontSize(value) {
3232
};
3333
}
3434

35+
export function setLineNumbers(value) {
36+
return (dispatch, getState) => {
37+
dispatch({
38+
type: ActionTypes.SET_LINE_NUMBERS,
39+
value
40+
});
41+
const state = getState();
42+
if (state.user.authenticated) {
43+
const formParams = {
44+
preferences: {
45+
lineNumbers: value
46+
}
47+
};
48+
updatePreferences(formParams, dispatch);
49+
}
50+
};
51+
}
52+
3553
export function setAutosave(value) {
3654
return (dispatch, getState) => {
3755
dispatch({

client/modules/IDE/actions/sorting.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,14 @@ export function toggleDirectionForField(field) {
2525
field
2626
};
2727
}
28+
29+
export function setSearchTerm(searchTerm) {
30+
return {
31+
type: ActionTypes.SET_SEARCH_TERM,
32+
query: searchTerm
33+
};
34+
}
35+
36+
export function resetSearchTerm() {
37+
return setSearchTerm('');
38+
}

client/modules/IDE/components/AssetList.jsx

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@ import { connect } from 'react-redux';
44
import { bindActionCreators } from 'redux';
55
import { Link } from 'react-router';
66
import { Helmet } from 'react-helmet';
7-
87
import prettyBytes from 'pretty-bytes';
98

9+
import Loader from '../../App/components/loader';
1010
import * as AssetActions from '../actions/assets';
1111

12-
1312
class AssetList extends React.Component {
1413
constructor(props) {
1514
super(props);
@@ -23,17 +22,37 @@ class AssetList extends React.Component {
2322
return `p5.js Web Editor | ${this.props.username}'s assets`;
2423
}
2524

25+
hasAssets() {
26+
return !this.props.loading && this.props.assetList.length > 0;
27+
}
28+
29+
renderLoader() {
30+
if (this.props.loading) return <Loader />;
31+
return null;
32+
}
33+
34+
renderEmptyTable() {
35+
if (!this.props.loading && this.props.assetList.length === 0) {
36+
return (<p className="asset-table__empty">No uploaded assets.</p>);
37+
}
38+
return null;
39+
}
40+
2641
render() {
2742
const username = this.props.username !== undefined ? this.props.username : this.props.user.username;
43+
const { assetList, totalSize } = this.props;
2844
return (
2945
<div className="asset-table-container">
46+
{/* Eventually, this copy should be Total / 250 MB Used */}
47+
{this.hasAssets() &&
48+
<p className="asset-table__total">{`${prettyBytes(totalSize)} Total`}</p>
49+
}
3050
<Helmet>
3151
<title>{this.getAssetsTitle()}</title>
3252
</Helmet>
33-
{this.props.assets.length === 0 &&
34-
<p className="asset-table__empty">No uploaded assets.</p>
35-
}
36-
{this.props.assets.length > 0 &&
53+
{this.renderLoader()}
54+
{this.renderEmptyTable()}
55+
{this.hasAssets() &&
3756
<table className="asset-table">
3857
<thead>
3958
<tr>
@@ -44,7 +63,7 @@ class AssetList extends React.Component {
4463
</tr>
4564
</thead>
4665
<tbody>
47-
{this.props.assets.map(asset =>
66+
{assetList.map(asset =>
4867
(
4968
<tr className="asset-table__row" key={asset.key}>
5069
<td>{asset.name}</td>
@@ -65,20 +84,24 @@ AssetList.propTypes = {
6584
username: PropTypes.string
6685
}).isRequired,
6786
username: PropTypes.string.isRequired,
68-
assets: PropTypes.arrayOf(PropTypes.shape({
87+
assetList: PropTypes.arrayOf(PropTypes.shape({
6988
key: PropTypes.string.isRequired,
7089
name: PropTypes.string.isRequired,
7190
url: PropTypes.string.isRequired,
7291
sketchName: PropTypes.string.isRequired,
7392
sketchId: PropTypes.string.isRequired
7493
})).isRequired,
94+
totalSize: PropTypes.number.isRequired,
7595
getAssets: PropTypes.func.isRequired,
96+
loading: PropTypes.bool.isRequired
7697
};
7798

7899
function mapStateToProps(state) {
79100
return {
80101
user: state.user,
81-
assets: state.assets
102+
assetList: state.assets.list,
103+
totalSize: state.assets.totalSize,
104+
loading: state.loading
82105
};
83106
}
84107

0 commit comments

Comments
 (0)