You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@texera.apache.org by xi...@apache.org on 2026/03/31 23:21:24 UTC

(texera) branch main updated: feat(gui): add computing unit types in frontend dashboard (#4327)

This is an automated email from the ASF dual-hosted git repository.

xiaozhenliu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/texera.git


The following commit(s) were added to refs/heads/main by this push:
     new 70021f66c2 feat(gui): add computing unit types in frontend dashboard (#4327)
70021f66c2 is described below

commit 70021f66c2e4439f326fe56bfbe62a7db6e76a5b
Author: Grace Chia <94...@users.noreply.github.com>
AuthorDate: Tue Mar 31 16:21:19 2026 -0700

    feat(gui): add computing unit types in frontend dashboard (#4327)
    
    <!--
    Thanks for sending a pull request (PR)! Here are some tips for you:
    1. If this is your first time, please read our contributor guidelines:
    [Contributing to
    Texera](https://github.com/apache/texera/blob/main/CONTRIBUTING.md)
      2. Ensure you have added or run the appropriate tests for your PR
      3. If the PR is work in progress, mark it a draft on GitHub.
      4. Please write your PR title to summarize what this PR proposes, we
        are following Conventional Commits style for PR titles as well.
      5. Be sure to keep the PR description updated to reflect all changes.
    -->
    
    ### What changes were proposed in this PR?
    <!--
    Please clarify what changes you are proposing. The purpose of this
    section
    is to outline the changes. Here are some tips for you:
      1. If you propose a new API, clarify the use case for a new API.
      2. If you fix a bug, you can clarify why it is a bug.
      3. If it is a refactoring, clarify what has been changed.
      3. It would be helpful to include a before-and-after comparison using
         screenshots or GIFs.
      4. Please consider writing useful notes for better and faster reviews.
    -->
    This PR adds the types that are necessary to create a dashboard tab for
    computing units. It is part 1 of 3 of PR #3691.
    
    ### Any related issues, documentation, discussions?
    <!--
    Please use this section to link other resources if not mentioned
    already.
    1. If this PR fixes an issue, please include `Fixes #1234`, `Resolves
    #1234`
    or `Closes #1234`. If it is only related, simply mention the issue
    number.
      2. If there is design documentation, please add the link.
      3. If there is a discussion in the mailing list, please add the link.
    -->
    Related to #3690
    
    ### How was this PR tested?
    <!--
    If tests were added, say they were added here. Or simply mention that if
    the PR
    is tested with existing test cases. Make sure to include/update test
    cases that
    check the changes thoroughly including negative and positive cases if
    possible.
    If it was tested in a way different from regular unit tests, please
    clarify how
    you tested step by step, ideally copy and paste-able, so that other
    reviewers can
    test and check, and descendants can verify in the future. If tests were
    not added,
    please describe why they were not added and/or why it was difficult to
    add.
    -->
    Tested locally
    
    ### Was this PR authored or co-authored using generative AI tooling?
    <!--
    If generative AI tooling has been used in the process of authoring this
    PR,
    please include the phrase: 'Generated-by: ' followed by the name of the
    tool
    and its version. If no, write 'No'.
    Please refer to the [ASF Generative Tooling
    Guidance](https://www.apache.org/legal/generative-tooling.html) for
    details.
    -->
    No.
    
    Co-authored-by: Chen Li <ch...@gmail.com>
    Co-authored-by: Xiaozhen Liu <xi...@uci.edu>
---
 frontend/src/app/dashboard/type/dashboard-entry.ts | 39 ++++++++++++++++++++--
 frontend/src/app/dashboard/type/search-result.ts   |  2 +-
 frontend/src/app/dashboard/type/type-predicates.ts |  5 +++
 frontend/src/app/hub/service/hub.service.ts        |  1 +
 4 files changed, 44 insertions(+), 3 deletions(-)

diff --git a/frontend/src/app/dashboard/type/dashboard-entry.ts b/frontend/src/app/dashboard/type/dashboard-entry.ts
index 6dfb46cc1c..735249d64c 100644
--- a/frontend/src/app/dashboard/type/dashboard-entry.ts
+++ b/frontend/src/app/dashboard/type/dashboard-entry.ts
@@ -21,7 +21,14 @@ import { DashboardFile } from "./dashboard-file.interface";
 import { DashboardWorkflow } from "./dashboard-workflow.interface";
 import { DashboardProject } from "./dashboard-project.interface";
 import { DashboardDataset } from "./dashboard-dataset.interface";
-import { isDashboardDataset, isDashboardFile, isDashboardProject, isDashboardWorkflow } from "./type-predicates";
+import { DashboardWorkflowComputingUnit } from "../../workspace/types/workflow-computing-unit";
+import {
+  isDashboardDataset,
+  isDashboardFile,
+  isDashboardProject,
+  isDashboardWorkflow,
+  isDashboardWorkflowComputingUnit,
+} from "./type-predicates";
 import { EntityType } from "../../hub/service/hub.service";
 
 export interface UserInfo {
@@ -50,7 +57,14 @@ export class DashboardEntry {
   accessibleUserIds: number[];
   coverImageUrl?: string;
 
-  constructor(public value: DashboardWorkflow | DashboardProject | DashboardFile | DashboardDataset) {
+  constructor(
+    public value:
+      | DashboardWorkflow
+      | DashboardProject
+      | DashboardFile
+      | DashboardDataset
+      | DashboardWorkflowComputingUnit
+  ) {
     if (isDashboardWorkflow(value)) {
       this.type = EntityType.Workflow;
       this.id = value.workflow.wid;
@@ -124,6 +138,20 @@ export class DashboardEntry {
       this.isLiked = false;
       this.accessibleUserIds = [];
       this.coverImageUrl = value.dataset.coverImage;
+    } else if (isDashboardWorkflowComputingUnit(value)) {
+      this.type = EntityType.ComputingUnit;
+      this.id = value.computingUnit.cuid;
+      this.name = value.computingUnit.name;
+      this.creationTime = value.computingUnit.creationTime;
+      this.accessLevel = value.accessPrivilege;
+      this.ownerName = "";
+      this.ownerGoogleAvatar = "";
+      this.ownerId = value.computingUnit.uid;
+      this.viewCount = 0;
+      this.cloneCount = 0;
+      this.likeCount = 0;
+      this.isLiked = false;
+      this.accessibleUserIds = [];
     } else {
       throw new Error("Unexpected type in DashboardEntry.");
     }
@@ -182,4 +210,11 @@ export class DashboardEntry {
     }
     return this.value;
   }
+
+  get computingUnit(): DashboardWorkflowComputingUnit {
+    if (!isDashboardWorkflowComputingUnit(this.value)) {
+      throw new Error("Value is not of type DashboardWorkflowComputingUnit");
+    }
+    return this.value;
+  }
 }
diff --git a/frontend/src/app/dashboard/type/search-result.ts b/frontend/src/app/dashboard/type/search-result.ts
index 268381b0a5..8fc14361b1 100644
--- a/frontend/src/app/dashboard/type/search-result.ts
+++ b/frontend/src/app/dashboard/type/search-result.ts
@@ -24,7 +24,7 @@ import { DashboardDataset } from "./dashboard-dataset.interface";
 import { DashboardEntry } from "./dashboard-entry";
 
 export interface SearchResultItem {
-  resourceType: "workflow" | "project" | "file" | "dataset";
+  resourceType: "workflow" | "project" | "file" | "dataset" | "computing-unit";
   workflow?: DashboardWorkflow;
   project?: DashboardProject;
   file?: DashboardFile;
diff --git a/frontend/src/app/dashboard/type/type-predicates.ts b/frontend/src/app/dashboard/type/type-predicates.ts
index 6c9cf96263..0ed825feb4 100644
--- a/frontend/src/app/dashboard/type/type-predicates.ts
+++ b/frontend/src/app/dashboard/type/type-predicates.ts
@@ -21,6 +21,7 @@ import { DashboardWorkflow } from "./dashboard-workflow.interface";
 import { DashboardProject } from "./dashboard-project.interface";
 import { DashboardFile } from "./dashboard-file.interface";
 import { DashboardDataset } from "./dashboard-dataset.interface";
+import { DashboardWorkflowComputingUnit } from "../../workspace/types/workflow-computing-unit";
 
 export function isDashboardWorkflow(value: any): value is DashboardWorkflow {
   return value && typeof value.workflow === "object";
@@ -37,3 +38,7 @@ export function isDashboardFile(value: any): value is DashboardFile {
 export function isDashboardDataset(value: any): value is DashboardDataset {
   return value && typeof value.dataset === "object";
 }
+
+export function isDashboardWorkflowComputingUnit(value: any): value is DashboardWorkflowComputingUnit {
+  return value && typeof value.computingUnit === "object";
+}
diff --git a/frontend/src/app/hub/service/hub.service.ts b/frontend/src/app/hub/service/hub.service.ts
index 231fb5e3b8..66cd08a914 100644
--- a/frontend/src/app/hub/service/hub.service.ts
+++ b/frontend/src/app/hub/service/hub.service.ts
@@ -30,6 +30,7 @@ export enum EntityType {
   Dataset = "dataset",
   Project = "project",
   File = "file",
+  ComputingUnit = "computing-unit",
 }
 
 export enum ActionType {