Skip to content

refactor(frontend): extract shared computing-unit create modal component - #6082

Merged
aglinxinyuan merged 6 commits into
apache:mainfrom
kunwp1:refactor/computing-unit-create-modal
Jul 4, 2026
Merged

aglinxinyuan merged 6 commits into
apache:mainfrom
kunwp1:refactor/computing-unit-create-modal

Conversation

@kunwp1

@kunwp1 kunwp1 commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

This is a refactor PR that extracts the "create computing unit" modal, previously duplicated between the workspace power button (computing-unit-selection.component) and the dashboard Computing Units page (user-computing-unit.component), into a new shared standalone component ComputingUnitCreateModalComponent under frontend/src/app/common/component/computing-unit-create-modal/. The shared component owns the whole form (unit type, name, CPU/memory/GPU selects, JVM memory slider, shared memory size, local URI), the option fetching from getComputingUnitTypes()/getComputingUnitLimitOptions(), validation, and the create call. The workspace host selects the newly created unit for the current workflow, and the dashboard host refreshes its list.

Net effect: 13 files changed, ~460 lines of duplicated TS/HTML/SCSS removed, no user-visible behavior change.

Any related issues, documentation, discussions?

Closes #6081

How was this PR tested?

Since this is a refactoring, tested whether the behavior of creating a CU hasn't changed.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code, Claude Fable 5

Extract the create-computing-unit form (type, name, CPU/memory/GPU, JVM
memory, shared memory, local URI) duplicated between the workspace power
button and the dashboard Computing Units page into one shared standalone
ComputingUnitCreateModalComponent. Hosts bind [(visible)] and handle
(unitCreated) for their post-create action; menu.component seeds the
default unit name through showAddComputeUnitModalVisible(defaultName).
Behavior is unchanged.
@github-actions github-actions Bot added refactor Refactor the code frontend Changes related to the frontend GUI labels Jul 4, 2026
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @Yicong-Huang, @gracecluvohio, @Ma77Ball
    You can notify them by mentioning @Yicong-Huang, @gracecluvohio, @Ma77Ball in a comment.

@codecov-commenter

codecov-commenter commented Jul 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.18%. Comparing base (67b6612) to head (046ff2d).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #6082      +/-   ##
============================================
+ Coverage     57.67%   58.18%   +0.50%     
  Complexity     3142     3142              
============================================
  Files          1130     1132       +2     
  Lines         43832    43692     -140     
  Branches       4747     4734      -13     
============================================
+ Hits          25281    25423     +142     
+ Misses        17108    16832     -276     
+ Partials       1443     1437       -6     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from 9df3b22
agent-service 44.59% <ø> (ø) Carriedforward from 9df3b22
amber 60.69% <ø> (ø) Carriedforward from 9df3b22
computing-unit-managing-service 0.00% <ø> (ø) Carriedforward from 9df3b22
config-service 52.30% <ø> (ø) Carriedforward from 9df3b22
file-service 62.81% <ø> (ø) Carriedforward from 9df3b22
frontend 51.31% <100.00%> (+1.18%) ⬆️
notebook-migration-service 78.57% <ø> (ø) Carriedforward from 9df3b22
pyamber 91.15% <ø> (ø) Carriedforward from 9df3b22
python 90.69% <ø> (ø) Carriedforward from 9df3b22
workflow-compiling-service 55.14% <ø> (ø) Carriedforward from 9df3b22

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kunwp1
kunwp1 requested a review from aglinxinyuan July 4, 2026 02:12
@kunwp1

kunwp1 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor Author

/request-review @aglinxinyuan

Cover the remaining create-modal paths flagged by Codecov: fetch/create
error toasts, GPU option edge cases, JVM slider interactions and the
preserve-previous-value branch, open-modal template rendering for the
kubernetes and local forms, footer button wiring, and the unitCreated
handlers in both hosts. Extract buildLocalComputingUnitUri into
computing-unit.util so both port branches are unit-testable, and add
refreshComputingUnitList to the mock status service.

@aglinxinyuan aglinxinyuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Seems like just moving code to a new file.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the frontend computing-unit creation flow by extracting the duplicated “create computing unit” modal (previously implemented in both the workspace power button and the dashboard Computing Units page) into a shared ComputingUnitCreateModalComponent under frontend/src/app/common/component/computing-unit-create-modal/.

Changes:

  • Introduces a shared, standalone ComputingUnitCreateModalComponent that owns CU option fetching, validation, and the create call, emitting unitCreated to hosts.
  • Replaces the duplicated modal markup/logic in workspace and dashboard hosts with <texera-computing-unit-create-modal [(visible)] ...>.
  • Updates workspace menu + unit-selection tests to align with the new “seed default name via method parameter” flow.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
