From 72da3a3270f5169e6436a502c4b1a30d314f0b2a Mon Sep 17 00:00:00 2001 From: erge Date: Sat, 16 Sep 2023 16:23:30 +0800 Subject: [PATCH] =?UTF-8?q?[Bugfix]Connect-JSON=E6=A8=A1=E5=BC=8F=E4=B8=8B?= =?UTF-8?q?=E7=9A=84JSON=E6=A0=BC=E5=BC=8F=E5=92=8C=E5=AE=98=E6=96=B9API?= =?UTF-8?q?=E7=9A=84=E6=A0=BC=E5=BC=8F=E4=B8=8D=E4=B8=80=E8=87=B4(#1048)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/Connect/AddConnector.tsx | 10 +++---- .../src/pages/Connect/AddConnectorUseJSON.tsx | 30 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/km-console/packages/layout-clusters-fe/src/pages/Connect/AddConnector.tsx b/km-console/packages/layout-clusters-fe/src/pages/Connect/AddConnector.tsx index ef6a55bdf..5ecdcce10 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/Connect/AddConnector.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/Connect/AddConnector.tsx @@ -949,7 +949,7 @@ export default forwardRef( success?: { connectClusterId: number; connectorName: string; - configs: { + config: { [key: string]: any; }; }; @@ -991,7 +991,7 @@ export default forwardRef( success: { connectClusterId: res[0].connectClusterId, connectorName: result['name'], - configs: result, + config: result, }, }); }, @@ -1015,7 +1015,7 @@ export default forwardRef( curClusterName = cluster.label; } }); - (jsonRef as any)?.onOpen(operateInfo.type, curClusterName, info.success.configs); + (jsonRef as any)?.onOpen(operateInfo.type, curClusterName, info.success.config); onClose(); } }); @@ -1028,9 +1028,9 @@ export default forwardRef( setCurrentStep(info.error); } else { setSubmitLoading(true); - Object.entries(info.success.configs).forEach(([key, val]) => { + Object.entries(info.success.config).forEach(([key, val]) => { if (val === null) { - delete info.success.configs[key]; + delete info.success.config[key]; } }); Utils.put(api.validateConnectorConfig, info.success).then( diff --git a/km-console/packages/layout-clusters-fe/src/pages/Connect/AddConnectorUseJSON.tsx b/km-console/packages/layout-clusters-fe/src/pages/Connect/AddConnectorUseJSON.tsx index b93513460..e06ede24e 100644 --- a/km-console/packages/layout-clusters-fe/src/pages/Connect/AddConnectorUseJSON.tsx +++ b/km-console/packages/layout-clusters-fe/src/pages/Connect/AddConnectorUseJSON.tsx @@ -10,7 +10,7 @@ const PLACEHOLDER = `配置格式如下 { "connectClusterName": "", // Connect Cluster 名称 - "configs": { // 具体配置项 + "config": { // 具体配置项 "name": "", "connector.class": "", "tasks.max": 1, @@ -47,7 +47,7 @@ export default forwardRef((props: any, ref) => { configs: JSON.stringify( { connectClusterName, - configs: defaultConfigs, + config: defaultConfigs, }, null, 2 @@ -63,13 +63,13 @@ export default forwardRef((props: any, ref) => { form.validateFields().then( (data) => { const postData = JSON.parse(data.configs); - postData.connectorName = postData.configs.name; + postData.connectorName = postData.config.name; postData.connectClusterId = connectClusters.find((cluster) => cluster.label === postData.connectClusterName).value; delete postData.connectClusterName; - Object.entries(postData.configs).forEach(([key, val]) => { + Object.entries(postData.config).forEach(([key, val]) => { if (val === null) { - delete postData.configs[key]; + delete postData.config[key]; } }); Utils.put(api.validateConnectorConfig, postData).then( @@ -198,20 +198,20 @@ export default forwardRef((props: any, ref) => { } } - if (!v.configs || typeof v.configs !== 'object') { - return Promise.reject('内容缺少 configs 字段或字段格式错误'); + if (!v.config || typeof v.config !== 'object') { + return Promise.reject('内容缺少 config 字段或字段格式错误'); } else { // 校验 connectorName 字段 - if (!v.configs.name) { - return Promise.reject('configs 字段下缺少 name 项'); + if (!v.config.name) { + return Promise.reject('config 字段下缺少 name 项'); } else { - if (type === 'edit' && v.configs.name !== defaultConfigs.name) { + if (type === 'edit' && v.config.name !== defaultConfigs.name) { return Promise.reject('编辑模式下不允许修改 name 字段'); } } - if (!v.configs['connector.class']) { - return Promise.reject('configs 字段下缺少 connector.class 项'); - } else if (type === 'edit' && v.configs['connector.class'] !== defaultConfigs['connector.class']) { + if (!v.config['connector.class']) { + return Promise.reject('config 字段下缺少 connector.class 项'); + } else if (type === 'edit' && v.config['connector.class'] !== defaultConfigs['connector.class']) { return Promise.reject('编辑模式下不允许修改 connector.class 字段'); } } @@ -219,13 +219,13 @@ export default forwardRef((props: any, ref) => { if (type === 'create') { // 异步校验 connector 名称是否重复 以及 className 是否存在 return Promise.all([ - Utils.request(api.isConnectorExist(connectClusterId, v.configs.name)), + Utils.request(api.isConnectorExist(connectClusterId, v.config.name)), Utils.request(api.getConnectorPlugins(connectClusterId)), ]).then( ([data, plugins]: [any, ConnectorPlugin[]]) => { return data?.exist ? Promise.reject('name 与已有 Connector 重复') - : plugins.every((plugin) => plugin.className !== v.configs['connector.class']) + : plugins.every((plugin) => plugin.className !== v.config['connector.class']) ? Promise.reject('该 connectCluster 下不存在 connector.class 项配置的插件') : Promise.resolve(); },