Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ function clickNodes(item: any, data?: any) {
})),
}
}
item['properties']['condition'] = 'OR'
props.workflowRef?.addNode(item)

emit('clickNodes', item)
Expand All @@ -188,6 +189,7 @@ function onmousedown(item: any, data?: any) {
if (data.tool_type == 'DATA_SOURCE') {
item['properties'].kind = WorkflowKind.DataSource
}

item['properties']['node_data'] = {
...data,
tool_lib_id: data.id,
Expand All @@ -197,6 +199,7 @@ function onmousedown(item: any, data?: any) {
})),
}
}
item['properties']['condition'] = 'OR'
props.workflowRef?.onmousedown(item)
emit('onmousedown', item)
}
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 code appears to handle node creation based on user interactions with different tools (e.g., adding nodes of specific types like "PROCESS" or "DATA_SOURCE"). There are a few recommendations:

  1. Ensure that props.workflowRef is valid before calling its methods (addNode and onmousedown). Consider adding checks to avoid errors.
  2. In both functions (clickNodes and onmousedown), set 'condition' property to 'OR'. This seems consistent across updates, but ensure it fits the intended logic in your use case.
  3. If there's any validation needed on item, consider adding it at appropriate points within these functions for better clarity and maintainability.

Overall, the code looks generally correct for handling mouse events related to workflow node additions and modifications, but careful attention should be paid to ensuring method calls operate safely under all conditions.

Expand Down
3 changes: 2 additions & 1 deletion ui/src/components/workflow-dropdown-menu/knowledge/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ function clickNodes(item: any, data?: any) {
})),
}
}
item['properties']['condition'] = 'OR'
props.workflowRef?.addNode(item)

emit('clickNodes', item)
}

Expand All @@ -219,6 +219,7 @@ function onmousedown(item: any, data?: any) {
})),
}
}
item['properties']['condition'] = 'OR'
props.workflowRef?.onmousedown(item)
emit('onmousedown', item)
}
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 does not have any apparent syntax errors or logical flaws that would cause significant issues. However, there are several areas where improvements can be made:

  1. Null Checking: The line props.workflowRef?.addNode(item) includes a safe navigator operator (?.). It's good practice to ensure that the property is truthy before using it, but if you know for certain that workflowRef will never be null during execution, this could be unnecessary.

  2. Documentation and Naming Conventions: While the code is concise, clarity of naming could improve readability. For example, adding comments to explain each step or parameter might help future developers understand the intentions better.

  3. Suggestion for Optimizations: There isn't much room for optimization within these specific functions as they appear simple operations. However, if multiple similar functionalities exist across different parts of the system, consolidating them into common helper functions could reduce redundancy and maintainability.

  4. Type Handling: If props has its own TypeScript type definitions, make sure the types are correctly specified and consistent throughout your application. This ensures that all expected properties are present and behave accordingly without runtime errors.

Overall, the code seems functional with minor enhancements in terms of best practices such as documentation and potentially simplifying null checks if appropriate.

Expand Down
Loading