Files
Iris/src/js/components/VersionManager.js

59 lines
1.5 KiB
JavaScript
Raw Normal View History

import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { Link } from 'react-router'
import { createStore, bindActionCreators } from 'redux'
import FontAwesome from 'react-fontawesome'
import * as pusherActions from '../services/pusher/actions'
class VersionManager extends React.Component{
constructor(props) {
super(props);
}
2016-10-31 09:25:15 +13:00
renderUpgradeButton(){
if( this.props.pusher.upgrading ){
return (
2017-02-09 21:23:26 +13:00
<button className="outline" disabled>
<FontAwesome name="circle-o-notch" spin />
&nbsp;
Upgrading
</button>
);
}
if( !this.props.pusher.version.is_root ){
2017-02-09 21:23:26 +13:00
return <button className="outline" disabled>Not running as root</button>
}
if( this.props.pusher.version.upgrade_available ){
2017-02-09 21:23:26 +13:00
return <button className="primary" onClick={() => this.props.pusherActions.startUpgrade()}>Upgrade to { this.props.pusher.version.latest }</button>
}
2017-02-09 21:23:26 +13:00
return <button className="outline" disabled>No updates available</button>
}
render(){
return (
2017-02-07 10:00:29 +13:00
<span className="version-manager">
2016-10-31 09:25:15 +13:00
{ this.renderUpgradeButton() }
2017-02-07 10:00:29 +13:00
<span className="description">{ this.props.pusher.version.current } installed</span>
</span>
);
}
}
const mapStateToProps = (state, ownProps) => {
return state;
}
const mapDispatchToProps = (dispatch) => {
return {
pusherActions: bindActionCreators(pusherActions, dispatch)
}
}
export default connect(mapStateToProps, mapDispatchToProps)(VersionManager)