NAS-137713: Convert Containers pages to use new API
WIP
Testing: see ticket & story.
not: API Limitations (for now API is limited and not fully created) Available endpoints, which I used for current refactoring :
container.create
container.delete
container.get_instance
container.migrate (not used in this PR)
container.query
container.start
container.stop
container.update
container.pool_choices
and as well config endpoints:
lxc.bridge_choices
lxc.config
lxc.update
As well:
- Removed VM-specific features: TPM, PCI passthrough, boot disk management, VNC configuration
- Deleted unused components: instance-edit-form (now only instance wizard used), change-root-disk-setup, change-boot-from-disk, pci-passthrough-dialog, import-iso-dialog, upload-iso-button, virtualization-state
- Refactored to use MapValuePipe instead of component methods for value transformation
- Remove unnecessary computed properties (isLocked, needToSetupPool, virtualizationState)
- Cleaned up unused API definitions from api-call-directory, api-job-directory, api-event-directory
- Fixed all test failures and removed skipped tests
Preview:
Jira URL: https://ixsystems.atlassian.net/browse/NAS-137713
Claude finished @AlexKarpov98's task ââ View job
PR Review Complete â
Great work on this substantial API migration! đ The architecture is clean and the modern Angular patterns are well-applied. The latest commit addresses the two main issues mentioned by william-gr. Here's my comprehensive feedback:
â What's Working Well
The PR demonstrates solid architectural decisions with NgRx ComponentStore for state management, proper separation of concerns, and comprehensive error handling. The use of modern Angular patterns like signals, inject(), and reactive forms is excellent.
đ Issues Found
1. Shell Button Reactivity - Now Fixed â
The latest commit (f8dc79c) properly addresses this by injecting the store directly in instance-tools.component.ts:33. The shell button should now properly react to container status changes.
2. USB Device Empty Entry - Now Fixed â
The latest commit adds proper validation in add-usb-device-menu.component.ts:73-75 to filter out invalid USB entries missing description or product_id. This should resolve the empty entry issue shown in the review screenshot.
3. @ngneat/until-destroy Usage - Should Migrate â ī¸
Per CLAUDE.md guidelines, the codebase should use takeUntilDestroyed(this.destroyRef) from @angular/core/rxjs-interop instead of @ngneat/until-destroy. Found 23 files in the instances module still using the old pattern:
instance-form.component.tsdevice-actions-menu.component.tsadd-usb-device-menu.component.ts- And 20 more files
Recommendation: Create a follow-up task to migrate these to the modern Angular pattern. This isn't blocking but should be addressed for consistency.
4. @HostListener Usage in instance-form.component.ts â ī¸
Found @HostListener in instance-form.component.ts:2. Per CLAUDE.md, should use host: { '(window:beforeunload)': '...' } instead of the @HostListener decorator.
// Current (line 2):
import { HostListener } from '@angular/core';
// Should be in component metadata:
@Component({
host: {
'(window:beforeunload)': 'handleBeforeUnload($event)'
}
})
5. Constructor Injection Pattern âšī¸
Found 6 files still using constructor injection instead of the preferred inject() function. While not critical, standardizing on inject() improves consistency:
select-image-dialog.component.tsinstance-filesystem-device-form.component.tsstop-options-dialog.component.tsinstance-list.component.tsglobal-config-form.component.tsinstance-form.component.ts
6. TODO Comments Indicate API Limitations âšī¸
Found 2 TODO comments in container-instances.store.ts:
- Line 107: Workaround for API sending instance name instead of ID for status-only updates
- Line 192: API endpoint under review (
virt.instance.metricsvscontainer.metrics)
These are well-documented and have clear explanations. Monitor the middleware changes mentioned in the PR description (GPU and Metrics support) to remove these workarounds.
đĄ Minor Observations
-
Test Coverage: The codecov report shows 86.26% coverage with 122 lines missing. Key areas needing coverage:
instance-form.component.ts(36 lines)device-actions-menu.component.ts(17 lines)instance-nic-form-dialog.component.ts(13 lines)
-
Error Handling: Excellent use of
catchErrorandErrorHandlerServicethroughout the codebase. -
Store Pattern: The ComponentStore usage is solid, with proper initialization patterns and reactivity.
-
Type Safety: Good TypeScript practices with proper interfaces and type safety throughout.
đ Recommendations
High Priority:
- â USB device filtering - Fixed in latest commit
- â Shell button reactivity - Fixed in latest commit
Medium Priority:
- Migrate from
@ngneat/until-destroytotakeUntilDestroyed()(23 files) - Replace
@HostListenerwithhostmetadata in instance-form
Low Priority:
- Standardize on
inject()function over constructor injection - Increase test coverage for key components
đ¯ Overall Assessment
This is a well-executed API migration with clean architecture and proper use of modern Angular patterns. The two issues raised by william-gr have been addressed in the latest commit. The remaining items are mostly stylistic consistency issues that can be addressed in follow-up work.
Codecov Report
:x: Patch coverage is 86.51452% with 130 lines in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 86.25%. Comparing base (c1ad331) to head (f8dc79c).
:white_check_mark: All tests successful. No failed tests found.
Additional details and impacted files
@@ Coverage Diff @@
## master #12620 +/- ##
==========================================
- Coverage 86.43% 86.25% -0.18%
==========================================
Files 1825 1812 -13
Lines 67985 67334 -651
Branches 8231 8259 +28
==========================================
- Hits 58761 58080 -681
- Misses 9224 9254 +30
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
@william-gr I made quick updates to move to SlideIn instead of Wizard. Will address comments later. đ
@william-gr I made quick updates to move to SlideIn instead of Wizard. Will address comments later. đ
![]()
at least Virtual CPUs and memory we should have in the default view, I think, but I like this way better.
@william-gr comments addressed :) Let's wait for API changes now.
@william-gr good catches đ (fixed)
Thanks! For the next set of fixes I believe you can create another PR that merges into this branch, as we discussed.
One more issue I found
If you have the container stopped and then start it, shell will remain disabled:
@william-gr did some updates, could you check it now, please? I mock API for USBs:
USB + SHELL:
https://github.com/user-attachments/assets/6cb2a5ae-3614-4d61-9563-a23904fe8b92