Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use dispatch #431

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/components/molecules/cluster/createForm.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import React from 'react';
import { connect } from 'react-redux';
import TextField from 'material-ui/TextField';
import RaisedButton from 'material-ui/RaisedButton';
import FileInput from 'react-file-reader-input';
import base64 from 'base-64';
import settingsActions from '../../layouts/layout/actions/settings';
import actions from './actions/create';

const mapStateToProps = () => ({});

const CreateClusterForm = React.createClass({
propTypes: {
dispatch: React.PropTypes.func.isRequired,
create: React.PropTypes.func.isRequired,
close: React.PropTypes.func.isRequired,
},

contextTypes: {
Expand All @@ -21,12 +25,12 @@ const CreateClusterForm = React.createClass({

handleSubmit(event) {
event.preventDefault();
this.props.dispatch(actions.create(
this.props.create(
this.state.name,
this.state.sshKey,
this.state.username,
));
this.props.dispatch(settingsActions.close());
);
this.props.close();
},

handleNameChange(event) {
Expand Down Expand Up @@ -79,4 +83,4 @@ const CreateClusterForm = React.createClass({
});


export default CreateClusterForm;
export default connect(mapStateToProps, { ...actions, ...settingsActions })(CreateClusterForm);
2 changes: 2 additions & 0 deletions src/components/molecules/host/createForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import RaisedButton from 'material-ui/RaisedButton';
import settingsActions from '../../layouts/layout/actions/settings';
import actions from './actions/create';

const mapStateToProps = () => ({});

const CreateHostForm = React.createClass({
propTypes: {
clusterId: React.PropTypes.string.isRequired,
Expand Down
19 changes: 12 additions & 7 deletions src/components/molecules/provider/createForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import SelectField from 'material-ui/SelectField';
import RaisedButton from 'material-ui/RaisedButton';
import MenuItem from 'material-ui/MenuItem';
import settingsActions from '../../layouts/layout/actions/settings';
import actions from './actions/create';
import createActions from './actions/create';
import pluginActions from './actions/plugin';

const styles = {
Expand Down Expand Up @@ -38,7 +38,9 @@ export const CreateProviderForm = React.createClass({
providerStatus: React.PropTypes.string,
providerRemove: React.PropTypes.object,
providerRemoveStatus: React.PropTypes.string,
dispatch: React.PropTypes.func.isRequired,
get: React.PropTypes.func.isRequired,
create: React.PropTypes.func.isRequired,
close: React.PropTypes.func.isRequired,
},

getDefaultProps() {
Expand All @@ -55,7 +57,7 @@ export const CreateProviderForm = React.createClass({
},

componentWillMount() {
this.props.dispatch(pluginActions.get());
this.props.get();
},

handleTypeChange(event, key) {
Expand All @@ -73,14 +75,12 @@ export const CreateProviderForm = React.createClass({

handleSubmit(event) {
event.preventDefault();
this.props.dispatch(
actions.create(
this.props.create(
this.props.cluster.id,
this.state.type,
this.state.fields,
)
);
this.props.dispatch(settingsActions.close());
this.props.close();
},

render() {
Expand Down Expand Up @@ -117,5 +117,10 @@ export const CreateProviderForm = React.createClass({
},
});

const actions = {
...settingsActions,
...createActions,
...pluginActions,
};

export default connect(mapStateToProps, actions)(CreateProviderForm);
4 changes: 2 additions & 2 deletions src/components/organisms/service-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const mapStateToProps = state => {
const ServiceList = React.createClass({
propTypes: {
services: React.PropTypes.array,
dispatch: React.PropTypes.func.isRequired,
get: React.PropTypes.func.isRequired,
},

getDefaultProps() {
Expand All @@ -25,7 +25,7 @@ const ServiceList = React.createClass({
},

componentWillMount() {
this.props.dispatch(actions.get());
this.props.get();
},

render() {
Expand Down