Repository navigation
refactor(frontend): extract shared computing-unit create modal component - #6082
Conversation
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.
Automated Reviewer SuggestionsBased on the
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
/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
left a comment
There was a problem hiding this comment.
LGTM! Seems like just moving code to a new file.
There was a problem hiding this comment.
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
ComputingUnitCreateModalComponentthat owns CU option fetching, validation, and the create call, emittingunitCreatedto 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.
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.
…#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]>
…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)
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 componentComputingUnitCreateModalComponentunderfrontend/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 fromgetComputingUnitTypes()/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