1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { connect, DispatchProp } from 'react-redux';
7 import { Grid, Typography, Button, Select } from '@material-ui/core';
8 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
9 import { login, authActions } from '~/store/auth/auth-action';
10 import { ArvadosTheme } from '~/common/custom-theme';
11 import { RootState } from '~/store/store';
12 import * as classNames from 'classnames';
14 type CssRules = 'root' | 'container' | 'title' | 'content' | 'content__bolder' | 'button';
16 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
19 backgroundColor: theme.palette.grey["200"],
27 background: 'url("arvados-logo-big.png") no-repeat center center',
36 marginBottom: theme.spacing.unit * 6,
37 color: theme.palette.grey["800"]
40 marginBottom: theme.spacing.unit * 3,
42 color: theme.palette.grey["800"]
52 type LoginPanelProps = DispatchProp<any> & WithStyles<CssRules> & {
53 remoteHosts: { [key: string]: string },
59 export const LoginPanel = withStyles(styles)(
60 connect((state: RootState) => ({
61 remoteHosts: state.auth.remoteHosts,
62 homeCluster: state.auth.homeCluster,
63 uuidPrefix: state.auth.localCluster,
64 loginCluster: state.auth.loginCluster
65 }))(({ classes, dispatch, remoteHosts, homeCluster, uuidPrefix, loginCluster }: LoginPanelProps) =>
66 <Grid container justify="center" alignItems="center"
67 className={classes.root}
68 style={{ marginTop: 56, overflowY: "auto", height: "100%" }}>
69 <Grid item className={classes.container}>
70 <Typography variant='h6' align="center" className={classes.title}>
71 Welcome to the Arvados Workbench
73 <Typography className={classes.content}>
74 The "Log in" button below will show you a Google sign-in page.
75 After you assure Google that you want to log in here with your Google account, you will be redirected back here to Arvados Workbench.
77 <Typography className={classes.content}>
78 If you have never used Arvados Workbench before, logging in for the first time will automatically create a new account.
80 <Typography variant='body1' className={classNames(classes.content, classes.content__bolder)}>
81 IMPORTANT: Please keep in mind to store exploratory data only but not any information used for clinical decision making.
83 <Typography className={classes.content}>
84 Arvados Workbench uses your name and email address only for identification, and does not retrieve any other personal information from Google.
87 {Object.keys(remoteHosts).length > 1 && loginCluster === "" &&
88 <Typography component="div" align="right">
89 <label>Please select the cluster that hosts your user account:</label>
90 <Select native value={homeCluster} style={{ margin: "1em" }}
91 onChange={(event) => dispatch(authActions.SET_HOME_CLUSTER(event.target.value))}>
92 {Object.keys(remoteHosts).map((k) => <option key={k} value={k}>{k}</option>)}
96 <Typography component="div" align="right">
97 <Button variant="contained" color="primary" style={{ margin: "1em" }} className={classes.button}
98 onClick={() => dispatch(login(uuidPrefix, homeCluster, loginCluster, remoteHosts))}>
99 Log in to {uuidPrefix}
100 {uuidPrefix !== homeCluster &&
101 <span> with user from {homeCluster}</span>}