Skip to content

fix: The same observable object cannot appear twice in the same tree#2812

Merged
wxg0103 merged 1 commit intomainfrom
pr@main@fix_1054451
Apr 7, 2025
Merged

fix: The same observable object cannot appear twice in the same tree#2812
wxg0103 merged 1 commit intomainfrom
pr@main@fix_1054451

Conversation

@shaohuzhang1
Copy link
Copy Markdown
Contributor

fix: The same observable object cannot appear twice in the same tree --bug=1054451 --user=王孝刚 【应用嵌套】高级编排中应用关联设置用户输入参数的应用,会报该应用不可用 https://www.tapd.cn/57709429/s/1681701

--bug=1054451 --user=王孝刚 【应用嵌套】高级编排中应用关联设置用户输入参数的应用,会报该应用不可用 https://www.tapd.cn/57709429/s/1681701
@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot bot commented Apr 7, 2025

Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot bot commented Apr 7, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@wxg0103 wxg0103 merged commit ecd5faf into main Apr 7, 2025
4 checks passed
@wxg0103 wxg0103 deleted the pr@main@fix_1054451 branch April 7, 2025 10:46
)
const merge_api_input_field_list = new_api_input_field_list.map((item: any) => {
const find_field = old_api_input_field_list.find(
(old_item: any) => old_item.variable == item.variable
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided code looks generally correct, but there are a few areas where optimizations can be made:

  • Dealing with Duplicates: The cloneDeep function is used to ensure that the original array structures (api_input_field_list and user_input_field_list) are not modified within the update_field method. This can prevent unintended side effects.

  • Performance Considerations: If old_api_input_field_list, old_user_input_field_list, new_api_input_field_list, or new_user_input_field_list could be very large arrays, manually cloning them might become inefficient due to memory usage. In such cases, consider using deep-copying libraries specifically designed for performance, though this seems unnecessary unless explicitly specified in your context.

Here's the suggested enhancement to improve readability slightly by organizing the clones neatly:

const oldApiInputFieldList = cloneDeep(props.nodeModel.properties.node_data.api_input_field_list);
const oldUserInputFieldList = cloneDeep(props.nodeModel.properties.node_data.user_input_field_list);

if (isWorkFlow(ok.data.type)) {
  const nodeData = ok.data.work_flow.nodes[0].properties.node_data;
  const newApiInputFieldList = cloneDeep(ok.data.work_flow.nodes[0].properties.api_input_field_list);
  const newUserInputFieldList = cloneDeep(ok.data.work_flow.nodes[0].properties.user_input_field_list);

  const mergeApiInputFieldList = newApiInputFieldList.map((item: any) => {
    const findField = oldApiInputFieldList.find((oldItem: any) => oldItem.variable === item.variable);
    return findField || item; // Merge logic here
  });
}

In summary, maintaining clean and efficient code while handling potentially large data sets depends on specific needs and constraints. For simplicity and clarity, manual deep-cloning ensures correctness without significant overhead in many scenarios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants