Skip to content

Scaling: Consolidate ScalingTab and clean up components#330

Merged
illume merged 1 commit into
Azure:mainfrom
skoeva:scalingtab
Mar 5, 2026
Merged

Scaling: Consolidate ScalingTab and clean up components#330
illume merged 1 commit into
Azure:mainfrom
skoeva:scalingtab

Conversation

@skoeva
Copy link
Copy Markdown
Collaborator

@skoeva skoeva commented Feb 26, 2026

These changes consolidate ScalingTab into the Scaling module and extract reusable hooks and components to reduce duplication and improve maintainability.

Summary

  • Move ScalingTab from ScalingTab/ into Scaling/ alongside ScalingCard, removing the separate directory
  • Extract useEditDialog hook from inline ScalingTab logic, encapsulating dialog state, form pre-population, and HPA/manual PATCH save logic via clusterRequest
  • Extract ScalingEditDialog component from inline ScalingTab JSX
  • Extract MetricTile local helper in ScalingMetrics to reduce repeated Typography pairs, and lift CPU/bounds ternaries out of JSX into variables
  • Set explicit time ranges per component: 24h/1h-step for ScalingTab, 2h/15min-step for ScalingCard; make timeRangeSecs and step required params in useChartData
  • Simplify Alert usage across components by removing redundant Box/Typography wrappers
  • Add TSDoc field docs to ScalingMetricsProps
  • Add useEditDialog test suite (10 tests) covering dialog state, form pre-population, HPA and manual save paths, onSaved callback, and error handling
  • Expand useDeployments tests with setSelectedDeployment coverage and data-reload stability
  • Update useChartData tests for required params and additional cache/time-range edge cases
  • Fix several correctness issues flagged in review: boundsValue leak in ScalingMetrics, || 0 coercion in HPA inputs, missing guard in handleSave, and grid layout wrapping with 5 tiles

Fixes: #100

Testing

  • Run cd plugins/aks-desktop && npm test and ensure the tests pass

Screenshot

image

@skoeva skoeva self-assigned this Feb 26, 2026
Copilot AI review requested due to automatic review settings February 26, 2026 17:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request consolidates the ScalingTab component into the Scaling module and extracts reusable hooks and components to improve code organization and maintainability. The refactoring separates presentation logic from business logic, making the codebase more testable and reducing duplication.

Changes:

  • Moved ScalingTab from ScalingTab/ directory into Scaling/ alongside ScalingCard
  • Extracted useEditDialog hook to encapsulate dialog state management and HPA/manual scaling save logic
  • Extracted ScalingEditDialog and MetricTile components to reduce JSX complexity
  • Made time range and step parameters explicit and required in useChartData, allowing different components to use different resolutions (24h/1h for ScalingTab, 2h/15min for ScalingCard)
  • Added comprehensive test coverage for new hooks with 10 new tests for useEditDialog and expanded tests for useDeployments and useChartData

Reviewed changes

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

Show a summary per file
File Description
plugins/aks-desktop/src/index.tsx Updated import path for ScalingTab from ScalingTab/ to Scaling/
plugins/aks-desktop/src/components/ScalingTab/ScalingTab.tsx Removed old ScalingTab implementation (721 lines deleted)
plugins/aks-desktop/src/components/Scaling/ScalingTab.tsx New consolidated ScalingTab using extracted hooks and components (184 lines)
plugins/aks-desktop/src/components/Scaling/hooks/useEditDialog.ts New hook encapsulating edit dialog state, form pre-population, and save logic
plugins/aks-desktop/src/components/Scaling/hooks/useEditDialog.test.ts Comprehensive test suite for useEditDialog (10 tests covering all paths)
plugins/aks-desktop/src/components/Scaling/hooks/useDeployments.test.ts Expanded tests for setSelectedDeployment and data reload stability
plugins/aks-desktop/src/components/Scaling/hooks/useChartData.ts Made timeRangeSecs and step required parameters; changed cache from single object to Map
plugins/aks-desktop/src/components/Scaling/hooks/useChartData.test.ts Updated all test calls to include required timeRangeSecs/step parameters; added cache collision tests
plugins/aks-desktop/src/components/Scaling/components/ScalingMetrics.tsx Added TSDoc, extracted MetricTile helper, lifted CPU/bounds logic out of JSX
plugins/aks-desktop/src/components/Scaling/components/ScalingEditDialog.tsx New extracted dialog component for editing scaling configuration
plugins/aks-desktop/src/components/Scaling/components/ScalingChart.tsx Simplified Alert usage by removing redundant Typography wrapper
plugins/aks-desktop/src/components/Scaling/ScalingCard.tsx Updated to pass explicit timeRangeSecs/step to useChartData; simplified Alert usage
Comments suppressed due to low confidence (1)

