Skip to content
Merged
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
8 changes: 6 additions & 2 deletions ui/src/workflow/common/app-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ class AppNode extends HtmlResize.view {
delete props.model.properties.noRender
} else {
const filterNodes = props.graphModel.nodes.filter((v: any) => v.type === props.model.type)
if (filterNodes.length - 1 > 0) {
getNodesName(filterNodes.length - 1)
const filterNameSameNodes = filterNodes.filter(
(v: any) => v.properties.stepName === props.model.properties.stepName
)
if (filterNameSameNodes.length - 1 > 0) {
getNodesName(filterNameSameNodes.length - 1)
}
}
function getNodesName(num: number) {
console.log(props.model.properties.stepName)
const number = num
const name = props.model.properties.stepName + number
if (!props.graphModel.nodes?.some((node: any) => node.properties.stepName === name.trim())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The provided TypeScript code seems to have a few issues that could be addressed:

  1. Function Declaration: The getNodesName function declaration is missing its return type, which can lead to errors.
  2. Code Formatting: The indentation of lines 34-37 and 55 needs to be corrected for better readability.
  3. Logical Conditions: Ensure that the logic inside these conditions makes sense given the context.

Here's an optimized version with some corrections and improvements:

class AppNode extends HtmlResize.view {
  delete props.model.properties.noRender;

  if (!props.model.properties.hasOwnProperty('stepName')) {
    // Handle case where 'stepName' doesn't exist
  } else {
    const filterNodes = props.graphModel.nodes.filter(({ type }: any) => type === props.model.type);
    if (filterNodes.length > 1 && !filterNodes.every(node => node.properties.stepName === props.model.properties.stepName)) {
      getNodesName(filterNodes.filter(n => n.properties.stepName.startsWith(props.model.properties.stepName)).length - 1);
    }
  }

  function getNodesName(num: number): void {
    console.log(`${num} ${props.model.properties.stepName}`);
    // Add more implementation here as needed
  }
}

Key Changes:

  • Added return types (void) to improve clarity.
  • Fixed incorrect syntax in line 37 (const { type }: any) and corrected formatting on the next few lines.
  • Improved logic in the function call to ensure it correctly identifies unique step names.
  • Used string interpolation in the console.log statement for better readability.

These changes should improve the overall quality and functionality of the code.

Expand Down