Browse Source

[Fix][UI Next][V1.0.0-Beta] Fix jdbc connect parameter validate bug (#9891)

3.0.0/version-upgrade
Devosend 2 years ago committed by GitHub
parent
commit
87dc42fcc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      dolphinscheduler-ui-next/src/locales/modules/en_US.ts
  2. 3
      dolphinscheduler-ui-next/src/locales/modules/zh_CN.ts
  3. 4
      dolphinscheduler-ui-next/src/utils/index.ts
  4. 36
      dolphinscheduler-ui-next/src/utils/json.ts
  5. 9
      dolphinscheduler-ui-next/src/views/datasource/list/use-form.ts

3
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 = {

3
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 = {

4
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

36
dolphinscheduler-ui-next/src/utils/json.ts

@ -0,0 +1,36 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* 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 isJson

9
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
})

Loading…
Cancel
Save