1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { Field, InjectedFormProps } from "redux-form";
7 import { TextField } from "~/components/text-field/text-field";
8 import { NativeSelectField } from "~/components/select-field/select-field";
19 } from '@material-ui/core';
20 import { ArvadosTheme } from '~/common/custom-theme';
21 import { User } from "~/models/user";
22 import { MY_ACCOUNT_VALIDATION} from "~/validators/validators";
24 type CssRules = 'root' | 'gridItem' | 'label' | 'title' | 'actions';
26 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
39 marginBottom: theme.spacing.unit * 3,
40 color: theme.palette.grey["600"]
44 justifyContent: 'flex-end'
48 export interface MyAccountPanelRootActionProps {}
50 export interface MyAccountPanelRootDataProps {
57 {key: 'Bio-informatician', value: 'Bio-informatician'},
58 {key: 'Data Scientist', value: 'Data Scientist'},
59 {key: 'Analyst', value: 'Analyst'},
60 {key: 'Researcher', value: 'Researcher'},
61 {key: 'Software Developer', value: 'Software Developer'},
62 {key: 'System Administrator', value: 'System Administrator'},
63 {key: 'Other', value: 'Other'}
66 type MyAccountPanelRootProps = InjectedFormProps<MyAccountPanelRootActionProps> & MyAccountPanelRootDataProps & WithStyles<CssRules>;
68 export const MyAccountPanelRoot = withStyles(styles)(
69 ({ classes, isValid, handleSubmit, reset, isPristine, invalid, submitting }: MyAccountPanelRootProps) => {
70 return <Card className={classes.root}>
72 <Typography variant="title" className={classes.title}>User profile</Typography>
73 <form onSubmit={handleSubmit}>
74 <Grid container direction="row" spacing={24}>
76 <Grid item className={classes.gridItem}>
84 <Grid item className={classes.gridItem}>
92 <Grid item className={classes.gridItem}>
100 <Grid item className={classes.gridItem}>
103 name="prefs.profile.organization"
104 component={TextField}
105 validate={MY_ACCOUNT_VALIDATION}
109 <Grid item className={classes.gridItem}>
112 name="prefs.profile.website_url"
113 component={TextField}
116 <Grid item className={classes.gridItem}>
117 <InputLabel className={classes.label} htmlFor="prefs.profile.role">Organization</InputLabel>
119 id="prefs.profile.role"
120 name="prefs.profile.role"
121 component={NativeSelectField}
127 <Grid item className={classes.gridItem} />
128 <Grid item className={classes.gridItem}>
132 component={TextField}
136 <Grid item className={classes.gridItem} />
137 <Grid item className={classes.gridItem}>
139 label="E-mail at Organization"
140 name="prefs.profile.organization_email"
141 component={TextField}
142 validate={MY_ACCOUNT_VALIDATION}
147 <Grid item xs={12} className={classes.actions}>
148 <Button color="primary" onClick={reset} disabled={isPristine}>Discard changes</Button>
153 disabled={isPristine || invalid || submitting}>