Plato on Github
Report Home
src/components/Event/NewButton.js
Maintainability
85.43
Lines of code
41
Difficulty
14.83
Estimated Errors
0.26
Function weight
By Complexity
By SLOC
import React from 'react' import { Well, Button, ButtonToolbar, Glyphicon, Tooltip, OverlayTrigger, Grid, Row, Col, ToggleButtonGroup, ToggleButton } from 'react-bootstrap' import { URL } from '../../api/icat/icatPlus' import { ComboSearch } from 'react-combo-search' import PropTypes from 'prop-types'; import { NEW_EVENT_VISIBLE, } from '../../constants/EventTypes'; /* A React component which renders the 'New' button */ class NewButton extends React.Component { render() { if (this.props.isNewComponentVisible === undefined || this.props.isNewComponentVisible === true) { return (<Button bsSize="small" bsStyle="primary" disabled > <Glyphicon glyph="plus" />New </Button>) } const tooltip = (text) => ( <Tooltip id="tooltip"> {text} </Tooltip> ); // default behavior return (<OverlayTrigger placement="bottom" overlay={tooltip("Create a new event")}> <Button bsSize="small" bsStyle="primary" onClick={() => this.props.onClick(NEW_EVENT_VISIBLE)} disabled={false} > <Glyphicon glyph="plus" /> New </Button> </OverlayTrigger> ) } } export default NewButton; NewButton.propTypes = { /** True when the user has clicked the button which in turn is displaying the new component */ isNewComponentVisible: PropTypes.bool, /** Callback function triggered when the user clicks on the button */ onClick: PropTypes.func, }