From 751a9ef3a12c952fe179f256d854d0c4aa37e28e Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Wed, 4 Oct 2017 22:49:07 +0200 Subject: Apply prettier to codebase --- src/pages/App.js | 168 +++++++++++++++++++++++++---------------------- src/pages/Experiments.js | 97 ++++++++++++++------------- src/pages/Home.js | 80 +++++++++++----------- src/pages/NotFound.js | 14 ++-- src/pages/Profile.js | 60 ++++++++--------- src/pages/Simulations.js | 60 ++++++++--------- 6 files changed, 249 insertions(+), 230 deletions(-) (limited to 'src/pages') diff --git a/src/pages/App.js b/src/pages/App.js index 801aefcd..ad201e7d 100644 --- a/src/pages/App.js +++ b/src/pages/App.js @@ -1,11 +1,11 @@ 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"; -import {openSimulationSucceeded} from "../actions/simulations"; -import {resetCurrentDatacenter} from "../actions/topology/building"; +import { connect } from "react-redux"; +import { ShortcutManager } from "react-shortcuts"; +import { openExperimentSucceeded } from "../actions/experiments"; +import { openSimulationSucceeded } from "../actions/simulations"; +import { resetCurrentDatacenter } from "../actions/topology/building"; import ToolPanelComponent from "../components/app/map/controls/ToolPanelComponent"; import LoadingScreen from "../components/app/map/LoadingScreen"; import SimulationSidebarComponent from "../components/app/sidebars/simulation/SimulationSidebarComponent"; @@ -24,92 +24,102 @@ import KeymapConfiguration from "../shortcuts/keymap"; const shortcutManager = new ShortcutManager(KeymapConfiguration); class AppComponent extends React.Component { - static propTypes = { - simulationId: PropTypes.number.isRequired, - inSimulation: PropTypes.bool, - experimentId: PropTypes.number, - simulationName: PropTypes.string, - }; - static childContextTypes = { - shortcuts: PropTypes.object.isRequired - }; + static propTypes = { + simulationId: PropTypes.number.isRequired, + inSimulation: PropTypes.bool, + experimentId: PropTypes.number, + simulationName: PropTypes.string + }; + static childContextTypes = { + shortcuts: PropTypes.object.isRequired + }; - componentDidMount() { - this.props.resetCurrentDatacenter(); - if (this.props.inSimulation) { - this.props.openExperimentSucceeded(this.props.simulationId, this.props.experimentId); - return; - } - this.props.openSimulationSucceeded(this.props.simulationId); + componentDidMount() { + this.props.resetCurrentDatacenter(); + if (this.props.inSimulation) { + this.props.openExperimentSucceeded( + this.props.simulationId, + this.props.experimentId + ); + return; } + this.props.openSimulationSucceeded(this.props.simulationId); + } - getChildContext() { - return { - shortcuts: shortcutManager - } - } + getChildContext() { + return { + shortcuts: shortcutManager + }; + } - render() { - return ( - -
- - {this.props.datacenterIsLoading ? -
- -
: -
- - - - - {this.props.inSimulation ? - : - undefined - } - {this.props.inSimulation ? - : - undefined - } -
- } - - - - - -
-
- ); - } + render() { + return ( + +
+ + {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; - } + 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, - }; + return { + datacenterIsLoading: state.currentDatacenterId === -1, + simulationName + }; }; const mapDispatchToProps = dispatch => { - return { - resetCurrentDatacenter: () => dispatch(resetCurrentDatacenter()), - openSimulationSucceeded: id => dispatch(openSimulationSucceeded(id)), - openExperimentSucceeded: (simulationId, experimentId) => - dispatch(openExperimentSucceeded(simulationId, experimentId)), - }; + return { + resetCurrentDatacenter: () => dispatch(resetCurrentDatacenter()), + openSimulationSucceeded: id => dispatch(openSimulationSucceeded(id)), + openExperimentSucceeded: (simulationId, experimentId) => + dispatch(openExperimentSucceeded(simulationId, experimentId)) + }; }; -const App = connect( - mapStateToProps, - mapDispatchToProps -)(AppComponent); +const App = connect(mapStateToProps, mapDispatchToProps)(AppComponent); export default App; diff --git a/src/pages/Experiments.js b/src/pages/Experiments.js index c56ad5ce..2f73cd7e 100644 --- a/src/pages/Experiments.js +++ b/src/pages/Experiments.js @@ -1,66 +1,75 @@ import PropTypes from "prop-types"; import React from "react"; import DocumentTitle from "react-document-title"; -import {connect} from "react-redux"; -import {fetchExperimentsOfSimulation} from "../actions/experiments"; -import {openSimulationSucceeded} from "../actions/simulations"; +import { connect } from "react-redux"; +import { fetchExperimentsOfSimulation } from "../actions/experiments"; +import { openSimulationSucceeded } from "../actions/simulations"; import AppNavbar from "../components/navigation/AppNavbar"; import ExperimentListContainer from "../containers/experiments/ExperimentListContainer"; import NewExperimentButtonContainer from "../containers/experiments/NewExperimentButtonContainer"; import NewExperimentModal from "../containers/modals/NewExperimentModal"; class ExperimentsComponent extends React.Component { - static propTypes = { - simulationId: PropTypes.number.isRequired, - simulationName: PropTypes.string, - }; + static propTypes = { + simulationId: PropTypes.number.isRequired, + simulationName: PropTypes.string + }; - componentDidMount() { - this.props.storeSimulationId(this.props.simulationId); - this.props.fetchExperimentsOfSimulation(this.props.simulationId); - } + componentDidMount() { + this.props.storeSimulationId(this.props.simulationId); + this.props.fetchExperimentsOfSimulation(this.props.simulationId); + } - render() { - return ( - -
- -
- - -
- -
-
- ); - } + render() { + return ( + +
+ +
+ + +
+ +
+
+ ); + } } const mapStateToProps = state => { - let simulationName = undefined; - if (state.currentSimulationId !== -1 && state.objects.simulation[state.currentSimulationId]) { - simulationName = state.objects.simulation[state.currentSimulationId].name; - } + let simulationName = undefined; + if ( + state.currentSimulationId !== -1 && + state.objects.simulation[state.currentSimulationId] + ) { + simulationName = state.objects.simulation[state.currentSimulationId].name; + } - return { - simulationName, - }; + return { + simulationName + }; }; const mapDispatchToProps = dispatch => { - return { - storeSimulationId: id => dispatch(openSimulationSucceeded(id)), - fetchExperimentsOfSimulation: id => dispatch(fetchExperimentsOfSimulation(id)), - }; + return { + storeSimulationId: id => dispatch(openSimulationSucceeded(id)), + fetchExperimentsOfSimulation: id => + dispatch(fetchExperimentsOfSimulation(id)) + }; }; -const Experiments = connect( - mapStateToProps, - mapDispatchToProps -)(ExperimentsComponent); +const Experiments = connect(mapStateToProps, mapDispatchToProps)( + ExperimentsComponent +); export default Experiments; diff --git a/src/pages/Home.js b/src/pages/Home.js index 03df4dc5..f6479722 100644 --- a/src/pages/Home.js +++ b/src/pages/Home.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React from "react"; import DocumentTitle from "react-document-title"; import ContactSection from "../components/home/ContactSection"; import IntroSection from "../components/home/IntroSection"; @@ -13,48 +13,50 @@ import jQuery from "../util/jquery"; import "./Home.css"; class Home extends React.Component { - state = { - scrollSpySetup: false, - }; + state = { + scrollSpySetup: false + }; - componentDidMount() { - const scrollOffset = 60; - jQuery("#navbar").find("li a").click(function (e) { - if (jQuery(e.target).parents(".auth-links").length > 0) { - return; - } - e.preventDefault(); - jQuery(jQuery(this).attr('href'))[0].scrollIntoView(); - window.scrollBy(0, -scrollOffset); - }); - - if (!this.state.scrollSpySetup) { - jQuery("body").scrollspy({ - target: "#navbar", - offset: scrollOffset - }); - this.setState({scrollSpySetup: true}); + componentDidMount() { + const scrollOffset = 60; + jQuery("#navbar") + .find("li a") + .click(function(e) { + if (jQuery(e.target).parents(".auth-links").length > 0) { + return; } - } + e.preventDefault(); + jQuery(jQuery(this).attr("href"))[0].scrollIntoView(); + window.scrollBy(0, -scrollOffset); + }); - render() { - return ( -
- -
- - - - - - - - - -
-
- ); + if (!this.state.scrollSpySetup) { + jQuery("body").scrollspy({ + target: "#navbar", + offset: scrollOffset + }); + this.setState({ scrollSpySetup: true }); } + } + + render() { + return ( +
+ +
+ + + + + + + + + +
+
+ ); + } } export default Home; diff --git a/src/pages/NotFound.js b/src/pages/NotFound.js index 4120e285..b344e923 100644 --- a/src/pages/NotFound.js +++ b/src/pages/NotFound.js @@ -1,14 +1,14 @@ -import React from 'react'; +import React from "react"; import DocumentTitle from "react-document-title"; import TerminalWindow from "../components/not-found/TerminalWindow"; -import './NotFound.css'; +import "./NotFound.css"; const NotFound = () => ( - -
- -
-
+ +
+ +
+
); export default NotFound; diff --git a/src/pages/Profile.js b/src/pages/Profile.js index 8a418f80..106ec97e 100644 --- a/src/pages/Profile.js +++ b/src/pages/Profile.js @@ -1,42 +1,40 @@ -import React from 'react'; +import React from "react"; import DocumentTitle from "react-document-title"; -import {connect} from "react-redux"; -import {openDeleteProfileModal} from "../actions/modals/profile"; +import { connect } from "react-redux"; +import { openDeleteProfileModal } from "../actions/modals/profile"; import AppNavbar from "../components/navigation/AppNavbar"; import DeleteProfileModal from "../containers/modals/DeleteProfileModal"; -const ProfileContainer = ({onDelete}) => ( - -
- -
- -

- This does not delete your Google account, but simply disconnects it from the OpenDC platform and - deletes any simulation info that is associated with you (simulations you own and any authorizations - you may have on other projects). -

-
- -
-
+const ProfileContainer = ({ onDelete }) => ( + +
+ +
+ +

+ This does not delete your Google account, but simply disconnects it + from the OpenDC platform and deletes any simulation info that is + associated with you (simulations you own and any authorizations you + may have on other projects). +

+
+ +
+
); const mapDispatchToProps = dispatch => { - return { - onDelete: () => dispatch(openDeleteProfileModal()), - }; + return { + onDelete: () => dispatch(openDeleteProfileModal()) + }; }; -const Profile = connect( - undefined, - mapDispatchToProps -)(ProfileContainer); +const Profile = connect(undefined, mapDispatchToProps)(ProfileContainer); export default Profile; diff --git a/src/pages/Simulations.js b/src/pages/Simulations.js index 46b2843c..ecff8fe6 100644 --- a/src/pages/Simulations.js +++ b/src/pages/Simulations.js @@ -1,8 +1,8 @@ -import React from 'react'; +import React from "react"; import DocumentTitle from "react-document-title"; -import {connect} from "react-redux"; -import {openNewSimulationModal} from "../actions/modals/simulations"; -import {fetchAuthorizationsOfCurrentUser} from "../actions/users"; +import { connect } from "react-redux"; +import { openNewSimulationModal } from "../actions/modals/simulations"; +import { fetchAuthorizationsOfCurrentUser } from "../actions/users"; import AppNavbar from "../components/navigation/AppNavbar"; import SimulationFilterPanel from "../components/simulations/FilterPanel"; import NewSimulationModal from "../containers/modals/NewSimulationModal"; @@ -10,37 +10,37 @@ import NewSimulationButtonContainer from "../containers/simulations/NewSimulatio import VisibleSimulationList from "../containers/simulations/VisibleSimulationAuthList"; class SimulationsContainer extends React.Component { - componentDidMount() { - this.props.fetchAuthorizationsOfCurrentUser(); - } + componentDidMount() { + this.props.fetchAuthorizationsOfCurrentUser(); + } - render() { - return ( - -
- -
- - - -
- -
-
- ); - } + render() { + return ( + +
+ +
+ + + +
+ +
+
+ ); + } } const mapDispatchToProps = dispatch => { - return { - fetchAuthorizationsOfCurrentUser: () => dispatch(fetchAuthorizationsOfCurrentUser()), - openNewSimulationModal: () => dispatch(openNewSimulationModal()), - }; + return { + fetchAuthorizationsOfCurrentUser: () => + dispatch(fetchAuthorizationsOfCurrentUser()), + openNewSimulationModal: () => dispatch(openNewSimulationModal()) + }; }; -const Simulations = connect( - undefined, - mapDispatchToProps -)(SimulationsContainer); +const Simulations = connect(undefined, mapDispatchToProps)( + SimulationsContainer +); export default Simulations; -- cgit v1.2.3