Skip to content

Commit

Permalink
[Bugfix]Connect-JSON模式下的JSON格式和官方API的格式不一致(#1048) (#1153)
Browse files Browse the repository at this point in the history
请不要在没有先创建Issue的情况下创建Pull Request。

## 变更的目的是什么

XXXXX

## 简短的更新日志

XX

## 验证这一变化

XXXX

请遵循此清单,以帮助我们快速轻松地整合您的贡献:

* [ ] 一个 PR(Pull Request的简写)只解决一个问题,禁止一个 PR 解决多个问题;
* [ ] 确保 PR 有对应的 Issue(通常在您开始处理之前创建),除非是书写错误之类的琐碎更改不需要 Issue ;
* [ ] 格式化 PR 及 Commit-Log 的标题及内容,例如 #861 。PS:Commit-Log 需要在 Git Commit
代码时进行填写,在 GitHub 上修改不了;
* [ ] 编写足够详细的 PR 描述,以了解 PR 的作用、方式和原因;
* [ ] 编写必要的单元测试来验证您的逻辑更正。如果提交了新功能或重大更改,请记住在 test 模块中添加 integration-test;
* [ ] 确保编译通过,集成测试通过;
  • Loading branch information
Wyb7290 authored Oct 18, 2023
1 parent 3f81799 commit 1adfa63
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ export default forwardRef(
success?: {
connectClusterId: number;
connectorName: string;
configs: {
config: {
[key: string]: any;
};
};
Expand Down Expand Up @@ -991,7 +991,7 @@ export default forwardRef(
success: {
connectClusterId: res[0].connectClusterId,
connectorName: result['name'],
configs: result,
config: result,
},
});
},
Expand All @@ -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();
}
});
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const PLACEHOLDER = `配置格式如下
{
"connectClusterName": "", // Connect Cluster 名称
"configs": { // 具体配置项
"config": { // 具体配置项
"name": "",
"connector.class": "",
"tasks.max": 1,
Expand Down Expand Up @@ -47,7 +47,7 @@ export default forwardRef((props: any, ref) => {
configs: JSON.stringify(
{
connectClusterName,
configs: defaultConfigs,
config: defaultConfigs,
},
null,
2
Expand All @@ -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(
Expand Down Expand Up @@ -198,34 +198,34 @@ 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 字段');
}
}

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();
},
Expand Down

0 comments on commit 1adfa63

Please sign in to comment.