ES6 Plato on Github
Report Home
Summary Display
components/Logbook/Menu/NewlyAvailableEventsDialogue.js
Maintainability
58.19
Lines of code
42
Difficulty
21.15
Estimated Errors
0.19
Function weight
By Complexity
By SLOC
import React from 'react'; import PropTypes from 'prop-types'; import { Glyphicon } from 'react-bootstrap'; class NewlyAvailableEventsDialogue extends React.Component { render() { if (this.props.autorefreshEventList === true) { return null; } else { let { eventCountSinceLastRefresh, onIconClicked, eventCountByPeriodicRefresher } = this.props; let newEventCountSinceLastRefresh = 0; if (eventCountByPeriodicRefresher) { newEventCountSinceLastRefresh = (eventCountByPeriodicRefresher < eventCountSinceLastRefresh) ? 0 : eventCountByPeriodicRefresher - eventCountSinceLastRefresh } if (newEventCountSinceLastRefresh > 0) { return (<div className='btn btn-sm' style={{ color: '#888888' }}> <span>{newEventCountSinceLastRefresh} new log(s) arrived.</span> <Glyphicon onClick={onIconClicked} glyph='refresh' /> </div>) } return null; } } } export default NewlyAvailableEventsDialogue; NewlyAvailableEventsDialogue.proptype = { /** Whether the event list refreshes automatically when a new event has arrived */ autorefreshEventList: PropTypes.bool, /* Total number of event in the logbook known by the client since the last refresh of the event list */ eventCountSinceLastRefresh: PropTypes.number, /* Callback function triggered which the user clicks the icon*/ onIconClicked: PropTypes.func, /* Latest event count as found by the periodic calls to the server */ eventCountByPeriodicRefresher: PropTypes.number }