fix: Adjustment of workflow node name auto increment rule(#2562)#2576
fix: Adjustment of workflow node name auto increment rule(#2562)#2576wangdan-fit2cloud merged 1 commit intomainfrom
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. 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/test-infra 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 |
| 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())) { |
There was a problem hiding this comment.
The provided TypeScript code seems to have a few issues that could be addressed:
- Function Declaration: The
getNodesNamefunction declaration is missing its return type, which can lead to errors. - Code Formatting: The indentation of lines 34-37 and 55 needs to be corrected for better readability.
- 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.logstatement for better readability.
These changes should improve the overall quality and functionality of the code.
What this PR does / why we need it?
Summary of your change
Please indicate you've done the following: