aks-desktop: ImportAKSProjects: Fix Go To Projects button#463
Merged
Conversation
Contributor
There was a problem hiding this comment.
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 thenwindow.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.
ashu8912
approved these changes
Mar 18, 2026
skoeva
approved these changes
Mar 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 withhistory.replace('/'); window.location.reload()to match the existing pattern inRegisterAKSClusterDialog.Type of Change
Related Issues
Fixes #456
Changes Made
ImportAKSProjects.tsx: Replacewindow.location.href = '/'withhistory.replace('/'); window.location.reload()— React Router replaces the current history entry (avoiding stale back-navigation), then reload picks up kubeconfig/localStorage cluster config changesImportAKSProjects.test.tsx: Add test asserting the button callshistory.replace('/')andwindow.location.reload(), usingvi.stubGlobalwithvi.unstubAllGlobals()in atry/finallyblock to safely mock the non-configurablewindow.locationin JSDOM without global side effectsTesting
Test Cases
history.replace('/')andreload()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
Breaking Changes
N/A
Performance Impact
Documentation Updates
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. Useshistory.replace(notpush) to avoid polluting navigation history with a stale import results page. The test usesvi.stubGlobal/vi.unstubAllGlobals()because JSDOM markswindow.locationproperties as non-configurable, which causes bothObject.definePropertyandvi.spyOnto throw.