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

songjian pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 87dc42fcc4 [Fix][UI Next][V1.0.0-Beta] Fix jdbc connect parameter 
validate bug (#9891)
87dc42fcc4 is described below

commit 87dc42fcc4bb822eb82c2077885cb494baab3359
Author: Devosend <[email protected]>
AuthorDate: Thu May 5 16:20:33 2022 +0800

    [Fix][UI Next][V1.0.0-Beta] Fix jdbc connect parameter validate bug (#9891)
---
 .../src/locales/modules/en_US.ts                   |  3 +-
 .../src/locales/modules/zh_CN.ts                   |  3 +-
 dolphinscheduler-ui-next/src/utils/index.ts        |  4 ++-
 .../src/utils/{index.ts => json.ts}                | 34 +++++++++++-----------
 .../src/views/datasource/list/use-form.ts          |  9 ++++++
 5 files changed, 33 insertions(+), 20 deletions(-)

diff --git a/dolphinscheduler-ui-next/src/locales/modules/en_US.ts 
b/dolphinscheduler-ui-next/src/locales/modules/en_US.ts
index 8ba27c7349..f61eb95d84 100644
--- a/dolphinscheduler-ui-next/src/locales/modules/en_US.ts
+++ b/dolphinscheduler-ui-next/src/locales/modules/en_US.ts
@@ -1242,7 +1242,8 @@ const datasource = {
   user_name: 'User Name',
   user_name_tips: 'Please enter your username',
   user_password: 'Password',
-  user_password_tips: 'Please enter your password'
+  user_password_tips: 'Please enter your password',
+  jdbc_format_tips: 'jdbc connection parameters is not a correct JSON format'
 }
 
 const data_quality = {
diff --git a/dolphinscheduler-ui-next/src/locales/modules/zh_CN.ts 
b/dolphinscheduler-ui-next/src/locales/modules/zh_CN.ts
index 73dbacbc4b..260c7e7dbe 100644
--- a/dolphinscheduler-ui-next/src/locales/modules/zh_CN.ts
+++ b/dolphinscheduler-ui-next/src/locales/modules/zh_CN.ts
@@ -1227,7 +1227,8 @@ const datasource = {
   user_name: '用户名',
   user_name_tips: '请输入用户名',
   user_password: '密码',
-  user_password_tips: '请输入密码'
+  user_password_tips: '请输入密码',
+  jdbc_format_tips: 'jdbc连接参数不是一个正确的JSON格式'
 }
 
 const data_quality = {
diff --git a/dolphinscheduler-ui-next/src/utils/index.ts 
b/dolphinscheduler-ui-next/src/utils/index.ts
index afce8157fc..f164e025fa 100644
--- a/dolphinscheduler-ui-next/src/utils/index.ts
+++ b/dolphinscheduler-ui-next/src/utils/index.ts
@@ -22,6 +22,7 @@ import log from './log'
 import downloadFile from './downloadFile'
 import copy from './clipboard'
 import removeUselessChildren from './tree-format'
+import isJson from './json'
 
 const utils = {
   mapping,
@@ -30,7 +31,8 @@ const utils = {
   log,
   downloadFile,
   copy,
-  removeUselessChildren
+  removeUselessChildren,
+  isJson
 }
 
 export default utils
diff --git a/dolphinscheduler-ui-next/src/utils/index.ts 
b/dolphinscheduler-ui-next/src/utils/json.ts
similarity index 67%
copy from dolphinscheduler-ui-next/src/utils/index.ts
copy to dolphinscheduler-ui-next/src/utils/json.ts
index afce8157fc..3ce941ddb5 100644
--- a/dolphinscheduler-ui-next/src/utils/index.ts
+++ b/dolphinscheduler-ui-next/src/utils/json.ts
@@ -15,22 +15,22 @@
  * limitations under the License.
  */
 
-import mapping from './mapping'
-import regex from './regex'
-import truncateText from './truncate-text'
-import log from './log'
-import downloadFile from './downloadFile'
-import copy from './clipboard'
-import removeUselessChildren from './tree-format'
-
-const utils = {
-  mapping,
-  regex,
-  truncateText,
-  log,
-  downloadFile,
-  copy,
-  removeUselessChildren
+/**
+ * Verify if it is in json format
+ */
+const isJson = (str: string) => {
+  if (typeof str === 'string') {
+    try {
+      const obj = JSON.parse(str)
+      if (typeof obj === 'object' && obj) {
+        return true
+      } else {
+        return false
+      }
+    } catch (e) {
+      return false
+    }
+  }
 }
 
-export default utils
+export default isJson
diff --git a/dolphinscheduler-ui-next/src/views/datasource/list/use-form.ts 
b/dolphinscheduler-ui-next/src/views/datasource/list/use-form.ts
index 6ac6e31e5d..e1c427875f 100644
--- a/dolphinscheduler-ui-next/src/views/datasource/list/use-form.ts
+++ b/dolphinscheduler-ui-next/src/views/datasource/list/use-form.ts
@@ -26,6 +26,7 @@ import type {
   IDataBaseOptionKeys,
   IDataSource
 } from './types'
+import utils from '@/utils'
 
 export function useForm(id?: number) {
   const { t } = useI18n()
@@ -109,6 +110,14 @@ export function useForm(id?: number) {
             return new Error(t('datasource.oracle_connect_type_tips'))
           }
         }
+      },
+      other: {
+        trigger: ['input', 'blur'],
+        validator() {
+          if (state.detailForm.other && !utils.isJson(state.detailForm.other)) 
{
+            return new Error(t('datasource.jdbc_format_tips'))
+          }
+        }
       }
     } as FormRules
   })

Reply via email to