]> git.arvados.org - arvados.git/blob - services/workbench2/src/views/inactive-panel/inactive-panel.tsx
Merge branch '19378-folder-upload'
[arvados.git] / services / workbench2 / 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 '@mui/material';
9 import { CustomStyleRulesCallback } from 'common/custom-theme';
10 import { WithStyles } from '@mui/styles';
11 import withStyles from '@mui/styles/withStyles';
12 import { ArvadosTheme } from 'common/custom-theme';
13 import { navigateToLinkAccount } from 'store/navigation/navigation-action';
14 import { RootState } from 'store/store';
15 import { sanitizeHTML } from 'common/html-sanitize';
16
17 export type CssRules = 'root' | 'ontop' | 'title';
18
19 const styles: CustomStyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
20     root: {
21         position: 'relative',
22         backgroundColor: theme.palette.grey["200"],
23         background: 'url("arvados-logo-big.png") no-repeat center center',
24         backgroundBlendMode: 'soft-light',
25     },
26     ontop: {
27         zIndex: 10
28     },
29     title: {
30         marginBottom: theme.spacing(6),
31         color: theme.palette.grey["800"]
32     }
33 });
34
35 export interface InactivePanelActionProps {
36     startLinking: () => void;
37 }
38
39 const mapDispatchToProps = (dispatch: Dispatch): InactivePanelActionProps => ({
40     startLinking: () => {
41         dispatch<any>(navigateToLinkAccount);
42     }
43 });
44
45 const mapStateToProps = (state: RootState): InactivePanelStateProps => ({
46     inactivePageText: state.auth.config.clusterConfig.Workbench.InactivePageHTML,
47     loginCluster: state.auth.config.clusterConfig.Login.LoginCluster,
48 });
49
50 export interface InactivePanelStateProps {
51     inactivePageText: string;
52     loginCluster: string;
53 }
54
55 type InactivePanelProps = WithStyles<CssRules> & InactivePanelActionProps & InactivePanelStateProps;
56
57 export const InactivePanelRoot = ({ classes, startLinking, inactivePageText, loginCluster }: InactivePanelProps) =>{
58     const isLoginClusterFederation = loginCluster === "";
59     return <Grid container justifyContent="center" alignItems="center" direction="column" spacing={3}
60         className={classes.root}
61         style={{ marginTop: 56, height: "100%" }}>
62         <Grid item>
63             <Typography>
64                 <span dangerouslySetInnerHTML={{ __html: sanitizeHTML(inactivePageText) }} style={{ margin: "1em" }} />
65             </Typography>
66         </Grid>
67         { !isLoginClusterFederation
68         ? <><Grid item>
69             <Typography align="center">
70             If you would like to use this login to access another account click "Link Account".
71             </Typography>
72         </Grid>
73         <Grid item>
74             <Button className={classes.ontop} color="primary" variant="contained" onClick={() => startLinking()}>
75                 Link Account
76             </Button>
77         </Grid></>
78         : <><Grid item>
79             <Typography align="center">
80                 If you would like to use this login to access another account, please contact your administrator.
81             </Typography>
82         </Grid></> }
83     </Grid >
84 };
85
86 export const InactivePanel = connect(mapStateToProps, mapDispatchToProps)(
87     withStyles(styles)(InactivePanelRoot));