// Copyright (C) The Arvados Authors. All rights reserved. // // SPDX-License-Identifier: AGPL-3.0 import * as React from 'react'; import { StyleRulesCallback, WithStyles, withStyles, Card, CardContent, Button, Typography, Grid, } 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"; type CssRules = 'root';// | 'gridItem' | 'label' | 'title' | 'actions'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ root: { width: '100%', overflow: 'auto' } }); export interface LinkAccountPanelRootDataProps { user?: UserResource; userToLink?: UserResource; } export interface LinkAccountPanelRootActionProps { saveAccountLinkData: (type: LinkAccountType) => void; removeAccountLinkData: () => void; linkAccount: () => void; } function displayUser(user: UserResource, showCreatedAt: boolean = false) { const disp = []; disp.push({user.email} ({user.username}, {user.uuid})); if (showCreatedAt) { disp.push( created on {formatDate(user.createdAt)}); } return disp; } type LinkAccountPanelRootProps = LinkAccountPanelRootDataProps & LinkAccountPanelRootActionProps & WithStyles; export const LinkAccountPanelRoot = withStyles(styles) ( ({classes, user, userToLink, saveAccountLinkData, removeAccountLinkData, linkAccount}: LinkAccountPanelRootProps) => { return { user && userToLink===undefined && You are currently logged in as {displayUser(user, true)} You can link Arvados accounts. After linking, either login will take you to the same account. } { userToLink && user && Clicking 'Link accounts' will link {displayUser(user, true)} to {displayUser(userToLink, true)}. After linking, logging in as {displayUser(user)} will log you into the same account as {displayUser(userToLink)}. Any object owned by {displayUser(user)} will be transfered to {displayUser(userToLink)}. } ; });