import BaseTable from './BaseTable.jsx'; import ErrorModal from './ErrorModal.jsx'; import Grid from '@material-ui/core/Grid'; import PropTypes from 'prop-types'; import React from 'react'; import { StyledProgress } from './util/Progress.jsx'; import Tooltip from '@material-ui/core/Tooltip'; import _ from 'lodash'; import { withContext } from './util/AppContext.jsx'; const getClassification = (meshedPodCount, failedPodCount) => { if (failedPodCount > 0) { return "poor"; } else if (meshedPodCount === 0) { return "default"; } else { return "good"; } }; const namespacesColumns = PrefixedLink => [ { title: "Namespace", dataIndex: "namespace", render: d => { return ( {d.namespace} { _.isEmpty(d.errors) ? null : } ); } }, { title: "Meshed pods", dataIndex: "meshedPodsStr", isNumeric: true }, { title: "Meshed Status", key: "meshification", render: row => { let percent = row.meshedPercent.get(); let barType = _.isEmpty(row.errors) ? getClassification(row.meshedPods, row.failedPods) : "warning"; let Progress = StyledProgress(barType); let percentMeshedMsg = ""; if (row.meshedPercent.get() >= 0) { percentMeshedMsg = `(${row.meshedPercent.prettyRate()})`; } return (
{`${row.meshedPods} out of ${row.totalPods} running or pending pods are in the mesh ${percentMeshedMsg}`}
{row.failedPods === 0 ? null :
{ `${row.failedPods} failed pods` }
} )}>
); } } ]; class MeshedStatusTable extends React.Component { render() { return ( d.namespace} /> ); } } MeshedStatusTable.propTypes = { api: PropTypes.shape({ PrefixedLink: PropTypes.func.isRequired }).isRequired, tableRows: PropTypes.arrayOf(PropTypes.shape({})) }; MeshedStatusTable.defaultProps = { tableRows: [] }; export default withContext(MeshedStatusTable);