From bdfda992c607ed4ca591dbf310e659faa370a881 Mon Sep 17 00:00:00 2001 From: Eric Biagiotti Date: Tue, 7 May 2019 13:51:00 -0400 Subject: [PATCH] 15088: Adds link account feature to inactive page Arvados-DCO-1.1-Signed-off-by: Eric Biagiotti --- .../link-account-panel-actions.ts | 2 +- src/views/inactive-panel/inactive-panel.tsx | 78 +++++++++---------- .../link-account-panel-root.tsx | 2 +- 3 files changed, 40 insertions(+), 42 deletions(-) diff --git a/src/store/link-account-panel/link-account-panel-actions.ts b/src/store/link-account-panel/link-account-panel-actions.ts index ee58e588..5e7a02b4 100644 --- a/src/store/link-account-panel/link-account-panel-actions.ts +++ b/src/store/link-account-panel/link-account-panel-actions.ts @@ -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; diff --git a/src/views/inactive-panel/inactive-panel.tsx b/src/views/inactive-panel/inactive-panel.tsx index abfa1f81..25e03b85 100644 --- a/src/views/inactive-panel/inactive-panel.tsx +++ b/src/views/inactive-panel/inactive-panel.tsx @@ -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 = (theme: ArvadosTheme) => ({ root: { @@ -28,51 +29,48 @@ const styles: StyleRulesCallback = (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 & WithStyles & { - remoteHosts: { [key: string]: string }, - homeCluster: string, - uuidPrefix: string -}; +export interface InactivePanelActionProps { + linkAccount: () => void; +} + +const mapDispatchToProps = (dispatch: Dispatch): InactivePanelActionProps => ({ + linkAccount: () => dispatch(saveAccountLinkData(LinkAccountType.ACCESS_OTHER_ACCOUNT)) +}); + +type InactivePanelProps = WithStyles & 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) => - + - + style={{ marginTop: 56, height: "100%" }}> + Hi! You're logged in, but... - - - Your account is inactive. - - An administrator must activate your account before you can get any further. - + + + + + Your account is inactive. An administrator must activate your account before you can get any further. + + + + + If you would like to use this login to access another account click "Link Account". + + + + - )); + ))); diff --git a/src/views/link-account-panel/link-account-panel-root.tsx b/src/views/link-account-panel/link-account-panel-root.tsx index 8661f665..88730b89 100644 --- a/src/views/link-account-panel/link-account-panel-root.tsx +++ b/src/views/link-account-panel/link-account-panel-root.tsx @@ -98,7 +98,7 @@ export const LinkAccountPanelRoot = withStyles(styles) ( Cannot link {displayUser(targetUser)} to the same account. } { error === LinkAccountPanelError.INACTIVE && - Cannot link active account {displayUser(userToLink)} to inactive account {displayUser(targetUser)}. + Cannot link account {displayUser(userToLink)} to inactive account {displayUser(targetUser)}. } -- 2.30.2