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 _isEmpty from 'lodash/isEmpty'; 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', sorter: d => d.namespace, render: d => { return ( {d.namespace} { _isEmpty(d.errors) ? null : } ); }, }, { title: 'Meshed pods', dataIndex: 'meshedPodsStr', isNumeric: true, }, { title: 'Meshed Status', key: 'meshification', render: row => { const percent = row.meshedPercent.get(); const barType = _isEmpty(row.errors) ? getClassification(row.meshedPods, row.failedPods) : 'warning'; const 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` }
} )}>
); }, }, ]; const MeshedStatusTable = ({ api, tableRows }) => ( d.namespace} /> ); MeshedStatusTable.propTypes = { api: PropTypes.shape({ PrefixedLink: PropTypes.func.isRequired, }).isRequired, tableRows: PropTypes.arrayOf(PropTypes.shape({})), }; MeshedStatusTable.defaultProps = { tableRows: [], }; export default withContext(MeshedStatusTable);