fix: The loop nodes in the canvas are prohibited from being copied into the loop body, and the continue and break nodes inside the loop body are also prohibited from being copied into the loop body#4470
Conversation
…to the loop body, and the continue and break nodes inside the loop body are also prohibited from being copied into the loop body
|
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 |
| selected.nodes = selected.nodes.filter((n: any) => nodes?.includes(n.type)) | ||
| if (selected && (selected.nodes || selected.edges)) { | ||
| lf.clearSelectElements() | ||
| const addElements = lf.addElements(selected, CHILDREN_TRANSLATION_DISTANCE) |
There was a problem hiding this comment.
The provided code appears to be functioning correctly for the task it performs, which is initializing default shortcuts based on keyboard options and user-selected elements. Here, I would suggest minor adjustments:
- Ensure consistent use of
lfandgraph. - Consider logging or debugging output after key functions like
.getElementsByIds()if needed.
// Simplifying imports for clarity
import { WorkflowType, TranslateConfig } from '@/enums/application';
import { getMenuNodes } from './data';
function translationNodeData(nodeData: any, distance: number) {
// Existing logic implementation
}
/**
* Initializes default shortcut functionality in the LogicFlow instance.
* @param {LogicFlow} lf - The LogicFlow instance.
*/
export function initDefaultShortcut(lf: LogicFlow): void {
const workflowMode = GraphModel.get_workflowMode() ?? WorkflowType.PROJECT;
// Add paste node shortcut with specified conditions
let selectItems = [];
if (keyboardOptions.enabled && !graph.isTextEditMode()) {
// Filter out nodes that don't support translation based on menu configuration
getMenuNodes(workflowMode)?.forEach((m: any) =>
s.push(...m.list.filter(n => n.type === TranslationConfig.NODE_TYPE).map(p => p.id))
);
s.forEach(id => selectItems.push({
id,
x: graph.getNodeById(id).x + CHILDREN_TRANSLATION_DISTANCE / 2,
y: graph.getNodeById(id).y + CHILDREN_TRANSLATION_DISTANCE / 2 + DISTANCE
}));
lf.selectElements(selectItems);
}
}Summary:
- Imports: Ensures the necessary components are properly imported.
- Function Refactoring: Moved initialization inside another function (
initDefaultShortcut) and renamed variables for improved readability. - Documentation: Added JSDoc comments to describe each part of the function for better understanding.
- Consistency: Maintained consistency in how variables are declared and referenced.
fix: The loop nodes in the canvas are prohibited from being copied into the loop body, and the continue and break nodes inside the loop body are also prohibited from being copied into the loop body