ES6 Plato on Github
Report Home
Summary Display
components/Logbook/PublicEventPanel.js
Maintainability
61.20
Lines of code
62
Difficulty
18.10
Estimated Errors
0.39
Function weight
By Complexity
By SLOC
import React from 'react'; import PropTypes from 'prop-types'; import { Panel } from 'react-bootstrap'; import EventFooter from './EventFooter'; import { ORIGINAL_EVENT_VERSION, LATEST_EVENT_VERSION, ANNOTATION } from '../../constants/EventTypes'; import { getOriginalEvent, getPreviousVersionNumber } from '../../helpers/EventHelpers'; import _ from 'lodash'; import EventVersionPanel from './EventVersionPanel'; /** * React component which renders a public event. It is used only when the logbook context has become public */ class PublicEventPanel extends React.Component { render() { let { event } = this.props; if (!this.props.event) { return null }; return ( <Panel bsStyle='primary' style={{ marginBottom: '0px', height: '100%', position: 'relative' }}> <Panel.Heading> <b> Public log details </b> </Panel.Heading> <div style={{ position: 'absolute', top: '41px', bottom: '42px', width: '100%', overflowY: 'scroll', overflowX: 'hidden' }} > <div style={{ padding: '10px' }}> {/* try to show latest version of the event */} {getPreviousVersionNumber(event) === 0 ? <p style={{ fontStyle: 'italic', color: '888888', paddingBottom: '10px' }}>This event has never been commented.</p> : null} {/* Always show the latest version*/} <EventVersionPanel event={event} version={LATEST_EVENT_VERSION} /> {/* Show the original version if it exists for all except annotations */} {!_.isEqual(event.type, ANNOTATION) && getPreviousVersionNumber(event) !== 0 ? <EventVersionPanel event={getOriginalEvent(event)} version={ORIGINAL_EVENT_VERSION} /> : null} </div> </div> <div style={{ position: 'absolute', bottom: '0px', width: '100%' }}> <EventFooter isSaveButtonEnabled={false} isSaveButtonVisible={false} onCancelButtonClicked={() => this.props.onCloseButtonClicked()} cancelButtonLabel='Close' /> </div> </Panel > ) } } PublicEventPanel.propTypes = { /* event to edit. Null when a new event is being created. */ event: PropTypes.object, /* Function triggered when the user clicks on the close button */ onCloseButtonClicked: PropTypes.func, } export default PublicEventPanel;