1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
15 } from '@material-ui/core';
16 import { ArvadosTheme } from '~/common/custom-theme';
17 import { User } from "~/models/user";
18 import { LinkAccountType, AccountToLink } from "~/models/link-account";
19 import { formatDate }from "~/common/formatters";
21 type CssRules = 'root';// | 'gridItem' | 'label' | 'title' | 'actions';
23 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
30 export interface LinkAccountPanelRootDataProps {
32 accountToLink?: AccountToLink;
35 export interface LinkAccountPanelRootActionProps {
36 saveAccountLinkData: (type: LinkAccountType) => void;
37 removeAccountLinkData: () => void;
40 type LinkAccountPanelRootProps = LinkAccountPanelRootDataProps & LinkAccountPanelRootActionProps & WithStyles<CssRules>;
42 export const LinkAccountPanelRoot = withStyles(styles) (
43 ({classes, user, accountToLink, saveAccountLinkData, removeAccountLinkData}: LinkAccountPanelRootProps) => {
44 return <Card className={classes.root}>
46 { user && accountToLink===undefined && <Grid container spacing={24}>
47 <Grid container item direction="column" spacing={24}>
49 You are currently logged in as <b>{user.email}</b> ({user.username}, {user.uuid}) created on <b>{formatDate(user.createdAt)}</b>
52 You can link Arvados accounts. After linking, either login will take you to the same account.
55 <Grid container item direction="row" spacing={24}>
57 <Button color="primary" variant="contained" onClick={() => saveAccountLinkData(LinkAccountType.ADD_OTHER_LOGIN)}>
58 Add another login to this account
62 <Button color="primary" variant="contained" onClick={() => saveAccountLinkData(LinkAccountType.ACCESS_OTHER_ACCOUNT)}>
63 Use this login to access another account
68 { accountToLink && <Grid container spacing={24}>
69 <Grid container item direction="row" spacing={24}>
71 <Button variant="contained" onClick={() => removeAccountLinkData()}>
76 <Button color="primary" variant="contained" onClick={() => {}}>