Merge branch 'master' into 15067-tag-editing-by-ids
[arvados-workbench2.git] / src / views / inactive-panel / inactive-panel.tsx
index abfa1f8129aad55e8e7df7351056ea336fac70ec..91b4a51df8c41b150613077c277d7406b3226f7a 100644 (file)
@@ -3,15 +3,15 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { connect, DispatchProp } from 'react-redux';
-import { Grid, Typography, Button, Select } from '@material-ui/core';
+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 { login, authActions } from '~/store/auth/auth-action';
 import { ArvadosTheme } from '~/common/custom-theme';
+import { navigateToLinkAccount } from '~/store/navigation/navigation-action';
 import { RootState } from '~/store/store';
-import * as classNames from 'classnames';
 
-type CssRules = 'root' | 'container' | 'title' | 'content' | 'content__bolder' | 'button';
+type CssRules = 'root' | 'ontop' | 'title';
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     root: {
@@ -28,51 +28,51 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
             opacity: 0.2,
         }
     },
-    container: {
-        width: '560px',
+    ontop: {
         zIndex: 10
     },
     title: {
         marginBottom: theme.spacing.unit * 6,
         color: theme.palette.grey["800"]
-    },
-    content: {
-        marginBottom: theme.spacing.unit * 3,
-        lineHeight: '1.2rem',
-        color: theme.palette.grey["800"]
-    },
-    'content__bolder': {
-        fontWeight: 'bolder'
-    },
-    button: {
-        boxShadow: 'none'
     }
 });
 
-type LoginPanelProps = DispatchProp<any> & WithStyles<CssRules> & {
-    remoteHosts: { [key: string]: string },
-    homeCluster: string,
-    uuidPrefix: string
-};
+export interface InactivePanelActionProps {
+    startLinking: () => void;
+}
+
+const mapDispatchToProps = (dispatch: Dispatch): InactivePanelActionProps => ({
+    startLinking: () => {
+        dispatch<any>(navigateToLinkAccount);
+    }
+});
+
+export interface InactivePanelStateProps {
+    inactivePageText: string;
+}
 
-export const InactivePanel = withStyles(styles)(
-    connect((state: RootState) => ({
-        remoteHosts: state.auth.remoteHosts,
-        homeCluster: state.auth.homeCluster,
-        uuidPrefix: state.auth.localCluster
-    }))(({ classes, dispatch, remoteHosts, homeCluster, uuidPrefix }: LoginPanelProps) =>
-        <Grid container justify="center" alignItems="center"
-            className={classes.root}
-            style={{ marginTop: 56, overflowY: "auto", height: "100%" }}>
-            <Grid item className={classes.container}>
-                <Typography variant='h6' align="center" className={classes.title}>
-                    Hi! You're logged in, but...
-               </Typography>
-                <Typography>
-                    Your account is inactive.
+type InactivePanelProps = WithStyles<CssRules> & InactivePanelActionProps & InactivePanelStateProps;
 
-                   An administrator must activate your account before you can get any further.
-               </Typography>
-            </Grid>
-        </Grid >
-    ));
+export const InactivePanel = connect((state: RootState) => ({
+    inactivePageText: state.config.clusterConfig.Workbench.InactivePageHTML
+}), mapDispatchToProps)(withStyles(styles)((({ classes, startLinking, inactivePageText }: InactivePanelProps) =>
+    <Grid container justify="center" alignItems="center" direction="column" spacing={24}
+        className={classes.root}
+        style={{ marginTop: 56, height: "100%" }}>
+        <Grid item>
+            <Typography>
+                <div dangerouslySetInnerHTML={{ __html: inactivePageText }} style={{ margin: "1em" }} />
+            </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 >
+)));