From: Lucas Di Pentima Date: Tue, 1 Mar 2022 22:30:29 +0000 (-0300) Subject: Merge branch '17754-federated-acct-merge'. Closes #17754. X-Git-Tag: 2.4.0~8 X-Git-Url: https://git.arvados.org/arvados-workbench2.git/commitdiff_plain/6e335a900ab99ddc7b7288e00d20a54f6c75ec8f?hp=e42867f560b3c2f4c09cf6a2c07c964c63714141 Merge branch '17754-federated-acct-merge'. Closes #17754. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- diff --git a/src/views/inactive-panel/inactive-panel.test.tsx b/src/views/inactive-panel/inactive-panel.test.tsx new file mode 100644 index 00000000..c694f9db --- /dev/null +++ b/src/views/inactive-panel/inactive-panel.test.tsx @@ -0,0 +1,63 @@ +// Copyright (C) The Arvados Authors. All rights reserved. +// +// SPDX-License-Identifier: AGPL-3.0 + +import React from 'react'; +import { mount, configure } from 'enzyme'; +import Adapter from "enzyme-adapter-react-16"; +import { CustomTheme } from 'common/custom-theme'; +import { InactivePanelStateProps, CssRules, InactivePanelRoot } from './inactive-panel'; +import { MuiThemeProvider, StyledComponentProps } from '@material-ui/core'; + +configure({ adapter: new Adapter() }); + +describe('InactivePanel', () => { + let props: InactivePanelStateProps & StyledComponentProps; + + beforeEach(() => { + props = { + classes: { + root: 'root', + title: 'title', + ontop: 'ontop', + }, + isLoginClusterFederation: false, + inactivePageText: 'Inactive page content', + }; + }); + + it('should render content and link account option', () => { + // given + const expectedMessage = "Inactive page content"; + const expectedLinkAccountText = 'If you would like to use this login to access another account click "Link Account"'; + + // when + const wrapper = mount( + + + + ); + + // then + expect(wrapper.find('p').first().text()).toContain(expectedMessage); + expect(wrapper.find('p').at(1).text()).toContain(expectedLinkAccountText); + }) + + it('should render content and link account warning on LoginCluster federations', () => { + // given + props.isLoginClusterFederation = true; + const expectedMessage = "Inactive page content"; + const expectedLinkAccountText = 'If you would like to use this login to access another account, please contact your administrator'; + + // when + const wrapper = mount( + + + + ); + + // then + expect(wrapper.find('p').first().text()).toContain(expectedMessage); + expect(wrapper.find('p').at(1).text()).toContain(expectedLinkAccountText); + }) +}); \ No newline at end of file diff --git a/src/views/inactive-panel/inactive-panel.tsx b/src/views/inactive-panel/inactive-panel.tsx index 6d8bbf59..8a7c7928 100644 --- a/src/views/inactive-panel/inactive-panel.tsx +++ b/src/views/inactive-panel/inactive-panel.tsx @@ -11,7 +11,7 @@ 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 = (theme: ArvadosTheme) => ({ root: { @@ -47,32 +47,45 @@ const mapDispatchToProps = (dispatch: Dispatch): 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 & InactivePanelActionProps & InactivePanelStateProps; -export const InactivePanel = connect((state: RootState) => ({ - inactivePageText: state.auth.config.clusterConfig.Workbench.InactivePageHTML -}), mapDispatchToProps)(withStyles(styles)((({ classes, startLinking, inactivePageText }: InactivePanelProps) => + +export const InactivePanelRoot = ({ classes, startLinking, inactivePageText, isLoginClusterFederation }: InactivePanelProps) => -
+ - + { !isLoginClusterFederation + ? <> - If you would like to use this login to access another account click "Link Account". - + If you would like to use this login to access another account click "Link Account". + - - -))); + + + : <> + + If you would like to use this login to access another account, please contact your administrator. + + } + ; + +export const InactivePanel = connect(mapStateToProps, mapDispatchToProps)( + withStyles(styles)(InactivePanelRoot)); 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 c5c86eb2..490e47dc 100644 --- a/src/views/link-account-panel/link-account-panel-root.tsx +++ b/src/views/link-account-panel/link-account-panel-root.tsx @@ -73,125 +73,136 @@ type LinkAccountPanelRootProps = LinkAccountPanelRootDataProps & LinkAccountPane export const LinkAccountPanelRoot = withStyles(styles)( ({ classes, targetUser, userToLink, status, isProcessing, error, startLinking, cancelLinking, linkAccount, remoteHostsConfig, hasRemoteHosts, selectedCluster, setSelectedCluster, localCluster, loginCluster }: LinkAccountPanelRootProps) => { - return - - {isProcessing && - - Loading user info. Please wait. - - - + + // If a LoginFederation is configured, the self-serve account linking is not + // currently available. + if (loginCluster !== "") { + return + + + If you would like to link this account to another one, please contact your administrator. - } - {!isProcessing && status === LinkAccountPanelStatus.INITIAL && targetUser &&
- {isLocalUser(targetUser.uuid, localCluster) ? - - - You are currently logged in as {displayUser(targetUser, true)} - - - You can link Arvados accounts. After linking, either login will take you to the same account. - + + ; + } + return + { isProcessing && + + Loading user info. Please wait. + + + + + } + + { !isProcessing && status === LinkAccountPanelStatus.INITIAL && targetUser &&
+ { isLocalUser(targetUser.uuid, localCluster) + ? + + + You are currently logged in as {displayUser(targetUser, true)} - - - - - - - + + You can link Arvados accounts. After linking, either login will take you to the same account. + + + + + - {hasRemoteHosts && selectedCluster && - - You can also link {displayUser(targetUser, false)} with an account from a remote cluster. - - - Please select the cluster that hosts the account you want to link with: - - + + + + + {hasRemoteHosts && selectedCluster && + + You can also link {displayUser(targetUser, false)} with an account from a remote cluster. + + + Please select the cluster that hosts the account you want to link with: + + + + + + } + + : + + + You are currently logged in as {displayUser(targetUser, true, true)} + + { targetUser.isActive + ? (loginCluster === "" + ? <> + This a remote account. You can link a local Arvados account to this one. + After linking, you can access the local account's data by logging into the + {localCluster} cluster as user {targetUser.email} + from {targetUser.uuid.substring(0, 5)}. + - - - } - : - - - - You are currently logged in as {displayUser(targetUser, true, true)} - - {targetUser.isActive ? - (loginCluster === "" ? - <> - This a remote account. You can link a local Arvados account to this one. - After linking, you can access the local account's data by logging into the - {localCluster} cluster as user {targetUser.email} - from {targetUser.uuid.substring(0, 5)}. - - - - - : Please visit cluster - {loginCluster} - to perform account linking. - ) - : - This an inactive remote account. An administrator must activate your - account before you can proceed. After your accounts is activated, - you can link a local Arvados account hosted by the {localCluster} - cluster to this one. - } - - } -
} - {!isProcessing && (status === LinkAccountPanelStatus.LINKING || status === LinkAccountPanelStatus.ERROR) && userToLink && targetUser && - - {status === LinkAccountPanelStatus.LINKING && - - Clicking 'Link accounts' will link {displayUser(userToLink, true, !isLocalUser(targetUser.uuid, localCluster))} to {displayUser(targetUser, true, !isLocalUser(targetUser.uuid, localCluster))}. - - {(isLocalUser(targetUser.uuid, localCluster)) && - After linking, logging in as {displayUser(userToLink)} will log you into the same account as {displayUser(targetUser)}. - } - - Any object owned by {displayUser(userToLink)} will be transfered to {displayUser(targetUser)}. - - {!isLocalUser(targetUser.uuid, localCluster) && - You can access {userToLink.email} data by logging into {localCluster} with the {targetUser.email} account. - } + + : Please visit cluster + {loginCluster} to perform account linking. + ) + : + This an inactive remote account. An administrator must activate your + account before you can proceed. After your accounts is activated, + you can link a local Arvados account hosted by the {localCluster} cluster to this one. + } + +
} +
} + + {!isProcessing && (status === LinkAccountPanelStatus.LINKING || status === LinkAccountPanelStatus.ERROR) && userToLink && targetUser && + + {status === LinkAccountPanelStatus.LINKING && + + Clicking 'Link accounts' will link {displayUser(userToLink, true, !isLocalUser(targetUser.uuid, localCluster))} to {displayUser(targetUser, true, !isLocalUser(targetUser.uuid, localCluster))}. + + {(isLocalUser(targetUser.uuid, localCluster)) && + After linking, logging in as {displayUser(userToLink)} will log you into the same account as {displayUser(targetUser)}. } - {error === LinkAccountPanelError.NON_ADMIN && - Cannot link admin account {displayUser(userToLink)} to non-admin account {displayUser(targetUser)}. - } - {error === LinkAccountPanelError.SAME_USER && - Cannot link {displayUser(targetUser)} to the same account. - } - {error === LinkAccountPanelError.INACTIVE && - Cannot link account {displayUser(userToLink)} to inactive account {displayUser(targetUser)}. - } - - - - - - - + + Any object owned by {displayUser(userToLink)} will be transfered to {displayUser(targetUser)}. + {!isLocalUser(targetUser.uuid, localCluster) && + You can access {userToLink.email} data by logging into {localCluster} with the {targetUser.email} account. + } + } + {error === LinkAccountPanelError.NON_ADMIN && + Cannot link admin account {displayUser(userToLink)} to non-admin account {displayUser(targetUser)}. + } + {error === LinkAccountPanelError.SAME_USER && + Cannot link {displayUser(targetUser)} to the same account. + } + {error === LinkAccountPanelError.INACTIVE && + Cannot link account {displayUser(userToLink)} to inactive account {displayUser(targetUser)}. } -
-
; + + + + + + + + +
} +
; });