15088: Adds link account feature to inactive page
authorEric Biagiotti <ebiagiotti@veritasgenetics.com>
Tue, 7 May 2019 17:51:00 +0000 (13:51 -0400)
committerEric Biagiotti <ebiagiotti@veritasgenetics.com>
Tue, 7 May 2019 17:51:00 +0000 (13:51 -0400)
Arvados-DCO-1.1-Signed-off-by: Eric Biagiotti <ebiagiotti@veritasgenetics.com>

src/store/link-account-panel/link-account-panel-actions.ts
src/views/inactive-panel/inactive-panel.tsx
src/views/link-account-panel/link-account-panel-root.tsx

index ee58e588f8f3b76df1a723d608cb58495e4f072c..5e7a02b4d4d89bf4f20cf0b3ac7cb39ec2ec2276 100644 (file)
@@ -40,7 +40,7 @@ function validateLink(userToLink: UserResource, targetUser: UserResource) {
     else if (userToLink.isAdmin && !targetUser.isAdmin) {
         return LinkAccountPanelError.NON_ADMIN;
     }
-    else if (userToLink.isActive && !targetUser.isActive) {
+    else if (!targetUser.isActive) {
         return LinkAccountPanelError.INACTIVE;
     }
     return LinkAccountPanelError.NONE;
index abfa1f8129aad55e8e7df7351056ea336fac70ec..25e03b8565fefcb31ed97f350128d12baa0335b4 100644 (file)
@@ -3,15 +3,16 @@
 // 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 { saveAccountLinkData } from '~/store/link-account-panel/link-account-panel-actions';
+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 { RootState } from '~/store/store';
-import * as classNames from 'classnames';
+import { LinkAccountType } from '~/models/link-account';
 
-type CssRules = 'root' | 'container' | 'title' | 'content' | 'content__bolder' | 'button';
+
+type CssRules = 'root' | 'ontop' | 'title';
 
 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     root: {
@@ -28,51 +29,48 @@ 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 {
+    linkAccount: () => void;
+}
+
+const mapDispatchToProps = (dispatch: Dispatch): InactivePanelActionProps => ({
+    linkAccount: () => dispatch<any>(saveAccountLinkData(LinkAccountType.ACCESS_OTHER_ACCOUNT))
+});
+
+type InactivePanelProps =  WithStyles<CssRules> & InactivePanelActionProps;
 
-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"
+export const InactivePanel = connect(null, mapDispatchToProps)(withStyles(styles)((({ classes, linkAccount }: InactivePanelProps) =>
+        <Grid container justify="center" alignItems="center" direction="column" spacing={24}
             className={classes.root}
-            style={{ marginTop: 56, overflowY: "auto", height: "100%" }}>
-            <Grid item className={classes.container}>
+            style={{ marginTop: 56, height: "100%" }}>
+            <Grid item>
                 <Typography variant='h6' align="center" className={classes.title}>
                     Hi! You're logged in, but...
-               </Typography>
-                <Typography>
-                    Your account is inactive.
-
-                   An administrator must activate your account before you can get any further.
-               </Typography>
+                </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={() => linkAccount()}>
+                    Link Account
+                </Button>
             </Grid>
         </Grid >
-    ));
+    )));
index 8661f6654a3be0b98f8d9623d4ff4cee0161493c..88730b891d3b05aad23aeffdcb53a2ba6cd29bff 100644 (file)
@@ -98,7 +98,7 @@ export const LinkAccountPanelRoot = withStyles(styles) (
                     Cannot link {displayUser(targetUser)} to the same account.
                 </Grid> }
                 { error === LinkAccountPanelError.INACTIVE && <Grid item>
-                    Cannot link active account {displayUser(userToLink)} to inactive account {displayUser(targetUser)}.
+                    Cannot link account {displayUser(userToLink)} to inactive account {displayUser(targetUser)}.
                 </Grid> }
                 <Grid container item direction="row" spacing={24}>
                     <Grid item>