From 0be532640aba697d99310fe5e26628d41687f1d6 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 5 Oct 2017 15:52:44 +0200 Subject: [PATCH] SyncWarning store --- js/src/SyncWarning/syncWarning.js | 35 ++++++++++++------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/js/src/SyncWarning/syncWarning.js b/js/src/SyncWarning/syncWarning.js index 3da735450..8ca88b7b2 100644 --- a/js/src/SyncWarning/syncWarning.js +++ b/js/src/SyncWarning/syncWarning.js @@ -16,12 +16,15 @@ import React from 'react'; 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'; -function SyncWarning ({ className, isOk, health }) { - console.log('SyncWarning', isOk, health); +function SyncWarning ({ className }, { api }) { + const statusStore = StatusIndicator.Store.get(api); + const isOk = !statusStore.health.overall || (!statusStore.health.overall.isNotReadyYet && statusStore.health.overall.status === 'ok'); if (isOk) { return null; @@ -31,7 +34,7 @@ function SyncWarning ({ className, isOk, health }) {
{ - health.overall.message.map((message) => ( + statusStore.health.overall.message.map((message) => (

{ message }

@@ -42,24 +45,12 @@ function SyncWarning ({ className, isOk, health }) { ); } -SyncWarning.propTypes = { - className: PropTypes.string, - isOk: PropTypes.bool.isRequired, - health: PropTypes.object.isRequired +SyncWarning.contextTypes = { + api: PropTypes.object }; -function mapStateToProps (state) { - const { health } = state.nodeStatus; - const isNotAvailableYet = health.overall.isNotReady; - const isOk = !isNotAvailableYet && health.overall.status === 'ok'; +SyncWarning.propTypes = { + className: PropTypes.string +}; - return { - isOk, - health - }; -} - -export default connect( - mapStateToProps, - null -)(SyncWarning); +export default observer(SyncWarning);