This is an automated email from the ASF dual-hosted git repository. kunwp1 pushed a commit to branch chris-big-object-version-0 in repository https://gitbox.apache.org/repos/asf/texera.git
commit 611f50868691ddbaa4d76bae83462aca39feee39 Author: Xinyuan Lin <[email protected]> AuthorDate: Tue Oct 14 13:09:30 2025 -0700 refactor(frontend): Simplify onClickToggleGrids logic (#3896) --- .../app/workspace/component/menu/menu.component.ts | 4 +++- .../workflow-editor/workflow-editor.component.ts | 21 --------------------- .../workflow-graph/model/joint-graph-wrapper.ts | 16 ---------------- 3 files changed, 3 insertions(+), 38 deletions(-) diff --git a/frontend/src/app/workspace/component/menu/menu.component.ts b/frontend/src/app/workspace/component/menu/menu.component.ts index b26d1e82b7..4b5c3835f5 100644 --- a/frontend/src/app/workspace/component/menu/menu.component.ts +++ b/frontend/src/app/workspace/component/menu/menu.component.ts @@ -462,7 +462,9 @@ export class MenuComponent implements OnInit, OnDestroy { * This option is only for the current session and will be cleared on refresh. */ public onClickToggleGrids(): void { - this.workflowActionService.getJointGraphWrapper().toggleGrids(); + const paper = this.workflowActionService.getJointGraphWrapper().mainPaper; + const current = paper.options.gridSize || 1; + paper.setGridSize((current % 2) + 1); } /** diff --git a/frontend/src/app/workspace/component/workflow-editor/workflow-editor.component.ts b/frontend/src/app/workspace/component/workflow-editor/workflow-editor.component.ts index 6f53fa7371..a334b48603 100644 --- a/frontend/src/app/workspace/component/workflow-editor/workflow-editor.component.ts +++ b/frontend/src/app/workspace/component/workflow-editor/workflow-editor.component.ts @@ -87,7 +87,6 @@ export class WorkflowEditorComponent implements OnInit, AfterViewInit, OnDestroy editorWrapper!: HTMLElement; paper!: joint.dia.Paper; private interactive: boolean = true; - private gridOn: boolean = false; private _onProcessKeyboardActionObservable: Subject<void> = new Subject(); private wrapper; private currentOpenedOperatorID: string | null = null; @@ -169,7 +168,6 @@ export class WorkflowEditorComponent implements OnInit, AfterViewInit, OnDestroy this.handleElementCut(); this.handleElementPaste(); this.handleLinkCursorHover(); - this.handleGridsToggle(); if (this.config.env.linkBreakpointEnabled && this.workflowActionService.getHighlightingEnabled()) { this.handleLinkBreakpoint(); } @@ -1246,25 +1244,6 @@ export class WorkflowEditorComponent implements OnInit, AfterViewInit, OnDestroy return this.workflowActionService.getTexeraGraph().getOperator(operatorID).outputPorts.length == 0; } - /** - * This function handles the event stream from jointGraph to toggle the grids in jointPaper on or off. - * @private - */ - private handleGridsToggle(): void { - this.wrapper - .getJointPaperGridsToggleStream() - .pipe(untilDestroyed(this)) - .subscribe(() => { - if (this.gridOn) { - this.paper.setGridSize(1); - this.gridOn = false; - } else { - this.paper.setGridSize(2); - this.gridOn = true; - } - }); - } - /** * Handles mouse events to enable shared cursor. */ diff --git a/frontend/src/app/workspace/service/workflow-graph/model/joint-graph-wrapper.ts b/frontend/src/app/workspace/service/workflow-graph/model/joint-graph-wrapper.ts index 9793792c9b..a519bac1a2 100644 --- a/frontend/src/app/workspace/service/workflow-graph/model/joint-graph-wrapper.ts +++ b/frontend/src/app/workspace/service/workflow-graph/model/joint-graph-wrapper.ts @@ -140,8 +140,6 @@ export class JointGraphWrapper { private workflowEditorZoomSubject: Subject<number> = new Subject<number>(); // event stream of restoring zoom / offset default of the jointJS paper private restorePaperOffsetSubject: Subject<void> = new Subject<void>(); - // event stream to toggle the jointPaper grids on or off. - private jointPaperGridsToggleStream = new Subject<void>(); // event stream of showing the breakpoint button of a link private jointLinkBreakpointShowStream = new Subject<linkIDType>(); @@ -884,20 +882,6 @@ export class JointGraphWrapper { return JointGraphContext; } - /** - * Returns an observable to indicate a toggle of grids has happened, and lets workflow editor to handle the state. - */ - public getJointPaperGridsToggleStream(): Observable<void> { - return this.jointPaperGridsToggleStream.asObservable(); - } - - /** - * Triggers a toggle of whether to show grids in jointPaper. - */ - public toggleGrids() { - this.jointPaperGridsToggleStream.next(); - } - ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Below are methods for coeditor-presence. // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
