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, FormControl } 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 },
58 export const LoginPanel = withStyles(styles)(
59 connect((state: RootState) => ({
60 remoteHosts: state.auth.remoteHosts,
61 homeCluster: state.auth.homeCluster,
62 uuidPrefix: state.auth.localCluster
63 }))(({ classes, dispatch, remoteHosts, homeCluster, uuidPrefix }: LoginPanelProps) =>
64 <Grid container justify="center" alignItems="center"
65 className={classes.root}
66 style={{ marginTop: 56, overflowY: "auto" }}>
67 <Grid item className={classes.container}>
68 <Typography variant='h6' align="center" className={classes.title}>
69 Welcome to the Arvados Workbench
71 <Typography className={classes.content}>
72 The "Log in" button below will show you a Google sign-in page.
73 After you assure Google that you want to log in here with your Google account, you will be redirected back here to Arvados Workbench.
75 <Typography className={classes.content}>
76 If you have never used Arvados Workbench before, logging in for the first time will automatically create a new account.
78 <Typography variant='body1' className={classNames(classes.content, classes.content__bolder)}>
79 IMPORTANT: Please keep in mind to store exploratory data only but not any information used for clinical decision making.
81 <Typography className={classes.content}>
82 Arvados Workbench uses your name and email address only for identification, and does not retrieve any other personal information from Google.
85 {Object.keys(remoteHosts).length > 1 &&
86 <Typography component="div" align="right">
87 <label>Please select the cluster that hosts your user account:</label>
88 <Select native value={homeCluster} style={{ margin: "1em" }}
89 onChange={(event) => dispatch(authActions.SET_HOME_CLUSTER(event.target.value))}>
90 {Object.keys(remoteHosts).map((k) => <option key={k} value={k}>{k}</option>)}
94 <Typography component="div" align="right">
95 <Button variant="contained" color="primary" style={{ margin: "1em" }} className={classes.button}
96 onClick={() => dispatch(login(uuidPrefix, remoteHosts[homeCluster]))}>
97 Log in to {uuidPrefix}
98 {uuidPrefix !== homeCluster &&
99 <span> with user from {homeCluster}</span>}