import PropTypes from 'prop-types'; // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. // See License.txt for license information. import React from 'react'; import {FormattedMessage} from 'react-intl'; import * as Utils from 'utils/utils.jsx'; import statusGreen from 'images/status_green.png'; import statusRed from 'images/status_red.png'; export default class ClusterTable extends React.Component { static propTypes = { clusterInfos: PropTypes.array.isRequired, reload: PropTypes.func.isRequired } render() { var versionMismatch = ( ); var configMismatch = ( ); var version = ''; var configHash = ''; if (this.props.clusterInfos.length) { version = this.props.clusterInfos[0].version; configHash = this.props.clusterInfos[0].config_hash; } this.props.clusterInfos.map((clusterInfo) => { if (clusterInfo.version !== version) { versionMismatch = ( ); } if (clusterInfo.config_hash !== configHash) { configMismatch = ( ); } return null; }); var items = this.props.clusterInfos.map((clusterInfo) => { var status = null; if (clusterInfo.hostname === '') { clusterInfo.hostname = Utils.localizeMessage('admin.cluster.unknown', 'unknown'); } if (clusterInfo.version === '') { clusterInfo.version = Utils.localizeMessage('admin.cluster.unknown', 'unknown'); } if (clusterInfo.config_hash === '') { clusterInfo.config_hash = Utils.localizeMessage('admin.cluster.unknown', 'unknown'); } if (clusterInfo.id === '') { clusterInfo.id = Utils.localizeMessage('admin.cluster.unknown', 'unknown'); } if (clusterInfo.is_alive > 0) { status = ( ); } else { status = ( ); } return ( {status} {clusterInfo.hostname} {versionMismatch} {clusterInfo.version}
{configMismatch} {clusterInfo.config_hash}
{clusterInfo.internode_url}
{clusterInfo.id}
); }); return (
{items}
); } }