Sha256: 76ba87f77617fef70e5915b1ec53e154a18c96efa0745804b4118345ac3063b6
Contents?: true
Size: 1.93 KB
Versions: 16
Compression:
Stored size: 1.93 KB
Contents
import { connect } from 'react-redux'; import React from 'react'; import Immutable from 'seamless-immutable'; import PropTypes from 'prop-types'; // eslint-disable-next-line import/no-extraneous-dependencies import DonutChart from 'foremanReact/components/common/charts/DonutChart'; import AggregateStatus from './AggregateStatus/index.js'; import * as JobInvocationActions from '../../redux/actions/jobInvocations'; const colIndexOfMaxValue = columns => columns.reduce((iMax, x, i, arr) => (x[1] > arr[iMax][1] ? i : iMax), 0); class JobInvocationContainer extends React.Component { componentDidMount() { const { startJobInvocationsPolling, data: { url } } = this.props; startJobInvocationsPolling(url); } render() { const { jobInvocations, statuses } = this.props; const iMax = colIndexOfMaxValue(jobInvocations); return ( <div id="job_invocations_chart_container"> <DonutChart data={Immutable.asMutable(jobInvocations)} title={{type: 'percent', secondary: (jobInvocations[iMax] || [])[0]}}/> <AggregateStatus statuses={statuses} /> </div> ); } } const mapStateToProps = (state) => { const { jobInvocations, statuses, } = state.foremanRemoteExecutionReducers.jobInvocations; return { jobInvocations, statuses, }; }; JobInvocationContainer.propTypes = { startJobInvocationsPolling: PropTypes.func, data: PropTypes.shape({ url: PropTypes.string, }), jobInvocations: PropTypes.arrayOf(PropTypes.array), statuses: PropTypes.shape({ cancelled: PropTypes.number, failed: PropTypes.number, pending: PropTypes.number, success: PropTypes.number, }), }; JobInvocationContainer.defaultProps = { startJobInvocationsPolling: JobInvocationActions.startJobInvocationsPolling, data: {}, jobInvocations: [['property', 3, 'color']], statuses: {}, }; export default connect(mapStateToProps, JobInvocationActions)(JobInvocationContainer);
Version data entries
16 entries across 16 versions & 1 rubygems