Skip to content
This repository was archived by the owner on Mar 25, 2022. It is now read-only.

Commit 23a1c0f

Browse files
committed
feat(fbcnms-ui): Add Organization create
1 parent 27c5d29 commit 23a1c0f

File tree

4 files changed

+544
-113
lines changed

4 files changed

+544
-113
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
/**
2+
* Copyright 2004-present Facebook. All Rights Reserved.
3+
*
4+
* This source code is licensed under the BSD-style license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
* @format
9+
*/
10+
11+
import Box from '@material-ui/core/Box';
12+
import Divider from '@material-ui/core/Divider';
13+
import Grid from '@material-ui/core/Grid';
14+
import HelpIcon from '@material-ui/icons/Help';
15+
import IconButton from '@material-ui/core/IconButton';
16+
import InputAdornment from '@material-ui/core/InputAdornment';
17+
import LinearProgress from '@material-ui/core/LinearProgress';
18+
import ListItem from '@material-ui/core/ListItem';
19+
import OutlinedInput from '@material-ui/core/OutlinedInput';
20+
import React from 'react';
21+
import Tooltip from '@material-ui/core/Tooltip';
22+
import Typography from '@material-ui/core/Typography';
23+
import Visibility from '@material-ui/icons/Visibility';
24+
import VisibilityOff from '@material-ui/icons/VisibilityOff';
25+
import grey from '@material-ui/core/colors/grey';
26+
27+
import {makeStyles} from '@material-ui/styles';
28+
import {useState} from 'react';
29+
30+
const useStyles = makeStyles(theme => ({
31+
root: {
32+
display: 'flex',
33+
marginBottom: '5px',
34+
alignItems: 'center',
35+
},
36+
heading: {
37+
flexBasis: '33.33%',
38+
marginRight: '15px',
39+
textAlign: 'right',
40+
},
41+
subheading: {
42+
fontWeight: '400',
43+
},
44+
optionalLabel: {
45+
color: grey.A700,
46+
fontStyle: 'italic',
47+
fontWeight: '400',
48+
marginLeft: '8px',
49+
},
50+
secondaryHeading: {
51+
flexBasis: '66.66%',
52+
},
53+
icon: {
54+
marginLeft: '5px',
55+
paddingTop: '4px',
56+
verticalAlign: 'bottom',
57+
width: '15px',
58+
},
59+
formDivider: {
60+
margin: `${theme.spacing(3)}px 0 ${theme.spacing(2)}px`,
61+
backgroundColor: '#9DA7BB',
62+
opacity: 0.4,
63+
height: '1px',
64+
},
65+
}));
66+
67+
type Props = {
68+
label: string,
69+
children?: any,
70+
dense?: boolean,
71+
tooltip?: string,
72+
subLabel?: string,
73+
isOptional?: boolean,
74+
disableGutters?: boolean,
75+
};
76+
77+
export default function FormField(props: Props) {
78+
const classes = useStyles();
79+
const {tooltip} = props;
80+
return (
81+
<div className={classes.root}>
82+
<Typography className={classes.heading} variant="body2">
83+
{props.label}
84+
{tooltip && (
85+
<Tooltip title={tooltip} placement="bottom-start">
86+
<HelpIcon className={classes.icon} />
87+
</Tooltip>
88+
)}
89+
</Typography>
90+
<Typography
91+
className={classes.secondaryHeading}
92+
component="div"
93+
variant="body2">
94+
{props.children}
95+
</Typography>
96+
</div>
97+
);
98+
}
99+
100+
export function AltFormField(props: Props) {
101+
const classes = useStyles();
102+
return (
103+
<ListItem dense={props.dense} disableGutters={props.disableGutters}>
104+
<Grid container>
105+
<Grid item xs={12}>
106+
{props.label}
107+
{props.isOptional && (
108+
<Typography
109+
className={classes.optionalLabel}
110+
variant="caption"
111+
gutterBottom>
112+
{'optional'}
113+
</Typography>
114+
)}
115+
</Grid>
116+
{props.subLabel && (
117+
<Grid item xs={12}>
118+
<Typography
119+
className={classes.subheading}
120+
variant="caption"
121+
display="block"
122+
gutterBottom>
123+
{props.subLabel}
124+
</Typography>
125+
</Grid>
126+
)}
127+
<Grid item xs={12}>
128+
{props.children}
129+
</Grid>
130+
</Grid>
131+
</ListItem>
132+
);
133+
}
134+
135+
export function AltFormFieldSubheading(props: Props) {
136+
const classes = useStyles();
137+
return (
138+
<Grid container>
139+
<Grid item xs={12}>
140+
<Typography
141+
className={classes.subheading}
142+
variant="caption"
143+
display="block"
144+
gutterBottom>
145+
{props.label}
146+
</Typography>
147+
</Grid>
148+
<Grid item xs={12}>
149+
{props.children}
150+
</Grid>
151+
</Grid>
152+
);
153+
}
154+
155+
type PasswordProps = {
156+
value: string,
157+
onChange: string => void,
158+
};
159+
160+
export function FormDivider() {
161+
const classes = useStyles();
162+
return <Divider className={classes.formDivider} />;
163+
}
164+
165+
export function PasswordInput(props: PasswordProps) {
166+
const [showPassword, setShowPassword] = useState(false);
167+
return (
168+
<OutlinedInput
169+
{...props}
170+
type={showPassword ? 'text' : 'password'}
171+
value={props.value}
172+
onChange={e => props.onChange(e.target.value)}
173+
endAdornment={
174+
<InputAdornment position="end">
175+
<IconButton
176+
aria-label="toggle password visibility"
177+
onClick={() => setShowPassword(true)}
178+
onMouseDown={() => setShowPassword(false)}
179+
edge="end">
180+
{showPassword ? <Visibility /> : <VisibilityOff />}
181+
</IconButton>
182+
</InputAdornment>
183+
}
184+
/>
185+
);
186+
}
187+
188+
type ProgressProps = {
189+
value: number,
190+
text?: string,
191+
};
192+
193+
export function LinearProgressWithLabel(props: ProgressProps) {
194+
return (
195+
<Box display="flex" alignItems="center">
196+
<Box width="100%" mr={1}>
197+
<LinearProgress variant="determinate" value={props.value} />
198+
</Box>
199+
<Box minWidth={35}>
200+
<Typography>{props.text ?? `${Math.round(props.value)}%`}</Typography>
201+
</Box>
202+
</Box>
203+
);
204+
}

fbcnms-packages/fbcnms-ui/components/auth/EditUserDialog.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export type EditUser = {
3737
organization?: string,
3838
};
3939

40-
type SaveUserData = {
40+
export type SaveUserData = {
4141
email: string,
4242
password?: string,
4343
role: number,

0 commit comments

Comments
 (0)