This is an automated email from the ASF dual-hosted git repository.

shuai pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git

commit c4a89db6389edec2f96866dbc4cf8a4e6c6620be
Author: Wuzi <[email protected]>
AuthorDate: Sun Jul 14 14:07:30 2024 +0800

    support switching databases to display the relevant database configurations 
during the initial installation
    
    When switching to Mysql, use:
    Username: root
    Password: root
    Database host: db:3306
    
    When switching to Postgres, use
    Username: postgres
    Password: postgres
    Database host: db:5432
---
 ui/src/pages/Install/index.tsx | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/ui/src/pages/Install/index.tsx b/ui/src/pages/Install/index.tsx
index 1a30f0cb..f9dedeca 100644
--- a/ui/src/pages/Install/index.tsx
+++ b/ui/src/pages/Install/index.tsx
@@ -131,11 +131,35 @@ const Index: FC = () => {
     },
   });
 
+  const updateFormData = (params: FormDataType) => {
+    if (step === 2) {
+      let updatedFormData = formData;
+      if (params.db_type.value === 'mysql') {
+        updatedFormData = {
+          ...updatedFormData,
+          db_username: { ...updatedFormData.db_username, value: 'root' },
+          db_password: { ...updatedFormData.db_password, value: 'root' },
+          db_host: { ...updatedFormData.db_host, value: 'db:3306' },
+        };
+      } else if (params.db_type.value === 'postgres') {
+        updatedFormData = {
+          ...updatedFormData,
+          db_username: { ...updatedFormData.db_username, value: 'postgres' },
+          db_password: { ...updatedFormData.db_password, value: 'postgres' },
+          db_host: { ...updatedFormData.db_host, value: 'db:5432' },
+        };
+      }
+      return updatedFormData;
+    }
+    return formData;
+  };
+  
   const handleChange = (params: FormDataType) => {
     setErrorData({
       msg: '',
     });
-    setFormData({ ...formData, ...params });
+    const updatedFormData = updateFormData(params);
+    setFormData({ ...updatedFormData, ...params });
   };
 
   const handleErr = (data) => {

Reply via email to