-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix: Add application nodes in advanced orchestration, unpublished applications are not filtered out #3820
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: Add application nodes in advanced orchestration, unpublished applications are not filtered out #3820
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,10 +53,6 @@ function visibleChange(bool: boolean) { | |
options.value = props.global | ||
? props.nodeModel | ||
.get_up_node_field_list(false, true) | ||
.map((v: any) => { | ||
console.log(v) | ||
return v | ||
}) | ||
.filter( | ||
(v: any) => ['global', 'chat'].includes(v.value) && v.children && v.children.length > 0, | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code does not contain any obvious errors, but there are some areas that could be improved for better performance and readability:
Here's the refined version of the code based on these observations: function visibleChange(bool: boolean) {
const fields = props.global ? props.nodeModel.get_up_node_field_list(false, true).filter(
(item: any) => ['global', 'chat'].includes(item.value) && item.children && item.children.length > 0
);
fields.forEach((field: any) => {
console.log(field); // Log field only when included in the final list
});
options.value = fields; // Update options value only after processing
} These changes make the code cleaner and more efficient while maintaining the intended functionality. |
||
|
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 provided code is mostly correct, but there are a few areas to consider:
Type Annotations: While TypeScript annotations (
any
) can be useful for dynamic typing, they make it harder to catch type errors. Consider explicitly defining types foritem
, such as aninterface
ortype
. This will help catch issues at compile time.Error Handling: The function does not include error handling mechanisms. If the API call fails, no alert or exception is thrown. It would be beneficial to add try-catch blocks around the API call to handle these cases gracefully.
Code Organization: While the logic looks clean, you might want to further divide the functionality into smaller, reusable functions if this function grows in complexity.
Performance Considerations: Ensure that the filtering operation on
res.data
is efficient. IfapplicationList.value
could potentially contain a lot of data, consider memoization techniques or more optimized filtering strategies.Here's an example with improved type annotations and added exception handling:
Additional Recommendations:
/api/folders/current
with environment variables or configuration settings to improve maintainability.