19231: Add smaller page sizes (10 and 20 items) to load faster
[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 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 export 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 const mapStateToProps = (state: RootState): InactivePanelStateProps => ({
51     inactivePageText: state.auth.config.clusterConfig.Workbench.InactivePageHTML,
52     isLoginClusterFederation: state.auth.config.clusterConfig.Login.LoginCluster !== '',
53 });
54
55 export interface InactivePanelStateProps {
56     inactivePageText: string;
57     isLoginClusterFederation: boolean;
58 }
59
60 type InactivePanelProps = WithStyles<CssRules> & InactivePanelActionProps & InactivePanelStateProps;
61
62
63 export const InactivePanelRoot = ({ classes, startLinking, inactivePageText, isLoginClusterFederation }: InactivePanelProps) =>
64     <Grid container justify="center" alignItems="center" direction="column" spacing={24}
65         className={classes.root}
66         style={{ marginTop: 56, height: "100%" }}>
67         <Grid item>
68             <Typography>
69                 <span dangerouslySetInnerHTML={{ __html: inactivePageText }} style={{ margin: "1em" }} />
70             </Typography>
71         </Grid>
72         { !isLoginClusterFederation
73         ? <><Grid item>
74             <Typography align="center">
75             If you would like to use this login to access another account click "Link Account".
76             </Typography>
77         </Grid>
78         <Grid item>
79             <Button className={classes.ontop} color="primary" variant="contained" onClick={() => startLinking()}>
80                 Link Account
81             </Button>
82         </Grid></>
83         : <><Grid item>
84             <Typography align="center">
85                 If you would like to use this login to access another account, please contact your administrator.
86             </Typography>
87         </Grid></> }
88     </Grid >;
89
90 export const InactivePanel = connect(mapStateToProps, mapDispatchToProps)(
91     withStyles(styles)(InactivePanelRoot));