plugins/aks-desktop/src/components/Scaling/hooks/useChartData.ts:126

  • When cached data is returned (lines 121-126), loading state is not reset to false. The loading state was set to true on line 101, but the early return on line 126 bypasses the finally block on line 190 that sets loading to false. This would leave the loading indicator visible even though cached data is available. Add setLoading(false) in the cache hit block.
      if (cachedChartData) {
        applyIfLatest(() => {
          setChartData(cachedChartData);
          setError(null);
        });
        return;

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

Comment thread plugins/aks-desktop/src/components/Scaling/ScalingTab.tsx Outdated
Comment thread plugins/aks-desktop/src/components/Scaling/components/ScalingEditDialog.tsx Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 9 comments.


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

Comment thread plugins/aks-desktop/src/components/Scaling/components/ScalingMetrics.tsx Outdated
Comment thread plugins/aks-desktop/src/components/Scaling/hooks/useChartData.test.ts Outdated
Comment thread plugins/aks-desktop/src/components/Scaling/hooks/useEditDialog.ts
Comment thread plugins/aks-desktop/src/components/Scaling/ScalingTab.tsx
Comment thread plugins/aks-desktop/src/components/Scaling/hooks/useEditDialog.ts
Comment thread plugins/aks-desktop/src/components/Scaling/hooks/useEditDialog.ts
Comment thread plugins/aks-desktop/src/components/Scaling/hooks/useChartData.ts
@illume illume marked this pull request as draft March 2, 2026 16:04
@illume illume marked this pull request as draft March 2, 2026 16:04
@illume
Copy link
Copy Markdown
Collaborator

illume commented Mar 2, 2026

Looks good at a glance.

Marked it as draft because some convos are still open.

@skoeva skoeva force-pushed the scalingtab branch 2 times, most recently from 52f794e to 9221789 Compare March 2, 2026 17:05
@skoeva skoeva marked this pull request as ready for review March 2, 2026 17:12
Copilot AI review requested due to automatic review settings March 2, 2026 17:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 3 comments.

Files not reviewed (1)
  • plugins/aks-desktop/package-lock.json: Language not supported

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

Comment thread plugins/aks-desktop/src/components/Scaling/ScalingTab.tsx
Comment thread plugins/aks-desktop/src/components/Scaling/hooks/useEditDialog.ts
@skoeva skoeva requested a review from illume March 3, 2026 12:41
Comment thread plugins/aks-desktop/package-lock.json Outdated
Copy link
Copy Markdown
Collaborator

@illume illume left a comment

Choose a reason for hiding this comment

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

lgtm

Please remove the package-lock.json change?

@illume illume marked this pull request as draft March 3, 2026 18:18
@skoeva skoeva marked this pull request as ready for review March 3, 2026 21:08
Copilot AI review requested due to automatic review settings March 3, 2026 21:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 31 out of 32 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • plugins/aks-desktop/package-lock.json: Language not supported

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

Comment thread plugins/aks-desktop/src/components/Scaling/components/ScalingEditDialog.tsx Outdated
@illume
Copy link
Copy Markdown
Collaborator

illume commented Mar 3, 2026

@skoeva the package-lock file is still in the PR

@illume illume marked this pull request as draft March 3, 2026 23:17
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
@skoeva skoeva marked this pull request as ready for review March 4, 2026 13:24
Copilot AI review requested due to automatic review settings March 4, 2026 13:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 31 out of 31 changed files in this pull request and generated 1 comment.


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

Comment thread plugins/aks-desktop/src/components/Scaling/ScalingTab.tsx
Copy link
Copy Markdown
Collaborator

@illume illume left a comment

Choose a reason for hiding this comment

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

🎉 thanks!

@illume illume merged commit 3587213 into Azure:main Mar 5, 2026
11 checks passed
@skoeva skoeva deleted the scalingtab branch March 6, 2026 14:29
@illume illume mentioned this pull request Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plugins/aks-desktop: Separate presentation from logic plugins/aks-desktop/src/components/ScalingTab/ScalingTab.tsx ScalingTab

3 participants