You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by sh...@apache.org on 2024/07/16 03:09:14 UTC
(incubator-answer) 06/08: support switching databases to display the relevant database configurations during the initial installation
This is an automated email from the ASF dual-hosted git repository.
shuai pushed a commit to branch test
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git
commit 2f3d991bf2da2a11564d73910d8369cb48c46d90
Author: Wuzi <wu...@obiscr.com>
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) => {