fix: Clicking on the website data source cannot open the data source settings interface#4446
Conversation
…settings interface
|
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. DetailsInstructions 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-sigs/prow repository. |
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| } | ||
| node_id = n | ||
| ? [WorkflowType.DataSourceLocalNode, WorkflowType.DataSourceWebNode].includes(n.type) | ||
| ? n.type |
There was a problem hiding this comment.
The provided code snippet seems mostly correct for its purpose, but there is one suggestion for improvement:
if (n !== undefined && n.properties.node_data && n.properties.node_data.tool_lib_id) {
extra.value.current_tool_id = n.properties.node_data.tool_lib_id;
}In JavaScript/TypeScript, undefined cannot be used directly to check for truthiness due to coercion rules. Using strict equality checks (!==) or ensuring that n is defined prevents unnecessary comparisons with other falsy values. This change improves clarity and correctness.
Here's the optimized version of the function:
const sourceChange = (node_id: string) => {
base_form_data.value.node_id = node_id
const n = source_node_list.value.find((n: any) => n.id === node_id);
if (n && n.properties.node_data?.tool_lib_id) {
extra.value.current_tool_id = n.properties.node_data.tool_lib_id;
}
// ... rest of the original function ...
};This modification adds a conditional check before accessing n.type after filtering source_node_list. The use of optional chaining operator (?.) makes the expression safer by avoiding errors when n.properties.node_data is not available.
fix: Clicking on the website data source cannot open the data source settings interface