|
@@ -19,7 +19,7 @@ type Connection = AuthReq & {
|
|
time: string;
|
|
time: string;
|
|
};
|
|
};
|
|
|
|
|
|
-export const AuthForm = (props: any) => {
|
|
|
|
|
|
+export const AuthForm = () => {
|
|
// styles
|
|
// styles
|
|
const classes = useStyles();
|
|
const classes = useStyles();
|
|
|
|
|
|
@@ -39,7 +39,7 @@ export const AuthForm = (props: any) => {
|
|
const navigate = useNavigate();
|
|
const navigate = useNavigate();
|
|
|
|
|
|
// UI states
|
|
// UI states
|
|
- const [withPass, setWithPass] = useState(authReq.username.length > 0);
|
|
|
|
|
|
+ const [withPass, setWithPass] = useState(false);
|
|
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
|
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
|
|
const [connections, setConnections] = useState<Connection[]>([]);
|
|
const [connections, setConnections] = useState<Connection[]>([]);
|
|
const [isConnecting, setIsConnecting] = useState(false);
|
|
const [isConnecting, setIsConnecting] = useState(false);
|
|
@@ -48,7 +48,8 @@ export const AuthForm = (props: any) => {
|
|
const checkedForm = useMemo(() => {
|
|
const checkedForm = useMemo(() => {
|
|
return formatForm(authReq);
|
|
return formatForm(authReq);
|
|
}, [authReq]);
|
|
}, [authReq]);
|
|
- const { validation, checkIsValid } = useFormValidation(checkedForm);
|
|
|
|
|
|
+ const { validation, checkIsValid, resetValidation } =
|
|
|
|
+ useFormValidation(checkedForm);
|
|
|
|
|
|
// UI handlers
|
|
// UI handlers
|
|
// handle input change
|
|
// handle input change
|
|
@@ -110,6 +111,8 @@ export const AuthForm = (props: any) => {
|
|
address: authReq.address,
|
|
address: authReq.address,
|
|
database: authReq.database,
|
|
database: authReq.database,
|
|
username: authReq.username,
|
|
username: authReq.username,
|
|
|
|
+ password: authReq.password,
|
|
|
|
+ token: authReq.token,
|
|
time: Date.now(),
|
|
time: Date.now(),
|
|
},
|
|
},
|
|
];
|
|
];
|
|
@@ -135,7 +138,9 @@ export const AuthForm = (props: any) => {
|
|
// connect history clicked
|
|
// connect history clicked
|
|
const onConnectHistoryClicked = (connection: any) => {
|
|
const onConnectHistoryClicked = (connection: any) => {
|
|
console.log('connection', connection);
|
|
console.log('connection', connection);
|
|
|
|
+ // set auth request
|
|
setAuthReq(connection);
|
|
setAuthReq(connection);
|
|
|
|
+ // close menu
|
|
handleMenuClose();
|
|
handleMenuClose();
|
|
};
|
|
};
|
|
|
|
|
|
@@ -157,6 +162,21 @@ export const AuthForm = (props: any) => {
|
|
setConnections(connections);
|
|
setConnections(connections);
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
|
|
+ // UI effect
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ // if address contains zilliz, or username or password is not empty
|
|
|
|
+ // set withpass to true
|
|
|
|
+ if (
|
|
|
|
+ (authReq.address.length > 0 && authReq.address.includes('zilliz')) ||
|
|
|
|
+ authReq.username.length > 0 ||
|
|
|
|
+ authReq.password.length > 0
|
|
|
|
+ ) {
|
|
|
|
+ setWithPass(true);
|
|
|
|
+ }
|
|
|
|
+ // reset form
|
|
|
|
+ resetValidation(formatForm(authReq));
|
|
|
|
+ }, [authReq.address, authReq.username, authReq.password]);
|
|
|
|
+
|
|
return (
|
|
return (
|
|
<form onSubmit={handleConnect}>
|
|
<form onSubmit={handleConnect}>
|
|
<section className={classes.wrapper}>
|
|
<section className={classes.wrapper}>
|
|
@@ -175,7 +195,7 @@ export const AuthForm = (props: any) => {
|
|
textConfig={{
|
|
textConfig={{
|
|
label: attuTrans.address,
|
|
label: attuTrans.address,
|
|
key: 'address',
|
|
key: 'address',
|
|
- onChange: (val: string) => handleInputChange('address', val),
|
|
|
|
|
|
+ onChange: (val: string) => handleInputChange('address', String(val)),
|
|
variant: 'filled',
|
|
variant: 'filled',
|
|
className: classes.input,
|
|
className: classes.input,
|
|
placeholder: attuTrans.address,
|
|
placeholder: attuTrans.address,
|