Files
weave-scope/client/app/scripts/components/status.js
David Kaltschmidt 6b445466ef Move JS to ES2015
Refactored mixins into utils

ES2015 module exports

ES2015-style imports

WIP Fixing tests

Fixes tests after es2015 code migrations.

We we're require()ing an ES2015 module[1]. Have to make sure you account
for the .default in this case.

[1] We had to use ES5 `require` in Jest:
(https://github.com/babel/babel-jest/issues/16)
2015-12-01 14:35:22 +01:00

39 lines
1.2 KiB
JavaScript

import React from 'react';
export default class Status extends React.Component {
render() {
let title = '';
let text = 'Trying to reconnect...';
let showWarningIcon = false;
let classNames = 'status sidebar-item';
if (this.props.errorUrl) {
title = `Cannot reach Scope. Make sure the following URL is reachable: ${this.props.errorUrl}`;
classNames += ' status-loading';
showWarningIcon = true;
} else if (!this.props.topologiesLoaded) {
text = 'Loading topologies...';
classNames += ' status-loading';
showWarningIcon = false;
} else if (this.props.websocketClosed) {
classNames += ' status-loading';
showWarningIcon = true;
} else if (this.props.topology) {
const stats = this.props.topology.stats;
text = `${stats.node_count} nodes`;
if (stats.filtered_nodes) {
text = `${text} (${stats.filtered_nodes} filtered)`;
}
classNames += ' status-stats';
showWarningIcon = false;
}
return (
<div className={classNames}>
{showWarningIcon && <span className="status-icon fa fa-exclamation-circle" />}
<span className="status-label" title={title}>{text}</span>
</div>
);
}
}