From 8deb3914054e440b2f9a6f95648583d16ad97d5f Mon Sep 17 00:00:00 2001
From: Kennen <317052920@qq.com>
Date: Wed, 7 Jun 2023 17:02:15 +0800
Subject: [PATCH 1/3] feat(external-storage): Add mongo ssl #145573
---
.../src/views/external-storage/List.vue | 161 ++++++++++++++----
1 file changed, 128 insertions(+), 33 deletions(-)
diff --git a/packages/business/src/views/external-storage/List.vue b/packages/business/src/views/external-storage/List.vue
index 1b30675a63..5b542f2a2b 100644
--- a/packages/business/src/views/external-storage/List.vue
+++ b/packages/business/src/views/external-storage/List.vue
@@ -95,6 +95,15 @@
resize="none"
>
+
+
+
@@ -154,9 +163,10 @@ import { externalStorageApi } from '@tap/api'
import { TablePage, EXTERNAL_STORAGE_TYPE_MAP } from '@tap/business'
import { FilterBar, Drawer } from '@tap/component'
import { openUrl } from '@tap/shared'
+import { SchemaToForm } from '@tap/form'
export default {
- components: { TablePage, FilterBar, Drawer },
+ components: { TablePage, FilterBar, Drawer, SchemaToForm },
data() {
return {
loading: false,
@@ -189,7 +199,8 @@ export default {
info: [],
labelWidth: '120px',
showUsingTaskDialog: false,
- usingTasks: []
+ usingTasks: [],
+ schemaData: null
}
},
computed: {
@@ -207,6 +218,75 @@ export default {
this.getFilterItems()
const { locale } = this.$i18n
this.labelWidth = locale === 'en' ? '220px' : '120px'
+ this.schemaData = {
+ type: 'object',
+ properties: {
+ ssl: {
+ default: false,
+ 'x-decorator': 'FormItem',
+ 'x-component': 'Switch',
+ 'x-reactions': [
+ {
+ fulfill: {
+ state: {
+ visible: '{{$self.value===true}}'
+ }
+ },
+ target: '*(sslKey,sslPass,sslValidate)'
+ }
+ ],
+ 'x-component-props': {
+ optionType: 'button'
+ },
+ type: 'boolean',
+ title: '使用 TLS/SSL 连接',
+ 'x-index': 80
+ },
+ sslCA: {
+ 'x-decorator': 'FormItem',
+ 'x-component': 'TextFileReader',
+ type: 'string',
+ title: '证书颁发机构',
+ 'x-index': 120,
+ fileNameField: 'sslCAFile',
+ required: true
+ },
+ sslKey: {
+ 'x-decorator': 'FormItem',
+ 'x-component': 'TextFileReader',
+ type: 'string',
+ title: '客户端私钥',
+ 'x-index': 90,
+ fileNameField: 'sslKeyFile',
+ required: true
+ },
+ sslPass: {
+ 'x-decorator': 'FormItem',
+ 'x-component': 'Password',
+ type: 'string',
+ title: '私钥密码',
+ 'x-index': 100
+ },
+ sslValidate: {
+ 'x-decorator': 'FormItem',
+ 'x-component': 'Switch',
+ show: false,
+ 'x-reactions': [
+ {
+ fulfill: {
+ state: {
+ visible: '{{$self.value===true}}'
+ }
+ },
+ target: 'sslCA'
+ }
+ ],
+ type: 'boolean',
+ title: '验证服务端证书',
+ 'x-index': 110
+ }
+ }
+ }
},
methods: {
getFilterItems() {
@@ -281,37 +361,45 @@ export default {
submit() {
this.$refs.form.validate(async valid => {
if (valid) {
- this.loading = true
- let { id, name, type, uri, defaultStorage } = this.form
- let params = {
- id,
- name,
- type,
- uri,
- defaultStorage
- }
- const catchFunc = () => {
- this.loading = false
- }
- if (id) {
- await externalStorageApi
- .updateById(id, params)
- .then(() => {
- this.table.fetch()
- this.dialogVisible = false
- this.loading = false
- })
- .catch(catchFunc)
- } else {
- await externalStorageApi
- .post(params)
- .then(() => {
- this.table.fetch()
- this.dialogVisible = false
- this.loading = false
- })
- .catch(catchFunc)
- }
+ const schemaFormInstance = this.$refs.schemaToForm.getForm?.()
+ schemaFormInstance?.validate().then(async () => {
+ let formValues = this.$refs.schemaToForm?.getFormValues?.()
+
+ this.loading = true
+ let { id, name, type, uri, defaultStorage } = this.form
+ let params = Object.assign(
+ {
+ id,
+ name,
+ type,
+ uri,
+ defaultStorage
+ },
+ formValues
+ )
+ const catchFunc = () => {
+ this.loading = false
+ }
+ if (id) {
+ await externalStorageApi
+ .updateById(id, params)
+ .then(() => {
+ this.table.fetch()
+ this.dialogVisible = false
+ this.loading = false
+ })
+ .catch(catchFunc)
+ } else {
+ await externalStorageApi
+ .post(params)
+ .then(() => {
+ this.table.fetch()
+ this.dialogVisible = false
+ this.loading = false
+ })
+ .catch(catchFunc)
+ }
+ })
}
})
},
@@ -445,4 +533,11 @@ export default {
}
}
}
+.scheme-to-form {
+ ::v-deep {
+ .formily-element-form-item {
+ margin-bottom: 18px;
+ }
+ }
+}
From 764e4841e80bbb7d37089b4a3dacb927b2b9989a Mon Sep 17 00:00:00 2001
From: Kennen <317052920@qq.com>
Date: Wed, 7 Jun 2023 17:04:37 +0800
Subject: [PATCH 2/3] refactor(external-storage): Extract Chinese
---
packages/business/src/locale/lang/en.js | 7 ++++++-
packages/business/src/locale/lang/zh-CN.js | 7 ++++++-
packages/business/src/locale/lang/zh-TW.js | 7 ++++++-
packages/business/src/views/external-storage/List.vue | 10 +++++-----
4 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/packages/business/src/locale/lang/en.js b/packages/business/src/locale/lang/en.js
index 2bed168f97..43c5ba1220 100644
--- a/packages/business/src/locale/lang/en.js
+++ b/packages/business/src/locale/lang/en.js
@@ -1114,5 +1114,10 @@ export default {
'Are you sure to clear the check condition that the index field is empty? ',
packages_business_components_conditionbox_suoyinziduanwei: 'The index field is empty',
packages_business_components_conditionbox_yijianqingchusuo:
- 'One key to clear the condition that the index field is empty'
+ 'One key to clear the condition that the index field is empty',
+ packages_business_external_storage_list_yanzhengfuwuduan: 'Verify server certificate',
+ packages_business_external_storage_list_siyaomima: 'Private key password',
+ packages_business_external_storage_list_kehuduansiyao: 'Client private key',
+ packages_business_external_storage_list_zhengshubanfaji: 'Certificate Authority',
+ packages_business_external_storage_list_shiyongTls: 'Connect using TLS/SSL'
}
diff --git a/packages/business/src/locale/lang/zh-CN.js b/packages/business/src/locale/lang/zh-CN.js
index 4efa676572..a85ad973fd 100644
--- a/packages/business/src/locale/lang/zh-CN.js
+++ b/packages/business/src/locale/lang/zh-CN.js
@@ -1063,5 +1063,10 @@ export default {
packages_business_shared_cache_list_qingxianxiugaiwai: '外存不存在,请先修改外存配置后,再启动。',
packages_business_components_conditionbox_shifouquerenqing: '是否确认清除索引字段为空的校验条件?',
packages_business_components_conditionbox_suoyinziduanwei: '索引字段为空',
- packages_business_components_conditionbox_yijianqingchusuo: '一键清除索引字段为空的条件'
+ packages_business_components_conditionbox_yijianqingchusuo: '一键清除索引字段为空的条件',
+ packages_business_external_storage_list_yanzhengfuwuduan: '验证服务端证书',
+ packages_business_external_storage_list_siyaomima: '私钥密码',
+ packages_business_external_storage_list_kehuduansiyao: '客户端私钥',
+ packages_business_external_storage_list_zhengshubanfaji: '证书颁发机构',
+ packages_business_external_storage_list_shiyongTls: '使用 TLS/SSL 连接'
}
diff --git a/packages/business/src/locale/lang/zh-TW.js b/packages/business/src/locale/lang/zh-TW.js
index 05b5194a49..733d540024 100644
--- a/packages/business/src/locale/lang/zh-TW.js
+++ b/packages/business/src/locale/lang/zh-TW.js
@@ -1055,5 +1055,10 @@ export default {
packages_business_shared_cache_list_qingxianxiugaiwai: '外存不存在,請先修改外存配置後,再啟動。',
packages_business_components_conditionbox_shifouquerenqing: '是否確認清除索引字段為空的校驗條件? ',
packages_business_components_conditionbox_suoyinziduanwei: '索引字段為空',
- packages_business_components_conditionbox_yijianqingchusuo: '一鍵清除索引字段為空的條件'
+ packages_business_components_conditionbox_yijianqingchusuo: '一鍵清除索引字段為空的條件',
+ packages_business_external_storage_list_yanzhengfuwuduan: '驗證服務端證書',
+ packages_business_external_storage_list_siyaomima: '私鑰密碼',
+ packages_business_external_storage_list_kehuduansiyao: '客戶端私鑰',
+ packages_business_external_storage_list_zhengshubanfaji: '證書頒發機構',
+ packages_business_external_storage_list_shiyongTls: '使用 TLS/SSL 連接'
}
diff --git a/packages/business/src/views/external-storage/List.vue b/packages/business/src/views/external-storage/List.vue
index 5b542f2a2b..479be85b36 100644
--- a/packages/business/src/views/external-storage/List.vue
+++ b/packages/business/src/views/external-storage/List.vue
@@ -239,14 +239,14 @@ export default {
optionType: 'button'
},
type: 'boolean',
- title: '使用 TLS/SSL 连接',
+ title: i18n.t('packages_business_external_storage_list_shiyongTls'),
'x-index': 80
},
sslCA: {
'x-decorator': 'FormItem',
'x-component': 'TextFileReader',
type: 'string',
- title: '证书颁发机构',
+ title: i18n.t('packages_business_external_storage_list_zhengshubanfaji'),
'x-index': 120,
fileNameField: 'sslCAFile',
required: true
@@ -255,7 +255,7 @@ export default {
'x-decorator': 'FormItem',
'x-component': 'TextFileReader',
type: 'string',
- title: '客户端私钥',
+ title: i18n.t('packages_business_external_storage_list_kehuduansiyao'),
'x-index': 90,
fileNameField: 'sslKeyFile',
required: true
@@ -264,7 +264,7 @@ export default {
'x-decorator': 'FormItem',
'x-component': 'Password',
type: 'string',
- title: '私钥密码',
+ title: i18n.t('packages_business_external_storage_list_siyaomima'),
'x-index': 100
},
sslValidate: {
@@ -282,7 +282,7 @@ export default {
}
],
type: 'boolean',
- title: '验证服务端证书',
+ title: i18n.t('packages_business_external_storage_list_yanzhengfuwuduan'),
'x-index': 110
}
}
From d221a653a923e0df08c4e7a40173021626f12d91 Mon Sep 17 00:00:00 2001
From: Kennen <317052920@qq.com>
Date: Wed, 7 Jun 2023 17:16:54 +0800
Subject: [PATCH 3/3] refactor(external-storage): Add schemaLabelWidth
---
packages/business/src/views/external-storage/List.vue | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/packages/business/src/views/external-storage/List.vue b/packages/business/src/views/external-storage/List.vue
index 479be85b36..a4f7713d4c 100644
--- a/packages/business/src/views/external-storage/List.vue
+++ b/packages/business/src/views/external-storage/List.vue
@@ -101,7 +101,7 @@
ref="schemaToForm"
:schema="schemaData"
:colon="true"
- label-width="140"
+ :label-width="schemaLabelWidth"
>
@@ -198,6 +198,7 @@ export default {
details: '',
info: [],
labelWidth: '120px',
+ schemaLabelWidth: 120,
showUsingTaskDialog: false,
usingTasks: [],
schemaData: null
@@ -218,6 +219,7 @@ export default {
this.getFilterItems()
const { locale } = this.$i18n
this.labelWidth = locale === 'en' ? '220px' : '120px'
+ this.schemaLabelWidth = locale === 'en' ? 220 : 120
this.schemaData = {
type: 'object',
properties: {