Skip to content

Commit

Permalink
Merge pull request #164 from OpenChemistry/fix-girder-login
Browse files Browse the repository at this point in the history
Fix girder login when using the client from the dev stack
  • Loading branch information
alesgenova authored Feb 4, 2020
2 parents 42bedc7 + 6bb21ff commit 1f2dab1
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import React, {Component} from 'react';
import { ConnectedRouter } from 'connected-react-router';
import { Switch } from 'react-router'
import { connect } from 'react-redux';

import { isNil } from 'lodash-es';

import MoleculeContainer from './containers/molecule';
import CalculationContainer from './containers/calculation';
import {VibrationalModesChartContainer, FreeEnergyChartContainer} from './containers/charts';

import { selectors } from '@openchemistry/redux';
import { auth as authUI, route } from '@openchemistry/girder-ui';

// @material-ui components
Expand Down Expand Up @@ -71,12 +75,14 @@ class App extends Component {
}

render() {
const {classes} = this.props;
const {site, classes} = this.props;

let development = false;
if (!process.env.NODE_ENV || process.env.NODE_ENV === 'development' ||
process.env.REACT_APP_DEPLOYMENT === 'development') {
site === 'development') {
development = true;
}
const nersc = site === 'nersc';

return (
<ConnectedRouter history={history}>
Expand Down Expand Up @@ -137,9 +143,9 @@ class App extends Component {
<route.Private path='/user/:id/molecules' component={Molecules} />
</Switch>

<authUI.LoginOptions girder={development}/>
<authUI.GirderLogin/>
<authUI.NerscLogin/>
<authUI.LoginOptions girder={development} nersc={nersc}/>
{development && <authUI.GirderLogin/>}
{nersc && <authUI.NerscLogin/>}
<authUI.OauthRedirect/>
<JupyterIntegration/>
</div>
Expand All @@ -154,4 +160,20 @@ class App extends Component {
}
}

function mapStateToProps(state, _ownProps) {

const props = {
site: ''
};

const config = selectors.configuration.getConfiguration(state);
if (!isNil(config) && !isNil(config.deployment)) {
props.site = config.deployment.site;
}

return props;
}

App = connect(mapStateToProps)(App)

export default withStyles(appStyles)(App);

0 comments on commit 1f2dab1

Please sign in to comment.