Merge branch '18028-all-procs-context-menu'. Closes #18028
[arvados-workbench2.git] / src / views / inactive-panel / inactive-panel.tsx
index 8d53a21ecaa060fd659d6c92ac7d9e4f83e6b692..8a7c7928933925e77462d7d8b5e4e8d0875bbbdd 100644 (file)
@@ -2,16 +2,16 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as React from 'react';
+import React from 'react';
 import { Dispatch } from 'redux';
 import { connect } from 'react-redux';
 import { Grid, Typography, Button } from '@material-ui/core';
 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
-import { ArvadosTheme } from '~/common/custom-theme';
-import { navigateToLinkAccount } from '~/store/navigation/navigation-action';
+import { ArvadosTheme } from 'common/custom-theme';
+import { navigateToLinkAccount } from 'store/navigation/navigation-action';
+import { RootState } from 'store/store';
 
-
-type CssRules = 'root' | 'ontop' | 'title';
+export type CssRules = 'root' | 'ontop' | 'title';
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     root: {
@@ -47,31 +47,45 @@ const mapDispatchToProps = (dispatch: Dispatch): InactivePanelActionProps => ({
     }
 });
 
-type InactivePanelProps =  WithStyles<CssRules> & InactivePanelActionProps;
+const mapStateToProps = (state: RootState): InactivePanelStateProps => ({
+    inactivePageText: state.auth.config.clusterConfig.Workbench.InactivePageHTML,
+    isLoginClusterFederation: state.auth.config.clusterConfig.Login.LoginCluster !== '',
+});
+
+export interface InactivePanelStateProps {
+    inactivePageText: string;
+    isLoginClusterFederation: boolean;
+}
+
+type InactivePanelProps = WithStyles<CssRules> & InactivePanelActionProps & InactivePanelStateProps;
+
+
+export const InactivePanelRoot = ({ classes, startLinking, inactivePageText, isLoginClusterFederation }: InactivePanelProps) =>
+    <Grid container justify="center" alignItems="center" direction="column" spacing={24}
+        className={classes.root}
+        style={{ marginTop: 56, height: "100%" }}>
+        <Grid item>
+            <Typography>
+                <span dangerouslySetInnerHTML={{ __html: inactivePageText }} style={{ margin: "1em" }} />
+            </Typography>
+        </Grid>
+        { !isLoginClusterFederation
+        ? <><Grid item>
+            <Typography align="center">
+            If you would like to use this login to access another account click "Link Account".
+            </Typography>
+        </Grid>
+        <Grid item>
+            <Button className={classes.ontop} color="primary" variant="contained" onClick={() => startLinking()}>
+                Link Account
+            </Button>
+        </Grid></>
+        : <><Grid item>
+            <Typography align="center">
+                If you would like to use this login to access another account, please contact your administrator.
+            </Typography>
+        </Grid></> }
+    </Grid >;
 
-export const InactivePanel = connect(null, mapDispatchToProps)(withStyles(styles)((({ classes, startLinking }: InactivePanelProps) =>
-        <Grid container justify="center" alignItems="center" direction="column" spacing={24}
-            className={classes.root}
-            style={{ marginTop: 56, height: "100%" }}>
-            <Grid item>
-                <Typography variant='h6' align="center" className={classes.title}>
-                    Hi! You're logged in, but...
-                </Typography>
-            </Grid>
-            <Grid item>
-                <Typography align="center">
-                    Your account is inactive. An administrator must activate your account before you can get any further.
-                </Typography>
-            </Grid>
-            <Grid item>
-                <Typography align="center">
-                    If you would like to use this login to access another account click "Link Account".
-                </Typography>
-            </Grid>
-            <Grid item>
-                <Button className={classes.ontop} color="primary" variant="contained" onClick={() => startLinking()}>
-                    Link Account
-                </Button>
-            </Grid>
-        </Grid >
-    )));
+export const InactivePanel = connect(mapStateToProps, mapDispatchToProps)(
+    withStyles(styles)(InactivePanelRoot));