SyncWarning store

This commit is contained in:
Jaco Greeff 2017-10-05 15:52:44 +02:00
parent 4f082da02b
commit 0be532640a

View File

@ -16,12 +16,15 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { connect } from 'react-redux'; import { observer } from 'mobx-react';
import StatusIndicator from '@parity/ui/StatusIndicator';
import styles from './syncWarning.css'; import styles from './syncWarning.css';
function SyncWarning ({ className, isOk, health }) { function SyncWarning ({ className }, { api }) {
console.log('SyncWarning', isOk, health); const statusStore = StatusIndicator.Store.get(api);
const isOk = !statusStore.health.overall || (!statusStore.health.overall.isNotReadyYet && statusStore.health.overall.status === 'ok');
if (isOk) { if (isOk) {
return null; return null;
@ -31,7 +34,7 @@ function SyncWarning ({ className, isOk, health }) {
<div className={ className }> <div className={ className }>
<div className={ styles.body }> <div className={ styles.body }>
{ {
health.overall.message.map((message) => ( statusStore.health.overall.message.map((message) => (
<p key={ message }> <p key={ message }>
{ message } { message }
</p> </p>
@ -42,24 +45,12 @@ function SyncWarning ({ className, isOk, health }) {
); );
} }
SyncWarning.propTypes = { SyncWarning.contextTypes = {
className: PropTypes.string, api: PropTypes.object
isOk: PropTypes.bool.isRequired,
health: PropTypes.object.isRequired
}; };
function mapStateToProps (state) { SyncWarning.propTypes = {
const { health } = state.nodeStatus; className: PropTypes.string
const isNotAvailableYet = health.overall.isNotReady; };
const isOk = !isNotAvailableYet && health.overall.status === 'ok';
return { export default observer(SyncWarning);
isOk,
health
};
}
export default connect(
mapStateToProps,
null
)(SyncWarning);