X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/eb9611ea28acee0a8fdef772ef8d1b31ac689e4c..c56b5c0f2df66fbb23b278c2a3338c09d9435735:/src/views/link-account-panel/link-account-panel-root.tsx 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 12dae426..eb52ba18 100644 --- a/src/views/link-account-panel/link-account-panel-root.tsx +++ b/src/views/link-account-panel/link-account-panel-root.tsx @@ -2,7 +2,7 @@ // // SPDX-License-Identifier: AGPL-3.0 -import * as React from 'react'; +import React from 'react'; import { StyleRulesCallback, WithStyles, @@ -11,32 +11,37 @@ import { CardContent, Button, Grid, - Select + Select, + CircularProgress } from '@material-ui/core'; -import { ArvadosTheme } from '~/common/custom-theme'; -import { UserResource } from "~/models/user"; -import { LinkAccountType } from "~/models/link-account"; -import { formatDate } from "~/common/formatters"; -import { LinkAccountPanelStatus, LinkAccountPanelError } from "~/store/link-account-panel/link-account-panel-reducer"; +import { ArvadosTheme } from 'common/custom-theme'; +import { UserResource } from "models/user"; +import { LinkAccountType } from "models/link-account"; +import { formatDate } from "common/formatters"; +import { LinkAccountPanelStatus, LinkAccountPanelError } from "store/link-account-panel/link-account-panel-reducer"; +import { Config } from 'common/config'; -type CssRules = 'root';// | 'gridItem' | 'label' | 'title' | 'actions'; +type CssRules = 'root'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ root: { width: '100%', - overflow: 'auto' + overflow: 'auto', + display: 'flex' } }); export interface LinkAccountPanelRootDataProps { targetUser?: UserResource; userToLink?: UserResource; - remoteHosts: { [key: string]: string }; + remoteHostsConfig: { [key: string]: Config }; hasRemoteHosts: boolean; localCluster: string; - status : LinkAccountPanelStatus; + loginCluster: string; + status: LinkAccountPanelStatus; error: LinkAccountPanelError; selectedCluster?: string; + isProcessing: boolean; } export interface LinkAccountPanelRootActionProps { @@ -47,14 +52,14 @@ export interface LinkAccountPanelRootActionProps { } function displayUser(user: UserResource, showCreatedAt: boolean = false, showCluster: boolean = false) { - const disp = []; + const disp: JSX.Element[] = []; disp.push({user.email} ({user.username}, {user.uuid})); if (showCluster) { - const homeCluster = user.uuid.substr(0,5); + const homeCluster = user.uuid.substr(0, 5); disp.push( hosted on cluster {homeCluster} and ); } if (showCreatedAt) { - disp.push( created on {formatDate(user.createdAt, true)}); + disp.push( created on {formatDate(user.createdAt)}); } return disp; } @@ -65,105 +70,128 @@ function isLocalUser(uuid: string, localCluster: string) { type LinkAccountPanelRootProps = LinkAccountPanelRootDataProps & LinkAccountPanelRootActionProps & WithStyles; -export const LinkAccountPanelRoot = withStyles(styles) ( - ({classes, targetUser, userToLink, status, error, startLinking, cancelLinking, linkAccount, - remoteHosts, hasRemoteHosts, selectedCluster, setSelectedCluster, localCluster}: LinkAccountPanelRootProps) => { +export const LinkAccountPanelRoot = withStyles(styles)( + ({ classes, targetUser, userToLink, status, isProcessing, error, startLinking, cancelLinking, linkAccount, + remoteHostsConfig, hasRemoteHosts, selectedCluster, setSelectedCluster, localCluster, loginCluster }: LinkAccountPanelRootProps) => { return - { 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. - + {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)} - - - 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 with the {targetUser.email} account. - - - + + + + } + : + + + + 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.substr(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. + } + } + {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)}. + } + + + + + + + - -
} -
} - { (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. - } - } - { 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)}. - } - - - - - - - - - } + }
-
; -}); \ No newline at end of file + ; + });