Skip to content

fix: Edit advanced orchestration applications, add application nodes, and display that some applications are unavailable after being added #2945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2025

Conversation

shaohuzhang1
Copy link
Contributor

fix: Edit advanced orchestration applications, add application nodes, and display that some applications are unavailable after being added

… and display that some applications are unavailable after being added
Copy link

f2c-ci-robot bot commented Apr 22, 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.

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.

Copy link

f2c-ci-robot bot commented Apr 22, 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.

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

@@ -294,6 +302,7 @@ const update_field = () => {
}
})
.catch((err) => {
console.log(err)
set(props.nodeModel.properties, 'status', 500)
})
}
Copy link
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 appears to be a functional component for updating field properties within a workflow node data structure. The key operations involve merging new_api_input_field_list and old_api_input_field_list, handling missing fields, and similarly for user_input_field_list. Here are some review points to consider:

Regularity Checks

  1. Function Definition: The function is defined but lacks documentation about what it does or its purpose.
  2. Error Handling: There's no logging outside of catching an error (err) which means the exact nature of errors might not be fully captured.

Potential Issues

  1. Empty Lists: If either new_api_input_field_list or old_api_input_field_list is empty, attempting to map over them without checking for emptiness can lead to undefined behavior.

  2. Label Assignment: Ensure that the assignment logic for labels handles both object values and primitive types correctly.

  3. Status Update: While using set(props.nodeModel.properties, 'status', 500) when there's an error is useful, it would generally be more informative to include specific error messages in logs or UI updates.

Optimization Suggestions

  1. Avoid Nullish Coalescing Twice:

    const merge_user_input_field_list = new_user_input_field_list ||
      [].map((item: any) => {
        // Existing code
      });

    You can optimize this by removing one level of nesting.

  2. Use Immutability Libraries:
    Consider using libraries like Ramda for utility functions that help with immutability better than plain JavaScript methods.

    Example usage with Ramda:

    import { mergeWithKeyRight } from 'ramda';
    
    const merge_with_right = (key, val1, val2) =>
      typeof val1 === 'string' ? val1 : typeof val2 === 'string' ? val2 : null;
    
    const merge_api_input_field_list = old_api_input_field_list
      .reduce((acc, oldItem) => ({
        ...acc,
        [oldItem.variable]: newItem || oldItem
      }), {});
    
    const merge_user_input_field_list = old_user_input_field_list
      .reduce((acc, oldItem) => ({
        ...acc,
        [oldItem.field]: newItem || oldItem
      }), {});
      
    set(
      props.nodeModel.properties.node_data,
      'api_input_field_list',
      Object.values(merge_api_input_field_list).map(item => ({...item, value: item.value}))
    );
    
    set(
      props.nodeModel.properties.node_data,
      'user_input_field_list',
      Object.values(merge_user_intput_field_list).map(item => ({...item, value: item.value}))
    );
  3. Code Readability: Break down complex conditional checks into separate helper functions or inline conditions where necessary.

  4. Consistent Logic Across Fields:
    Ensure consistent naming and approach for finding fields across different input lists to avoid redundancy and complexity.

Conclusion

The provided code is mostly functional, with minor improvements suggested for code readability and efficiency. Addressing these points will enhance maintainability and performance.

@shaohuzhang1 shaohuzhang1 merged commit 6484fef into main Apr 22, 2025
4 of 5 checks passed
@shaohuzhang1 shaohuzhang1 deleted the pr@main@fix_application_node branch April 22, 2025 03:25
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.

1 participant