15803: INIT->INIT_USER, CONFIG->SET_CONFIG, remove config reducer
[arvados-workbench2.git] / src / views / login-panel / login-panel.tsx
index 092e50073d0ced0d171b36f6f6290f9c8c053c02..6fe3eee2aeb6a5425615ae9dec713ec6d4b57bb7 100644 (file)
@@ -9,7 +9,6 @@ import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/st
 import { login, authActions } from '~/store/auth/auth-action';
 import { ArvadosTheme } from '~/common/custom-theme';
 import { RootState } from '~/store/store';
-// import * as classNames from 'classnames';
 
 type CssRules = 'root' | 'container' | 'title' | 'content' | 'content__bolder' | 'button';
 
@@ -24,7 +23,6 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
             left: 0,
             bottom: 0,
             right: 0,
-            // background: 'url("arvados-logo-big.png") no-repeat center center',
             opacity: 0.2,
         }
     },
@@ -53,6 +51,7 @@ type LoginPanelProps = DispatchProp<any> & WithStyles<CssRules> & {
     remoteHosts: { [key: string]: string },
     homeCluster: string,
     uuidPrefix: string,
+    loginCluster: string,
     welcomePage: string
 };
 
@@ -61,16 +60,18 @@ export const LoginPanel = withStyles(styles)(
         remoteHosts: state.auth.remoteHosts,
         homeCluster: state.auth.homeCluster,
         uuidPrefix: state.auth.localCluster,
-        welcomePage: state.config.clusterConfig.Workbench.WelcomePageHTML
-    }))(({ classes, dispatch, remoteHosts, homeCluster, uuidPrefix, welcomePage }: LoginPanelProps) =>
+        loginCluster: state.auth.loginCluster,
+        welcomePage: state.auth.config.clusterConfig.Workbench.WelcomePageHTML
+    }))(({ classes, dispatch, remoteHosts, homeCluster, uuidPrefix, loginCluster, welcomePage }: LoginPanelProps) =>
         <Grid container justify="center" alignItems="center"
             className={classes.root}
             style={{ marginTop: 56, overflowY: "auto", height: "100%" }}>
             <Grid item className={classes.container}>
                 <Typography>
-                    <div dangerouslySetInnerHTML={{ __html: welcomePage }} />
+                    <div dangerouslySetInnerHTML={{ __html: welcomePage }} style={{ margin: "1em" }} />
                 </Typography>
-                {Object.keys(remoteHosts).length > 1 &&
+                {Object.keys(remoteHosts).length > 1 && loginCluster === "" &&
+
                     <Typography component="div" align="right">
                         <label>Please select the cluster that hosts your user account:</label>
                         <Select native value={homeCluster} style={{ margin: "1em" }}
@@ -81,10 +82,10 @@ export const LoginPanel = withStyles(styles)(
 
                 <Typography component="div" align="right">
                     <Button variant="contained" color="primary" style={{ margin: "1em" }} className={classes.button}
-                        onClick={() => dispatch(login(uuidPrefix, homeCluster, remoteHosts))}>
-                        Log in to {uuidPrefix}
-                        {uuidPrefix !== homeCluster &&
-                            <span>&nbsp;with user from {homeCluster}</span>}
+                        onClick={() => dispatch(login(uuidPrefix, homeCluster, loginCluster, remoteHosts))}>
+                        Log in
+                       {uuidPrefix !== homeCluster && loginCluster !== homeCluster &&
+                            <span>&nbsp;to {uuidPrefix} with user from {homeCluster}</span>}
                     </Button>
                 </Typography>
             </Grid>