25e03b8565fefcb31ed97f350128d12baa0335b4
[arvados-workbench2.git] / src / views / inactive-panel / inactive-panel.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React from 'react';
6 import { Dispatch } from 'redux';
7 import { connect } from 'react-redux';
8 import { saveAccountLinkData } from '~/store/link-account-panel/link-account-panel-actions';
9 import { Grid, Typography, Button } from '@material-ui/core';
10 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
11 import { ArvadosTheme } from '~/common/custom-theme';
12 import { LinkAccountType } from '~/models/link-account';
13
14
15 type CssRules = 'root' | 'ontop' | 'title';
16
17 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
18     root: {
19         position: 'relative',
20         backgroundColor: theme.palette.grey["200"],
21         '&::after': {
22             content: `''`,
23             position: 'absolute',
24             top: 0,
25             left: 0,
26             bottom: 0,
27             right: 0,
28             background: 'url("arvados-logo-big.png") no-repeat center center',
29             opacity: 0.2,
30         }
31     },
32     ontop: {
33         zIndex: 10
34     },
35     title: {
36         marginBottom: theme.spacing.unit * 6,
37         color: theme.palette.grey["800"]
38     }
39 });
40
41 export interface InactivePanelActionProps {
42     linkAccount: () => void;
43 }
44
45 const mapDispatchToProps = (dispatch: Dispatch): InactivePanelActionProps => ({
46     linkAccount: () => dispatch<any>(saveAccountLinkData(LinkAccountType.ACCESS_OTHER_ACCOUNT))
47 });
48
49 type InactivePanelProps =  WithStyles<CssRules> & InactivePanelActionProps;
50
51 export const InactivePanel = connect(null, mapDispatchToProps)(withStyles(styles)((({ classes, linkAccount }: InactivePanelProps) =>
52         <Grid container justify="center" alignItems="center" direction="column" spacing={24}
53             className={classes.root}
54             style={{ marginTop: 56, height: "100%" }}>
55             <Grid item>
56                 <Typography variant='h6' align="center" className={classes.title}>
57                     Hi! You're logged in, but...
58                 </Typography>
59             </Grid>
60             <Grid item>
61                 <Typography align="center">
62                     Your account is inactive. An administrator must activate your account before you can get any further.
63                 </Typography>
64             </Grid>
65             <Grid item>
66                 <Typography align="center">
67                     If you would like to use this login to access another account click "Link Account".
68                 </Typography>
69             </Grid>
70             <Grid item>
71                 <Button className={classes.ontop} color="primary" variant="contained" onClick={() => linkAccount()}>
72                     Link Account
73                 </Button>
74             </Grid>
75         </Grid >
76     )));