Merge branch '15771-deleting-a-selection-of-files-fails'
[arvados.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 { Grid, Typography, Button } from '@material-ui/core';
9 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
10 import { ArvadosTheme } from '~/common/custom-theme';
11 import { navigateToLinkAccount } from '~/store/navigation/navigation-action';
12 import { RootState } from '~/store/store';
13
14 type CssRules = 'root' | 'ontop' | 'title';
15
16 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
17     root: {
18         position: 'relative',
19         backgroundColor: theme.palette.grey["200"],
20         '&::after': {
21             content: `''`,
22             position: 'absolute',
23             top: 0,
24             left: 0,
25             bottom: 0,
26             right: 0,
27             background: 'url("arvados-logo-big.png") no-repeat center center',
28             opacity: 0.2,
29         }
30     },
31     ontop: {
32         zIndex: 10
33     },
34     title: {
35         marginBottom: theme.spacing.unit * 6,
36         color: theme.palette.grey["800"]
37     }
38 });
39
40 export interface InactivePanelActionProps {
41     startLinking: () => void;
42 }
43
44 const mapDispatchToProps = (dispatch: Dispatch): InactivePanelActionProps => ({
45     startLinking: () => {
46         dispatch<any>(navigateToLinkAccount);
47     }
48 });
49
50 export interface InactivePanelStateProps {
51     inactivePageText: string;
52 }
53
54 type InactivePanelProps = WithStyles<CssRules> & InactivePanelActionProps & InactivePanelStateProps;
55
56 export const InactivePanel = connect((state: RootState) => ({
57     inactivePageText: state.auth.config.clusterConfig.Workbench.InactivePageHTML
58 }), mapDispatchToProps)(withStyles(styles)((({ classes, startLinking, inactivePageText }: InactivePanelProps) =>
59     <Grid container justify="center" alignItems="center" direction="column" spacing={24}
60         className={classes.root}
61         style={{ marginTop: 56, height: "100%" }}>
62         <Grid item>
63             <Typography>
64                 <div dangerouslySetInnerHTML={{ __html: inactivePageText }} style={{ margin: "1em" }} />
65             </Typography>
66         </Grid>
67         <Grid item>
68             <Typography align="center">
69                 If you would like to use this login to access another account click "Link Account".
70             </Typography>
71         </Grid>
72         <Grid item>
73             <Button className={classes.ontop} color="primary" variant="contained" onClick={() => startLinking()}>
74                 Link Account
75             </Button>
76         </Grid>
77     </Grid >
78 )));