frontend/src/app/workspace/component/power-button/computing-unit-selection.component.ts Replaces in-component CU-create form logic with shared modal usage and unitCreated handler; adds name seeding via ViewChild.
frontend/src/app/workspace/component/power-button/computing-unit-selection.component.html Swaps the inline <nz-modal> create form for the shared <texera-computing-unit-create-modal> component.
frontend/src/app/workspace/component/power-button/computing-unit-selection.component.scss Removes styles that were only used by the old inline create modal form.
frontend/src/app/workspace/component/power-button/computing-unit-selection.component.spec.ts Adds a unit test validating default-name seeding into the embedded shared create modal.
frontend/src/app/workspace/component/menu/menu.component.ts Updates run-workflow path to seed the default CU name by passing it into showAddComputeUnitModalVisible(defaultName).
frontend/src/app/workspace/component/menu/menu.component.spec.ts Updates expectations to assert the seeded name is passed to showAddComputeUnitModalVisible(...).
frontend/src/app/dashboard/component/user/user-computing-unit/user-computing-unit.component.ts Replaces duplicated create modal state/logic with the shared create modal and refresh-on-create handler.
frontend/src/app/dashboard/component/user/user-computing-unit/user-computing-unit.component.html Swaps the inline <nz-modal> create form for the shared <texera-computing-unit-create-modal> component.
frontend/src/app/dashboard/component/user/user-computing-unit/user-computing-unit.component.scss Removes styles that were only used by the old inline create modal form.
frontend/src/app/common/component/computing-unit-create-modal/computing-unit-create-modal.component.ts New shared modal component: fetches CU type/limit options, validates input, performs create, and emits unitCreated.
frontend/src/app/common/component/computing-unit-create-modal/computing-unit-create-modal.component.html New shared modal template (migrated from the duplicated host templates).
frontend/src/app/common/component/computing-unit-create-modal/computing-unit-create-modal.component.scss New shared styles for the extracted modal layout and form controls.
frontend/src/app/common/component/computing-unit-create-modal/computing-unit-create-modal.component.spec.ts New unit tests for default type selection, option defaults, validation, create flow, and shared-memory/JVM slider behaviors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

kunwp1 and others added 4 commits July 3, 2026 22:50
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Signed-off-by: Kunwoo (Chris) <[email protected]>
…ails

The workspace host's slimmed getComputingUnitLimitOptions() subscription
swallowed errors, leaving gpuOptions empty so showGpuSelection() hid the
metrics popover's GPU row even for units with GPUs allocated. On fetch
failure, log the error and fall back to permissive: the metrics template
still requires the unit's own GPU limit to be non-zero, so the row only
shows for units that actually have GPUs. The shared create modal still
owns the user-facing toast for this endpoint.
The Copilot Autofix stub broke all six modal-rendering tests: the
declarative <nz-modal> in the component template delegates opening to
NzModalService.create(), so the spec needs the real service. Documented
inline to prevent the finding from being re-applied.
…hosts

Codecov flagged the [(visible)] lines in both host templates: the
banana-box event side only executes when the embedded modal emits
visibleChange, which no host test triggered. Add a visibility-sync test
per host asserting the modal's self-close propagates to the host flag.
@kunwp1
kunwp1 added this pull request to the merge queue Jul 4, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 4, 2026
@aglinxinyuan
aglinxinyuan added this pull request to the merge queue Jul 4, 2026
Merged via the queue into apache:main with commit 3dd4c2b Jul 4, 2026
19 checks passed
gupta-sahil01 pushed a commit to gupta-sahil01/texera that referenced this pull request Jul 9, 2026
…#6104)

### What changes were proposed in this PR?

This PR improves the UI of creating a computing unit (CU) with an
"Advanced Settings" section to get a simplified default view.

The shared memory size and JVM memory size are too technical for most
users, so the create-CU modal now shows only the common fields (name /
RAM / CPU) by default and tucks those two options behind a collapsed
"Advanced Settings" panel:

- Collapsed by default, and collapses again every time the modal opens.
- If shared memory is set larger than total memory while the panel is
collapsed, a warning appears on the panel header so the invalid value is
not hidden.
- Implemented once in the shared `ComputingUnitCreateModalComponent`
(apache#6082), so both entry points (the dashboard Computing Units page and
the workspace power button) get the same behavior.

The feature was originally implemented on the downstream dknet-ai.org
deployment
([Texera/dknet-ai-public@30318e2d](Texera/dknet-ai-public@30318e2)).

### Any related issues, documentation, discussions?

Closes apache#6102

### How was this PR tested?


https://github.com/user-attachments/assets/b7a5e4d3-b655-45bc-bf5c-f6ef1674af9c

### Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code

---------

Signed-off-by: Kunwoo (Chris) <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Oct 6, 2026
…e#8827)

### What changes were proposed in this PR?

Removes two leftovers from `ComputingUnitCreateModalComponent`. **−2
lines.** There is no behaviour change.

- `<ng-template #addComputeUnitModalTitle>`. The modal's title comes
from `[nzTitle]="getCreateModalTitle()"`. Nothing else reads the
template: there is no `@ViewChild`, no outlet, and neither of the two
hosts that open the modal passes it. `nz-modal` only picks up its
title/content/footer directives, never a plain `#ref` template.
- The `selectedShmSize` field. The create payload builds `shmSize` from
`shmSizeValue` / `shmSizeUnit`, which stay.

### History

| | |
| --- | --- |
| **Introduced by** | apache#3315 (2025-03-13), "Add computing unit manager
frontend": the title template. apache#3451 (2025-05-28), "Enable adjusting
shared memory for the computing unit": `selectedShmSize` |
| **Usage removed by** | apache#3400 (2025-05-26) switched the title to
`getCreateModalTitle()`. apache#4331 (2026-04-09), "add full computing unit
tab", dropped the field's last write and read. apache#6082 later moved both,
still unread, into this shared component |

The title template has been unused for sixteen months, and the field for
six.

### Any related issues, documentation, discussions?

Closes apache#8826

### How was this PR tested?

No new tests; no spec referenced either item.

From `frontend/`:

- `npx ng test --watch=false
--include='**/computing-unit-create-modal.component.spec.ts'
--include='**/user-computing-unit.component.spec.ts'
--include='**/computing-unit-selection.component.spec.ts'`: 3 files, 248
tests, all pass. The other two specs cover the modal's two hosts.
- `yarn format:ci`: clean.
- `npx ng build`: success.

To re-check:

```
git grep -n "addComputeUnitModalTitle\|selectedShmSize" -- frontend   # no hits
```

### Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 5.5)

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Changes related to the frontend GUI refactor Refactor the code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deduplicate the create-computing-unit modal between the workspace and dashboard

4 participants