ES6 Plato on Github
Report Home
Summary Display
containers/UserManagementContainer.js
Maintainability
71.36
Lines of code
72
Difficulty
17.84
Estimated Errors
0.49
Function weight
By Complexity
By SLOC
import React, { Component } from 'react'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import { Badge, Panel, Glyphicon } from 'react-bootstrap'; import _ from 'lodash'; import { setBreadCrumbs } from '../actions/breadcrumbs.js'; import 'react-bootstrap-typeahead/css/Typeahead.css'; import Loader from 'react-loader-advanced'; import InstrumentScientistTable from '../components/UserManagement/InstrumentScientistTable.js'; import { fetchInstrumentScientistsBySessionId } from '../actions/instrumentscientists.js'; import BeamlineResposibleForm from '../components/UserManagement/BeamlineResponsibleForm.js'; class UserManagementContainer extends Component { componentDidMount() { this.props.setBreadCrumbs([{ name: 'Manager' }, { name: 'User Management', link: '/usermanagement' }]); this.props.fetchInstrumentScientistsBySessionId(this.props.user.sessionId); } render() { if ((!this.props.user) || (!this.props.user.sessionId)) { return null; } return ( <div style={{ marginBottom: 100 }}> <p class="text-secondary">Beamline managers have access to all data, metadata and the electronic logbooks produced in a beamline</p> <BeamlineResposibleForm fetchInstrumentScientistsBySessionId={this.props.fetchInstrumentScientistsBySessionId} user={this.props.user} instrumentScientists={this.props.instrumentScientists} ></BeamlineResposibleForm> <Panel bsStyle="primary" style={{ marginTop: '30px', marginRight: '30px' }}> <Panel.Heading > <Panel.Title componentClass="h2"> <Glyphicon glyph="user" /> Beamline Managers <Badge> {this.props.instrumentScientists.fetching ? <span style={{ marginLeft: '10px' }} className="glyphicon glyphicon-repeat fast-right-spinner"></span> : this.props.instrumentScientists.data.length}</Badge> </Panel.Title> </Panel.Heading> <Panel.Body> <Loader show={this.props.instrumentScientists.fetching} > <InstrumentScientistTable fetchInstrumentScientistsBySessionId={this.props.fetchInstrumentScientistsBySessionId} user={this.props.user} instrumentScientists={this.props.instrumentScientists.data} ></InstrumentScientistTable> </Loader> </Panel.Body> </Panel> </div>); } } function mapStateToProps(state) { return { user: state.user, instrumentScientists: state.instrumentscientists }; } function mapDispatchToProps(dispatch) { return { setBreadCrumbs: bindActionCreators(setBreadCrumbs, dispatch), fetchInstrumentScientistsBySessionId: bindActionCreators(fetchInstrumentScientistsBySessionId, dispatch) }; } export default connect( mapStateToProps, mapDispatchToProps )(UserManagementContainer);