yangzhang75 commented on code in PR #9023:
URL: https://github.com/apache/texera/pull/9023#discussion_r4445531061


##########
frontend/src/app/workspace/component/code-editor-dialog/code-editor-host.directive.spec.ts:
##########
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { Component, OnDestroy } from "@angular/core";
+import { TestBed } from "@angular/core/testing";
+import { CodeEditorHostDirective } from "./code-editor-host.directive";
+import { CodeEditorService } from 
"../../service/code-editor/code-editor.service";
+
+/** A view that hosts the editor, as the operator canvas and the Form View do. 
*/
+@Component({
+  template: "<ng-template texeraCodeEditorHost></ng-template>",
+  imports: [CodeEditorHostDirective],
+})
+class HostingViewComponent {}
+
+/** Stands in for the editor: what the host holds, and what must be torn down 
with the view. */
+@Component({ template: "editor" })
+class HostedComponent implements OnDestroy {
+  static destroyed = 0;
+  ngOnDestroy(): void {
+    HostedComponent.destroyed++;
+  }
+}

Review Comment:
   This is Angular 21.2 (`frontend/package.json`): `standalone: true` has been 
the default since v19, so both test components are standalone, and `imports` is 
valid on them and in `TestBed.configureTestingModule`. The spec compiles and 
passes; the frontend leg was red on the formatter (one blank line in 
`code-editor.component.spec.ts`), fixed in eeb0cc649.



##########
frontend/src/app/workspace/component/code-editor-dialog/code-editor-host.directive.spec.ts:
##########
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { Component, OnDestroy } from "@angular/core";
+import { TestBed } from "@angular/core/testing";
+import { CodeEditorHostDirective } from "./code-editor-host.directive";
+import { CodeEditorService } from 
"../../service/code-editor/code-editor.service";
+
+/** A view that hosts the editor, as the operator canvas and the Form View do. 
*/
+@Component({
+  template: "<ng-template texeraCodeEditorHost></ng-template>",
+  imports: [CodeEditorHostDirective],
+})
+class HostingViewComponent {}
+
+/** Stands in for the editor: what the host holds, and what must be torn down 
with the view. */
+@Component({ template: "editor" })
+class HostedComponent implements OnDestroy {
+  static destroyed = 0;
+  ngOnDestroy(): void {
+    HostedComponent.destroyed++;
+  }
+}
+
+describe("CodeEditorHostDirective", () => {
+  let service: CodeEditorService;
+
+  beforeEach(async () => {
+    HostedComponent.destroyed = 0;
+    await TestBed.configureTestingModule({ imports: [HostingViewComponent, 
HostedComponent] }).compileComponents();

Review Comment:
   Same as the thread above: Angular 21, standalone by default, so this 
compiles as written.



##########
frontend/src/app/workspace/component/code-editor-dialog/code-editor.component.ts:
##########
@@ -93,14 +95,18 @@ export const LANGUAGE_SERVER_CONNECTION_TIMEOUT_MS = 1000;
     AnnotationSuggestionComponent,
   ],
 })
-export class CodeEditorComponent implements AfterViewInit, SafeStyle, 
OnDestroy {
+export class CodeEditorComponent implements OnInit, AfterViewInit, SafeStyle, 
OnDestroy {
   @ViewChild("editor", { static: true }) editorElement!: ElementRef;
   @ViewChild("container", { static: true }) containerElement!: ElementRef;
   @ViewChild(AnnotationSuggestionComponent) annotationSuggestion!: 
AnnotationSuggestionComponent;
   @ViewChild(BreakpointConditionInputComponent) breakpointConditionInput!: 
BreakpointConditionInputComponent;
   private code?: YText;
   private workflowVersionStreamSubject: Subject<void> = new Subject<void>();
-  public currentOperatorId!: string;
+  /**
+   * The operator whose code this edits, given by the opener: the operator 
property panel's button
+   * reads the highlighted operator, the Form View's the operator its field is 
bound to.
+   */
+  @Input() currentOperatorId!: string;

Review Comment:
   Added a guard at the top of `ngOnInit`: opened without `currentOperatorId`, 
it throws `CodeEditorComponent needs currentOperatorId set before it is 
initialised` instead of failing on the first lookup with `operator undefined 
does not exist`. A spec covers it. (eeb0cc649)



##########
frontend/src/app/workspace/component/code-editor-dialog/code-editor.component.ts:
##########
@@ -150,8 +156,10 @@ export class CodeEditorComponent implements AfterViewInit, 
SafeStyle, OnDestroy
     private config: GuiConfigService,
     private uiUdfParametersSyncService: UiUdfParametersSyncService,
     private notificationService: NotificationService
-  ) {
-    this.currentOperatorId = 
this.workflowActionService.getJointGraphWrapper().getCurrentHighlightedOperatorIDs()[0];
+  ) {}
+
+  ngOnInit(): void {
+    // Everything here keys on currentOperatorId, an input set after 
construction.
     const operatorType = 
this.workflowActionService.getTexeraGraph().getOperator(this.currentOperatorId).operatorType;

Review Comment:
   Same guard as the thread above. (eeb0cc649)



##########
frontend/src/app/workspace/component/workflow-form/workflow-form.component.scss:
##########
@@ -1104,3 +1104,11 @@ $shell: #fafafa;
     }
   }
 }
+
+/* The code editor opens into this page's outlet (texeraCodeEditorHost), so it 
is a descendant and
+   can be dragged under the sticky title row (z-index 20) and the panel's 
close button; keep the
+   editor above them. The canvas's chrome never exceeds that, so the shared 
editor keeps its own
+   value and only this page lifts it. The class is what beats the editor's own 
rule in specificity. */
+:host ::ng-deep #code-editor-container.box {
+  z-index: 21;
+}

Review Comment:
   Kept. The container is in the editor's own template, so from this page it 
can only be reached through `::ng-deep` or a global rule, and a global rule 
would be the same selector one file away from the reason for it. `::ng-deep` is 
how this frontend does it today (28 stylesheets under `src/app` use it); an 
input on the editor for one z-index would be more surface than the override is 
worth.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to