Skip to content

aks-desktop: ImportAKSProjects: Fix Go To Projects button#463

Merged
illume merged 1 commit into
Azure:mainfrom
illume:go-to-projects
Mar 18, 2026
Merged

aks-desktop: ImportAKSProjects: Fix Go To Projects button#463
illume merged 1 commit into
Azure:mainfrom
illume:go-to-projects

Conversation

@illume
Copy link
Copy Markdown
Collaborator

@illume illume commented Mar 17, 2026

Description

window.location.href = '/' in the Electron desktop app on macOS is interpreted as a filesystem path, opening Finder at / instead of navigating within the app. Replaced with history.replace('/'); window.location.reload() to match the existing pattern in RegisterAKSClusterDialog.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring
  • CI/CD changes
  • Other: **___**

Related Issues

Fixes #456

Changes Made

  • ImportAKSProjects.tsx: Replace window.location.href = '/' with history.replace('/'); window.location.reload() — React Router replaces the current history entry (avoiding stale back-navigation), then reload picks up kubeconfig/localStorage cluster config changes
  • ImportAKSProjects.test.tsx: Add test asserting the button calls history.replace('/') and window.location.reload(), using vi.stubGlobal with vi.unstubAllGlobals() in a try/finally block to safely mock the non-configurable window.location in JSDOM without global side effects

Testing

  • Unit tests pass
  • Integration tests pass
  • Manual testing completed
  • Performance tested (if applicable)
  • Accessibility tested (if applicable)

Test Cases

  1. All 14 ImportAKSProjects tests pass, including new test verifying history.replace('/') and reload() are both called when clicking "Go To Projects"

The steps to reproduce are something like this: Home -> Projects -> [Create Project] button -> Use existing namespaces option -> create the project -> Press [Go to projects] button. It should go to projects, not open finder. Santhosh Nagaraj that correct?

Screenshots/Videos

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Breaking Changes

N/A

Performance Impact

  • No performance impact
  • Performance improved
  • Performance degraded (explain why this is acceptable)

Documentation Updates

  • README.md updated
  • API documentation updated
  • Code comments updated
  • User guide updated
  • No documentation updates needed

Reviewer Notes

The reload is intentional and matches RegisterAKSClusterDialog.handleDone — Headlamp's cluster config is loaded at startup and doesn't reactively update when kubeconfig/localStorage changes after import. Uses history.replace (not push) to avoid polluting navigation history with a stale import results page. The test uses vi.stubGlobal/vi.unstubAllGlobals() because JSDOM marks window.location properties as non-configurable, which causes both Object.defineProperty and vi.spyOn to throw.

Copilot AI review requested due to automatic review settings March 17, 2026 21:09
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

Fixes navigation from the Import AKS Projects flow back to the Projects root by using React Router history navigation and forcing a full page reload (needed for Headlamp’s startup-loaded cluster config behavior).

Changes:

  • Update “Go To Projects” button to history.replace('/') and then window.location.reload().
  • Add a unit test validating the new navigation + reload behavior.

Reviewed changes

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

File Description
plugins/aks-desktop/src/components/ImportAKSProjects/ImportAKSProjects.tsx Switches the “Go To Projects” action from setting window.location.href to router-based replace + explicit reload.
plugins/aks-desktop/src/components/ImportAKSProjects/ImportAKSProjects.test.tsx Adds coverage to ensure the button calls history.replace('/') and triggers window.location.reload().

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

You can also share your feedback on Copilot code review. Take the survey.

@illume illume added the bug Something isn't working label Mar 17, 2026
@illume illume merged commit 58fb9ab into Azure:main Mar 18, 2026
16 checks passed
@illume illume deleted the go-to-projects branch March 18, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Clicking on Go to project after importing a project is opening finder in mac

4 participants