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 } from '@material-ui/core';
8 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
9 import { login } from '~/store/auth/auth-action';
10 import { ArvadosTheme } from '~/common/custom-theme';
11 import { RootState } from '~/store/store';
12 import { getProperty } from '~/store/properties/properties';
13 import { propertiesActions } from '~/store/properties/properties-actions';
14 import * as classNames from 'classnames';
16 type CssRules = 'root' | 'container' | 'title' | 'content' | 'content__bolder' | 'button';
18 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
21 backgroundColor: theme.palette.grey["200"],
29 background: 'url("arvados-logo-big.png") no-repeat center center',
38 marginBottom: theme.spacing.unit * 6,
39 color: theme.palette.grey["800"]
42 marginBottom: theme.spacing.unit * 3,
44 color: theme.palette.grey["800"]
54 type LoginPanelProps = DispatchProp<any> & WithStyles<CssRules> & {
60 export const REMOTE_HOSTS_NAME = 'remoteHosts';
61 export const HOME_CLUSTER_NAME = 'homeCluster';
62 export const setRemoteHosts = (remoteHosts: any) =>
63 propertiesActions.SET_PROPERTY({ key: REMOTE_HOSTS_NAME, value: remoteHosts });
65 export const setHomeCluster = (homeCluster: string) =>
66 propertiesActions.SET_PROPERTY({ key: HOME_CLUSTER_NAME, value: homeCluster });
68 export const LoginPanel = withStyles(styles)(
69 connect((state: RootState) => ({
70 remoteHosts: state.properties.remoteHosts,
71 homeCluster: state.properties.homeCluster,
72 uuidPrefix: state.properties.uuidPrefix
73 }))(({ classes, dispatch, remoteHosts, homeCluster, uuidPrefix }: LoginPanelProps) =>
74 <Grid container direction="column" item xs alignItems="center" justify="center" className={classes.root}>
75 <Grid item className={classes.container}>
76 <Typography variant='h6' align="center" className={classes.title}>
77 Welcome to the Arvados Workbench
79 <Typography className={classes.content}>
80 The "Log in" button below will show you a Google sign-in page.
81 After you assure Google that you want to log in here with your Google account, you will be redirected back here to Arvados Workbench.
83 <Typography className={classes.content}>
84 If you have never used Arvados Workbench before, logging in for the first time will automatically create a new account.
86 <Typography variant='body1' className={classNames(classes.content, classes.content__bolder)}>
87 IMPORTANT: Please keep in mind to store exploratory data only but not any information used for clinical decision making.
89 <Typography className={classes.content}>
90 Arvados Workbench uses your name and email address only for identification, and does not retrieve any other personal information from Google.
93 <Typography className={classes.content}>
96 Choose your home cluster:
97 <select value={homeCluster} onChange={(event) => dispatch(setHomeCluster(event.target.value))}>
98 {Object.keys(remoteHosts).map((k) => <option key={k} value={k}>{k}</option>)}
103 <Typography component="div" align="right">
104 <Button variant="contained" color="primary" className={classes.button} onClick={() => dispatch(login(uuidPrefix, remoteHosts[homeCluster]))}>