MCPcopy
hub / github.com/FlowiseAI/Flowise / EditUserDialog

Function EditUserDialog

packages/ui/src/views/users/EditUserDialog.jsx:39–208  ·  view source on GitHub ↗
({ show, dialogProps, onCancel, onConfirm, setError })

Source from the content-addressed store, hash-verified

37]
38
39const EditUserDialog = ({ show, dialogProps, onCancel, onConfirm, setError }) => {
40 const portalElement = document.getElementById('portal')
41 const currentUser = useSelector((state) => state.auth.user)
42
43 const dispatch = useDispatch()
44
45 useNotifier()
46
47 const enqueueSnackbar = (...args) => dispatch(enqueueSnackbarAction(...args))
48 const closeSnackbar = (...args) => dispatch(closeSnackbarAction(...args))
49
50 const [userName, setUserName] = useState('')
51 const [userEmail, setUserEmail] = useState('')
52 const [status, setStatus] = useState('active')
53 const [user, setUser] = useState({})
54
55 useEffect(() => {
56 if (dialogProps.type === 'EDIT' && dialogProps.data) {
57 setUser(dialogProps.data.user)
58 setUserEmail(dialogProps.data.user.email)
59 setUserName(dialogProps.data.user.name)
60 setStatus(dialogProps.data.user.status)
61 }
62
63 return () => {
64 setUserEmail('')
65 setUserName('')
66 setStatus('active')
67 setUser({})
68 }
69 // eslint-disable-next-line react-hooks/exhaustive-deps
70 }, [dialogProps])
71
72 useEffect(() => {
73 if (show) dispatch({ type: SHOW_CANVAS_DIALOG })
74 else dispatch({ type: HIDE_CANVAS_DIALOG })
75 return () => dispatch({ type: HIDE_CANVAS_DIALOG })
76 }, [show, dispatch])
77
78 const updateUser = async () => {
79 try {
80 const saveObj = {
81 userId: user.id,
82 organizationId: currentUser.activeOrganizationId,
83 status: status
84 }
85
86 const saveResp = await userApi.updateOrganizationUser(saveObj)
87 if (saveResp.data) {
88 enqueueSnackbar({
89 message: 'User Details Updated',
90 options: {
91 key: new Date().getTime() + Math.random(),
92 variant: 'success',
93 action: (key) => (
94 <Button style={{ color: 'white' }} onClick={() => closeSnackbar(key)}>
95 <IconX />
96 </Button>

Callers

nothing calls this directly

Calls 2

useNotifierFunction · 0.85
updateUserFunction · 0.70

Tested by

no test coverage detected