2019-01-18 17:17:48 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
import { Trans } from 'react-i18next';
|
|
|
|
|
|
|
|
|
|
import * as actionCreators from '../../actions/install';
|
|
|
|
|
|
|
|
|
|
class Controls extends Component {
|
2019-02-01 16:52:42 +00:00
|
|
|
renderPrevButton(step) {
|
|
|
|
|
switch (step) {
|
|
|
|
|
case 2:
|
|
|
|
|
case 3:
|
|
|
|
|
return (
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
className="btn btn-secondary btn-standard btn-lg"
|
|
|
|
|
onClick={this.props.prevStep}
|
|
|
|
|
>
|
|
|
|
|
<Trans>back</Trans>
|
|
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
renderNextButton(step) {
|
2019-01-18 17:17:48 +00:00
|
|
|
switch (step) {
|
|
|
|
|
case 1:
|
|
|
|
|
return (
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
className="btn btn-success btn-standard btn-lg"
|
|
|
|
|
onClick={this.props.nextStep}
|
|
|
|
|
>
|
|
|
|
|
<Trans>get_started</Trans>
|
|
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
case 2:
|
|
|
|
|
case 3:
|
|
|
|
|
return (
|
2019-02-01 16:52:42 +00:00
|
|
|
<button
|
|
|
|
|
type="submit"
|
|
|
|
|
className="btn btn-success btn-standard btn-lg"
|
|
|
|
|
disabled={this.props.invalid || this.props.pristine}
|
|
|
|
|
>
|
|
|
|
|
<Trans>next</Trans>
|
|
|
|
|
</button>
|
2019-01-18 17:17:48 +00:00
|
|
|
);
|
|
|
|
|
case 4:
|
|
|
|
|
return (
|
2019-02-01 16:52:42 +00:00
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
className="btn btn-success btn-standard btn-lg"
|
|
|
|
|
onClick={this.props.nextStep}
|
|
|
|
|
>
|
|
|
|
|
<Trans>next</Trans>
|
|
|
|
|
</button>
|
2019-01-18 17:17:48 +00:00
|
|
|
);
|
|
|
|
|
case 5:
|
|
|
|
|
return (
|
|
|
|
|
<button
|
2019-02-01 16:52:42 +00:00
|
|
|
type="button"
|
2019-01-18 17:17:48 +00:00
|
|
|
className="btn btn-success btn-standard btn-lg"
|
2019-02-04 14:13:59 +00:00
|
|
|
onClick={() => this.props.openDashboard(this.props.address)}
|
2019-01-18 17:17:48 +00:00
|
|
|
>
|
|
|
|
|
<Trans>open_dashboard</Trans>
|
|
|
|
|
</button>
|
|
|
|
|
);
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
return (
|
|
|
|
|
<div className="setup__nav">
|
2019-02-01 16:52:42 +00:00
|
|
|
<div className="btn-list">
|
|
|
|
|
{this.renderPrevButton(this.props.step)}
|
|
|
|
|
{this.renderNextButton(this.props.step)}
|
|
|
|
|
</div>
|
2019-01-18 17:17:48 +00:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Controls.propTypes = {
|
|
|
|
|
step: PropTypes.number.isRequired,
|
|
|
|
|
nextStep: PropTypes.func,
|
|
|
|
|
prevStep: PropTypes.func,
|
2019-02-01 16:52:42 +00:00
|
|
|
openDashboard: PropTypes.func,
|
2019-01-18 17:17:48 +00:00
|
|
|
submitting: PropTypes.bool,
|
2019-01-21 08:55:39 +00:00
|
|
|
invalid: PropTypes.bool,
|
2019-02-01 16:52:42 +00:00
|
|
|
pristine: PropTypes.bool,
|
2019-02-04 14:13:59 +00:00
|
|
|
address: PropTypes.string,
|
2019-01-18 17:17:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => {
|
|
|
|
|
const { step } = state.install;
|
|
|
|
|
const props = { step };
|
|
|
|
|
return props;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default connect(
|
|
|
|
|
mapStateToProps,
|
|
|
|
|
actionCreators,
|
|
|
|
|
)(Controls);
|