MCPcopy Create free account
hub / github.com/gotify/server / AddEditUserDialog

Function AddEditUserDialog

ui/src/user/AddEditUserDialog.tsx:20–106  ·  view source on GitHub ↗
({
    fClose,
    fOnSubmit,
    isEdit,
    name: initialName = '',
    admin: initialAdmin = false,
}: IProps)

Source from the content-addressed store, hash-verified

18}
19
20const AddEditUserDialog = ({
21 fClose,
22 fOnSubmit,
23 isEdit,
24 name: initialName = '',
25 admin: initialAdmin = false,
26}: IProps) => {
27 const [name, setName] = React.useState(initialName);
28 const [pass, setPass] = React.useState('');
29 const [admin, setAdmin] = React.useState(initialAdmin);
30
31 const namePresent = name.length !== 0;
32 const passPresent = pass.length !== 0 || isEdit;
33 const submitAndClose = async () => {
34 await fOnSubmit(name, pass, admin);
35 fClose();
36 };
37 return (
38 <Dialog
39 open={true}
40 onClose={fClose}
41 aria-labelledby="form-dialog-title"
42 id="add-edit-user-dialog">
43 <DialogTitle id="form-dialog-title">
44 {isEdit ? 'Edit ' + name : 'Add a user'}
45 </DialogTitle>
46 <DialogContent>
47 <TextField
48 autoFocus
49 margin="dense"
50 className="name"
51 label="Username *"
52 value={name}
53 name="username"
54 id="username"
55 onChange={(e) => setName(e.target.value)}
56 fullWidth
57 />
58 <TextField
59 margin="dense"
60 className="password"
61 type="password"
62 value={pass}
63 fullWidth
64 label={isEdit ? 'Password (empty if no change)' : 'Password *'}
65 name="password"
66 id="password"
67 onChange={(e) => setPass(e.target.value)}
68 />
69 <FormControlLabel
70 control={
71 <Switch
72 checked={admin}
73 className="admin-rights"
74 onChange={(e) => setAdmin(e.target.checked)}
75 value="admin"
76 />
77 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…