ImportAKSProjects: Extract hook, add tests, refactor UI#397
ImportAKSProjects: Extract hook, add tests, refactor UI#397skoeva wants to merge 1 commit intoAzure:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR refactors the AKS Desktop “Import AKS Projects” flow by extracting the orchestration logic into a reusable hook, switching the UI to use built-in table row selection, and centralizing AKS project label constants for reuse across create/import/delete flows.
Changes:
- Introduces
useImportAKSProjectsto handle namespace discovery (az graph), cluster registration, localStorage updates, and navigation. - Updates the Import UI to use MRT row selection and a simplified action toolbar.
- Adds shared AKS label constants and updates multiple components to consume them; adds unit tests for the new hook.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| plugins/aks-desktop/src/utils/shared/isAksProject.tsx | Uses centralized AKS label constants when identifying AKS-managed projects. |
| plugins/aks-desktop/src/utils/shared/aksLabels.ts | New shared constants for AKS project label keys/values. |
| plugins/aks-desktop/src/components/ImportAKSProjects/hooks/useImportAKSProjects.ts | New hook encapsulating import discovery + orchestration, including parallel cluster registration. |
| plugins/aks-desktop/src/components/ImportAKSProjects/hooks/useImportAKSProjects.test.ts | New unit tests covering discovery, import grouping, storage updates, and navigation. |
| plugins/aks-desktop/src/components/ImportAKSProjects/ImportAKSProjects.tsx | Refactored UI to use hook + built-in row selection with a simplified layout. |
| plugins/aks-desktop/src/components/DeleteAKSProject/AKSProjectDeleteButton.tsx | Replaces hardcoded label strings with shared constants. |
| plugins/aks-desktop/src/components/CreateAKSProject/CreateAKSProject.tsx | Replaces hardcoded label strings with shared constants when creating projects. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
plugins/aks-desktop/src/components/ImportAKSProjects/hooks/useImportAKSProjects.ts
Outdated
Show resolved
Hide resolved
plugins/aks-desktop/src/components/ImportAKSProjects/hooks/useImportAKSProjects.ts
Outdated
Show resolved
Hide resolved
plugins/aks-desktop/src/components/ImportAKSProjects/ImportAKSProjects.tsx
Outdated
Show resolved
Hide resolved
|
I think this PR is going to have a lot of conflicts with this one #314, can we hold this one until 314 is merged? |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
plugins/aks-desktop/src/components/ImportAKSProjects/hooks/useImportAKSProjects.ts
Outdated
Show resolved
Hide resolved
plugins/aks-desktop/src/components/ImportAKSProjects/hooks/useImportAKSProjects.test.ts
Outdated
Show resolved
Hide resolved
ca480ad to
0a6e850
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 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.
plugins/aks-desktop/src/components/ImportAKSProjects/hooks/useImportAKSProjects.ts
Outdated
Show resolved
Hide resolved
plugins/aks-desktop/src/components/ImportAKSProjects/ImportAKSProjects.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
💡 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.
plugins/aks-desktop/src/components/ImportAKSProjects/hooks/useImportAKSProjects.ts
Outdated
Show resolved
Hide resolved
plugins/aks-desktop/src/components/ImportAKSProjects/hooks/useImportAKSProjects.ts
Show resolved
Hide resolved
plugins/aks-desktop/src/components/ImportAKSProjects/ImportAKSProjects.tsx
Show resolved
Hide resolved
plugins/aks-desktop/src/components/ImportAKSProjects/hooks/useImportAKSProjects.test.ts
Outdated
Show resolved
Hide resolved
illume
left a comment
There was a problem hiding this comment.
Thanks for this. Can you please address the open review comments?
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 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.
plugins/aks-desktop/src/components/ImportAKSProjects/hooks/useImportAKSProjects.ts
Outdated
Show resolved
Hide resolved
plugins/aks-desktop/src/components/ImportAKSProjects/hooks/useImportAKSProjects.test.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
💡 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.
plugins/aks-desktop/src/components/ImportAKSProjects/hooks/useImportAKSProjects.ts
Outdated
Show resolved
Hide resolved
plugins/aks-desktop/src/components/ImportAKSProjects/hooks/useImportAKSProjects.ts
Outdated
Show resolved
Hide resolved
illume
left a comment
There was a problem hiding this comment.
There's some conflicts. Can you please have a look?
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
💡 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.
| // Register the cluster if it's not already registered in Headlamp. | ||
| // Re-registering overwrites the kubeconfig with namespace-scoped credentials, | ||
| // which would break access to previously imported namespaces on this cluster. | ||
| if (!registeredClusters.has(clusterName)) { | ||
| if (!subscriptionId || !resourceGroup) { | ||
| for (const ns of namespacesInCluster) { | ||
| results.push({ | ||
| namespace: `${ns.name} (${clusterName})`, | ||
| clusterName, | ||
| success: false, | ||
| message: t( | ||
| 'Cluster {{clusterName}} must be registered before importing regular namespaces. Import a managed namespace from this cluster first.', | ||
| { clusterName } | ||
| ), | ||
| }); | ||
| } | ||
| continue; | ||
| } | ||
|
|
||
| const registerResult = await registerAKSCluster( | ||
| subscriptionId, | ||
| resourceGroup, | ||
| clusterName | ||
| ); |
| "Waiting for namespace to be created": "Waiting for namespace to be created", | ||
| "Namespace status verification failed: {{message}}": "Namespace status verification failed: {{message}}", | ||
| "Namespace creation API succeeded, proceeding with user assignments": "Namespace creation API succeeded, proceeding with user assignments", | ||
| "Namespace creation completed successfully! Adding user access": "Namespace creation completed successfully! Adding user access", |
Signed-off-by: Evangelos Skopelitis <eskopelitis@microsoft.com>
These changes extract all logic from
ImportAKSProjectsinto a dedicateduseImportAKSProjectshook and replace the custom selection UI with the built-in MRT row selection.Fixes: #118
Summary
useImportAKSProjectsenableRowSelectionlocalStoragerace conditions when multiple clusters share the same nameaksLabels.ts— superseded byutils/constants/projectLabels.tsintroduced in project: Add ability to import and convert namespaces into projects #314Testing
cd plugins/aks-desktop && npm testand ensure the tests passScreenshot