import BaseTable from './BaseTable.jsx'; import PropTypes from 'prop-types'; import React from 'react'; import Tooltip from '@material-ui/core/Tooltip'; import { Trans } from '@lingui/macro'; import _get from 'lodash/get'; import _merge from 'lodash/merge'; import classNames from 'classnames'; import { statusClassNames } from './util/theme.js'; import { withStyles } from '@material-ui/core/styles'; const styles = theme => _merge({}, statusClassNames(theme), { statusTableDot: { width: theme.spacing(2), height: theme.spacing(2), minWidth: theme.spacing(2), borderRadius: '50%', display: 'inline-block', marginRight: theme.spacing(1), }, }); const columnConfig = { 'Pod Status': { width: 200, wrapDotsAt: 7, // dots take up more than one line in the table; space them out dotExplanation: status => { return status.value === 'good' ? 'is up and running' : 'has not been started'; }, }, 'Proxy Status': { width: 250, wrapDotsAt: 9, dotExplanation: pod => { const addedStatus = !pod.added ? 'Not in mesh' : 'Added to mesh'; return (
Pod status: {pod.status}
{addedStatus}
); }, }, }; const StatusDot = ({ status, columnName, classes }) => (
{status.name}
{_get(columnConfig, [columnName, 'dotExplanation'])(status)}
Uptime: {status.uptime} ({status.uptimeSec}s)
)}>
 
); StatusDot.propTypes = { columnName: PropTypes.string.isRequired, status: PropTypes.shape({ name: PropTypes.string.isRequired, uptime: PropTypes.string.isRequired, uptimeSec: PropTypes.number.isRequired, value: PropTypes.string.isRequired, }).isRequired, }; const columns = { resourceName: { title: columnTitleDeployment, dataIndex: 'name', }, pods: { title: columnTitlePods, key: 'numEntities', isNumeric: true, render: d => d.pods.length, }, status: (name, classes) => { return { title: columnTitlePodStatus, key: 'status', render: d => { return d.pods.map(status => ( )); }, }; }, }; const StatusTable = ({ classes, statusColumnTitle, data }) => { const tableCols = [ columns.resourceName, columns.pods, columns.status(statusColumnTitle, classes), ]; return ( r.name} /> ); }; StatusTable.propTypes = { data: PropTypes.arrayOf(PropTypes.shape({ name: PropTypes.string.isRequired, pods: PropTypes.arrayOf(PropTypes.object).isRequired, // TODO: What's the real shape here. added: PropTypes.bool, })).isRequired, statusColumnTitle: PropTypes.string.isRequired, }; export default withStyles(styles, { withTheme: true })(StatusTable);