From d628e0ac5162bb1baeb16fcf21b688d37bbff758 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Fri, 22 Sep 2017 13:39:50 +0200 Subject: Implement dynamic web page document title change --- src/pages/App.js | 66 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 27 deletions(-) (limited to 'src/pages/App.js') diff --git a/src/pages/App.js b/src/pages/App.js index 8e74bfa5..8f46156b 100644 --- a/src/pages/App.js +++ b/src/pages/App.js @@ -1,5 +1,6 @@ import PropTypes from "prop-types"; import React from "react"; +import DocumentTitle from "react-document-title"; import {connect} from "react-redux"; import {ShortcutManager} from "react-shortcuts"; import {openExperimentSucceeded} from "../actions/experiments"; @@ -27,6 +28,7 @@ class AppComponent extends React.Component { simulationId: PropTypes.number.isRequired, inSimulation: PropTypes.bool, experimentId: PropTypes.number, + simulationName: PropTypes.string, }; static childContextTypes = { shortcuts: PropTypes.object.isRequired @@ -49,40 +51,50 @@ class AppComponent extends React.Component { render() { return ( -
- - {this.props.datacenterIsLoading ? -
- -
: -
- - - - - {this.props.inSimulation ? - : - undefined - } - {this.props.inSimulation ? - : - undefined - } -
- } - - - - - -
+ +
+ + {this.props.datacenterIsLoading ? +
+ +
: +
+ + + + + {this.props.inSimulation ? + : + undefined + } + {this.props.inSimulation ? + : + undefined + } +
+ } + + + + + +
+
); } } const mapStateToProps = state => { + let simulationName = undefined; + if (state.currentSimulationId !== -1 && state.objects.simulation[state.currentSimulationId]) { + simulationName = state.objects.simulation[state.currentSimulationId].name; + } + return { datacenterIsLoading: state.currentDatacenterId === -1, + simulationName, }; }; -- cgit v1.2.3