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 statusYellow from 'images/status_yellow.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 = ''; var singleItem = false; if (this.props.clusterInfos.length) { version = this.props.clusterInfos[0].version; configHash = this.props.clusterInfos[0].config_hash; singleItem = this.props.clusterInfos.length === 1; } 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 (singleItem) { status = ( ); } else { status = ( ); } return ( {status} {clusterInfo.hostname} {versionMismatch} {clusterInfo.version}
{configMismatch} {clusterInfo.config_hash}
{clusterInfo.ipaddress} ); }); return (
{items}
); } }