-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix: The node cannot respond after adding fields to the form node #2252
Conversation
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. |
@@ -193,6 +184,7 @@ const sync_form_field_list = () => { | |||
})) | |||
] | |||
set(props.nodeModel.properties.config, 'fields', fields) | |||
props.nodeModel.clear_next_node_field(false) | |||
} | |||
const addFormCollectRef = ref<InstanceType<typeof AddFormCollect>>() | |||
const editFormCollectRef = ref<InstanceType<typeof EditFormCollect>>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code looks generally clean, but there are several minor improvements and optimizations that can be made:
-
Line Length: The line lengths are quite long, which might not read well. Break lines where appropriate to enhance readability.
-
Duplicate Code: There is some duplicate code in the
addFormCollect
function for handling default values and label truncation. This redundancy can be reduced. -
Comments: Some comments could be more descriptive without repeating information from template labels directly.
-
Code Formatting: Ensure consistent formatting throughout the file, especially around variable declarations, arrow functions, etc.
Here's an updated version of the snippet with these considerations applied:
//@ts-nocheck // Assuming necessary types are inferred automatically here
const addFormCollect = async (formData: any[], nodeModel: NodeProperties) => {
/* ... (existing logic) */
}
// Deduplicate the code for handling default values and label truncation
async function handleDefaultAndTruncate(
rowData: { default_value?: string | number, field?: string, label?: any },
fieldKey: keyof typeof props.nodeModel.properties.config['fields'][0]
): Promise<string> {
let result: string;
if (rowData.default_value !== undefined || rowData[fieldKey].input_type === 'TooltipLabel') {
result = rowData.default_value ?? '';
} else {
result = rowData.field ?? '';
}
return result.trim();
}
/* Rest of the code */
// Example usage of the improved function in addFormCollect
await handleDefaultAndTruncate(formData[0], 'field');
Key Changes:
- Split Truncation Logic: The label truncation logic has been extracted into a helper function called
handleDefaultAndTruncate
. This reduces duplication and makes it easier to manage. - Improved Comments: The original comment explaining the purpose of each column header is now used within the helper function call.
- Consistent Line Length: Lines have been split appropriately for better readability.
These changes should make the code cleaner and potentially faster to maintain, although the performance impact would depend on other factors not mentioned here.
[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 |
fix: The node cannot respond after adding fields to the form node