Skip to content

Commit e6631ea

Browse files
committed
Refactor Toolbar Props - See processing#824
1 parent 74ec1ba commit e6631ea

File tree

2 files changed

+25
-32
lines changed

2 files changed

+25
-32
lines changed

client/modules/IDE/components/Toolbar.jsx

+24-1
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 mapDispatchToPtops = {
207+
...IDEActions,
208+
...preferenceActions,
209+
...projectActions,
210+
};
211+
212+
export default connect(mapStateToProps, mapDispatchToPtops)(Toolbar);

client/modules/IDE/pages/IDEView.jsx

+1-31
Original file line numberDiff line numberDiff line change
@@ -212,30 +212,7 @@ class IDEView extends React.Component {
212212
warnIfUnsavedChanges={this.warnIfUnsavedChanges}
213213
cmController={this.cmController}
214214
/>
215-
<Toolbar
216-
className="Toolbar"
217-
isPlaying={this.props.ide.isPlaying}
218-
stopSketch={this.props.stopSketch}
219-
projectName={this.props.project.name}
220-
setProjectName={this.props.setProjectName}
221-
showEditProjectName={this.props.showEditProjectName}
222-
hideEditProjectName={this.props.hideEditProjectName}
223-
openPreferences={this.props.openPreferences}
224-
preferencesIsVisible={this.props.ide.preferencesIsVisible}
225-
setTextOutput={this.props.setTextOutput}
226-
setGridOutput={this.props.setGridOutput}
227-
setSoundOutput={this.props.setSoundOutput}
228-
owner={this.props.project.owner}
229-
project={this.props.project}
230-
infiniteLoop={this.props.ide.infiniteLoop}
231-
autorefresh={this.props.preferences.autorefresh}
232-
setAutorefresh={this.props.setAutorefresh}
233-
startSketch={this.props.startSketch}
234-
startAccessibleSketch={this.props.startAccessibleSketch}
235-
saveProject={this.props.saveProject}
236-
currentUser={this.props.user.username}
237-
showHelpModal={this.props.showHelpModal}
238-
/>
215+
<Toolbar />
239216
{this.props.ide.preferencesIsVisible &&
240217
<Overlay
241218
title="Settings"
@@ -547,8 +524,6 @@ IDEView.propTypes = {
547524
}),
548525
updatedAt: PropTypes.string
549526
}).isRequired,
550-
setProjectName: PropTypes.func.isRequired,
551-
openPreferences: PropTypes.func.isRequired,
552527
editorAccessibility: PropTypes.shape({
553528
lintMessages: PropTypes.array.isRequired,
554529
}).isRequired,
@@ -604,8 +579,6 @@ IDEView.propTypes = {
604579
collapseConsole: PropTypes.func.isRequired,
605580
deleteFile: PropTypes.func.isRequired,
606581
updateFileName: PropTypes.func.isRequired,
607-
showEditProjectName: PropTypes.func.isRequired,
608-
hideEditProjectName: PropTypes.func.isRequired,
609582
openProjectOptions: PropTypes.func.isRequired,
610583
closeProjectOptions: PropTypes.func.isRequired,
611584
newFolder: PropTypes.func.isRequired,
@@ -627,7 +600,6 @@ IDEView.propTypes = {
627600
route: PropTypes.oneOfType([PropTypes.object, PropTypes.element]).isRequired,
628601
setUnsavedChanges: PropTypes.func.isRequired,
629602
setTheme: PropTypes.func.isRequired,
630-
setAutorefresh: PropTypes.func.isRequired,
631603
endSketchRefresh: PropTypes.func.isRequired,
632604
startRefreshSketch: PropTypes.func.isRequired,
633605
setBlobUrl: PropTypes.func.isRequired,
@@ -641,12 +613,10 @@ IDEView.propTypes = {
641613
hideErrorModal: PropTypes.func.isRequired,
642614
clearPersistedState: PropTypes.func.isRequired,
643615
persistState: PropTypes.func.isRequired,
644-
showHelpModal: PropTypes.func.isRequired,
645616
hideHelpModal: PropTypes.func.isRequired,
646617
showRuntimeErrorWarning: PropTypes.func.isRequired,
647618
hideRuntimeErrorWarning: PropTypes.func.isRequired,
648619
startSketch: PropTypes.func.isRequired,
649-
startAccessibleSketch: PropTypes.func.isRequired
650620
};
651621

652622
function mapStateToProps(state) {

0 commit comments

Comments
 (0)