import React, { Fragment, PureComponent } from 'react'; import { defineMessages, injectIntl } from 'react-intl'; import Styled from './styles'; import { withModalMounter } from '/imports/ui/components/common/modal/service'; import Icon from '/imports/ui/components/connection-status/icon/component'; import SettingsMenuContainer from '/imports/ui/components/settings/container'; const intlMessages = defineMessages({ label: { id: 'app.connection-status.label', description: 'Connection status label', }, settings: { id: 'app.connection-status.settings', description: 'Connection settings label', }, }); class ConnectionStatusIcon extends PureComponent { renderIcon(level = 'normal') { return( ); } openAdjustSettings() { const { closeModal, mountModal, } = this.props; closeModal(); mountModal(); } render() { const { intl, stats, } = this.props; let color; switch (stats) { case 'warning': color = 'success'; break; case 'danger': color = 'warning'; break; case 'critical': color = 'danger'; break; default: color = 'success'; } const level = stats ? stats : 'normal'; return ( {this.renderIcon(level)} {intl.formatMessage(intlMessages.label)} {(level === 'critical' || level === 'danger') ? ( {intl.formatMessage(intlMessages.settings)} ) : ( ) } ); } } export default withModalMounter(injectIntl(ConnectionStatusIcon));