badguardhome/client/src/install/Setup/Controls.js

114 lines
3.3 KiB
JavaScript
Raw Normal View History

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"
2019-02-07 13:09:12 +00:00
disabled={
this.props.invalid
|| this.props.pristine
|| this.props.install.processingSubmit
}
2019-02-01 16:52:42 +00:00
>
<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() {
2019-02-07 13:09:12 +00:00
const { install } = this.props;
2019-01-18 17:17:48 +00:00
return (
<div className="setup__nav">
2019-02-01 16:52:42 +00:00
<div className="btn-list">
2019-02-07 13:09:12 +00:00
{this.renderPrevButton(install.step)}
{this.renderNextButton(install.step)}
2019-02-01 16:52:42 +00:00
</div>
2019-01-18 17:17:48 +00:00
</div>
);
}
}
Controls.propTypes = {
2019-02-07 13:09:12 +00:00
install: PropTypes.object.isRequired,
2019-01-18 17:17:48 +00:00
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) => {
2019-02-07 13:09:12 +00:00
const { install } = state;
const props = { install };
2019-01-18 17:17:48 +00:00
return props;
};
export default connect(
mapStateToProps,
actionCreators,
)(Controls);