mengw15 commented on code in PR #8376:
URL: https://github.com/apache/texera/pull/8376#discussion_r3931823408


##########
frontend/src/app/workspace/component/workflow-form/workflow-form.component.ts:
##########
@@ -0,0 +1,163 @@
+/**
+ * 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 { ChangeDetectorRef, Component, HostListener, OnDestroy, OnInit } from 
"@angular/core";
+import { CommonModule } from "@angular/common";
+import { ActivatedRoute, Router } from "@angular/router";
+import { UntilDestroy, untilDestroyed } from "@ngneat/until-destroy";
+import { NzAvatarModule } from "ng-zorro-antd/avatar";
+import { UserIconComponent } from 
"../../../dashboard/component/user/user-icon/user-icon.component";
+import { forkJoin } from "rxjs";
+
+import { USER_WORKFLOW, USER_WORKSPACE } from "../../../app-routing.constant";
+import { ComputingUnitStatusService } from 
"../../../common/service/computing-unit/computing-unit-status/computing-unit-status.service";
+import { WorkflowPersistService } from 
"../../../common/service/workflow-persist/workflow-persist.service";
+import { NotificationService } from 
"../../../common/service/notification/notification.service";
+import { UserService } from "../../../common/service/user/user.service";
+import { ExecuteWorkflowService } from 
"../../service/execute-workflow/execute-workflow.service";
+import { OperatorMetadataService } from 
"../../service/operator-metadata/operator-metadata.service";
+import { WorkflowActionService } from 
"../../service/workflow-graph/model/workflow-action.service";
+import { GuiConfigService } from "../../../common/service/gui-config.service";
+import { WorkflowConsoleService } from 
"../../service/workflow-console/workflow-console.service";
+import { WorkflowResultService } from 
"../../service/workflow-result/workflow-result.service";
+import { DefaultView } from 
"../../../dashboard/type/workflow-metadata.interface";
+import { CoeditorUserIconComponent } from 
"../menu/coeditor-user-icon/coeditor-user-icon.component";
+import { CoeditorPresenceService } from 
"../../service/workflow-graph/model/coeditor-presence.service";
+
+/**
+ * The Form View: a second way to use a workflow. This PR lays down the page 
shell -- behind
+ * the feature flag it loads the workflow the URL names, shows it read-only, 
and hands back to
+ * the operator canvas. The title bar's rename/save, the read-only preview, 
the inputs, running
+ * and results are added on top by later PRs. A view, not a new object: it 
opens the same
+ * workflow the canvas does.
+ */
+@UntilDestroy()
+@Component({
+  selector: "texera-workflow-form",
+  templateUrl: "./workflow-form.component.html",
+  styleUrls: ["./workflow-form.component.scss"],
+  imports: [CommonModule, NzAvatarModule, UserIconComponent, 
CoeditorUserIconComponent],
+})
+export class WorkflowFormComponent implements OnInit, OnDestroy {
+  public wid?: number;
+  public workflowName = "";
+  public loading = true;
+
+  constructor(
+    // Public for the template: shows the same live collaborator avatars as 
the canvas.
+    public coeditorPresenceService: CoeditorPresenceService,
+    private route: ActivatedRoute,
+    private router: Router,
+    private workflowActionService: WorkflowActionService,
+    private workflowPersistService: WorkflowPersistService,
+    private operatorMetadataService: OperatorMetadataService,
+    private executeWorkflowService: ExecuteWorkflowService,
+    private workflowResultService: WorkflowResultService,
+    private notificationService: NotificationService,
+    private userService: UserService,
+    private cdr: ChangeDetectorRef,
+    private computingUnitStatusService: ComputingUnitStatusService,
+    private workflowConsoleService: WorkflowConsoleService,
+    private config: GuiConfigService
+  ) {}
+
+  ngOnInit(): void {
+    const wid = Number(this.route.snapshot.params.id);
+    if (!Number.isFinite(wid)) {
+      void this.router.navigate([USER_WORKFLOW]);
+      return;
+    }
+    this.wid = wid;
+    this.load(wid);
+  }
+
+  private load(wid: number): void {
+    // With the feature off the form does not exist: hand straight to the 
operator canvas
+    // without loading anything, so a request that then fails cannot strand 
the visitor on
+    // an error instead of the page they would have gotten.
+    if (!this.config.env.formViewEnabled) {
+      void this.router.navigate([USER_WORKSPACE, String(wid)], { replaceUrl: 
true });
+      return;
+    }
+    this.workflowActionService.resetAsNewWorkflow();
+    forkJoin({
+      metadata: this.operatorMetadataService.getOperatorMetadata(),
+      workflow: this.workflowPersistService.retrieveWorkflow(wid),
+    })
+      .pipe(untilDestroyed(this))
+      .subscribe({
+        next: ({ workflow }) => {
+          // Even with the flag on, a workflow that opens on the operator 
canvas is sent
+          // there: reaching this URL for it lands on the canvas, not an empty 
page.
+          if (workflow.defaultView !== DefaultView.FORM) {

Review Comment:
   The #8011 closing note settled that the form renders for any workflow while 
the flag is on ("nothing redirects away from the form" — the default_view bit 
only picks the landing), yet this condition redirects a canvas-default workflow 
(undefined included) away, which quietly reintroduces the per-workflow gate: 
pr11's view switch would bounce straight back for any workflow whose default is 
the canvas. If it's temporary scaffolding while the body is empty, worth a 
comment saying which slice removes it; if it's meant to stay, it contradicts 
the settled model.



-- 
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