mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-04 10:41:14 +00:00
- Also added linter configuration, and make linter fail on error - fixing ES6 errors and added ES6 transformer - gulp target to try local build - linted gulpfile - cant hook into gulp lint yet, because gulp does currently not support ES6 which some rules demand, since gulp cant transpile itself, we have a chicken and egg problem. - ES6 transpiler for test runner - removed old linter config - adapted editorconfig to reflect linter config
78 lines
2.1 KiB
JavaScript
78 lines
2.1 KiB
JavaScript
const React = require('react');
|
|
|
|
const Logo = require('./logo');
|
|
const AppStore = require('../stores/app-store');
|
|
const Groupings = require('./groupings.js');
|
|
const Status = require('./status.js');
|
|
const Topologies = require('./topologies.js');
|
|
const WebapiUtils = require('../utils/web-api-utils');
|
|
const AppActions = require('../actions/app-actions');
|
|
const Details = require('./details');
|
|
const Nodes = require('./nodes');
|
|
const RouterUtils = require('../utils/router-utils');
|
|
|
|
|
|
const ESC_KEY_CODE = 27;
|
|
|
|
function getStateFromStores() {
|
|
return {
|
|
currentTopology: AppStore.getCurrentTopology(),
|
|
connectionState: AppStore.getConnectionState(),
|
|
currentGrouping: AppStore.getCurrentGrouping(),
|
|
selectedNodeId: AppStore.getSelectedNodeId(),
|
|
nodeDetails: AppStore.getNodeDetails(),
|
|
nodes: AppStore.getNodes(),
|
|
topologies: AppStore.getTopologies()
|
|
};
|
|
}
|
|
|
|
|
|
const App = React.createClass({
|
|
|
|
getInitialState: function() {
|
|
return getStateFromStores();
|
|
},
|
|
|
|
componentDidMount: function() {
|
|
AppStore.on(AppStore.CHANGE_EVENT, this.onChange);
|
|
window.addEventListener('keyup', this.onKeyPress);
|
|
|
|
RouterUtils.getRouter().start({hashbang: true});
|
|
WebapiUtils.getTopologies();
|
|
},
|
|
|
|
onChange: function() {
|
|
this.setState(getStateFromStores());
|
|
},
|
|
|
|
onKeyPress: function(ev) {
|
|
if (ev.keyCode === ESC_KEY_CODE) {
|
|
AppActions.hitEsc();
|
|
}
|
|
},
|
|
|
|
render: function() {
|
|
const showingDetails = this.state.selectedNodeId;
|
|
|
|
return (
|
|
<div>
|
|
{showingDetails && <Details nodes={this.state.nodes}
|
|
nodeId={this.state.selectedNodeId}
|
|
details={this.state.nodeDetails} /> }
|
|
|
|
<div className="header">
|
|
<Logo />
|
|
<Topologies topologies={this.state.topologies} currentTopology={this.state.currentTopology} />
|
|
<Groupings active={this.state.currentGrouping} currentTopology={this.state.currentTopology} />
|
|
<Status connectionState={this.state.connectionState} />
|
|
</div>
|
|
|
|
<Nodes nodes={this.state.nodes} />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
});
|
|
|
|
module.exports = App;
|