Skip to content

feat(ui): add multi-cluster user logout#4425

Open
alokdangre wants to merge 5 commits intokubernetes-sigs:mainfrom
alokdangre:feature/multi-cluster-user-logout
Open

feat(ui): add multi-cluster user logout#4425
alokdangre wants to merge 5 commits intokubernetes-sigs:mainfrom
alokdangre:feature/multi-cluster-user-logout

Conversation

@alokdangre
Copy link
Contributor

@alokdangre alokdangre commented Jan 23, 2026

Summary

  • Visual support for displaying authenticated users per cluster in TopBar.
  • Implemented individual cluster logout functionality.
  • Added SelfSubjectReview API support for fetching user info.
  • Fixed multi-cluster selection state bug in useSelectedClusters hook.
  • Improved logout UX to persist view on remaining clusters.

Related Issue

Fixes #4082

Changes

  • Updated TopBar.tsx component, clusterApi

Steps to Test

  1. select multiple clusters to view
  2. click on user menu,
  3. click on logout options

Screenshots (if applicable)

Screen.Recording.2026-01-23.145438.mp4

@k8s-ci-robot k8s-ci-robot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Jan 23, 2026
@k8s-ci-robot k8s-ci-robot requested a review from ashu8912 January 23, 2026 09:24
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jan 23, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@k8s-ci-robot k8s-ci-robot requested a review from yolossn January 23, 2026 09:24
@k8s-ci-robot
Copy link
Contributor

Welcome @alokdangre!

It looks like this is your first PR to kubernetes-sigs/headlamp 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/headlamp has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Jan 23, 2026
@alokdangre alokdangre force-pushed the feature/multi-cluster-user-logout branch from 4fa5f4b to a9ece5c Compare January 23, 2026 09:31
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Jan 23, 2026
@illume illume requested a review from Copilot January 24, 2026 20:18
Copy link
Contributor

@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 for this!

Can you please check the git commit guidelines in the development documentation and update your commit message? You can compare your message to other ones.

The frontend tests are failing in the GitHub check. Can you please try running the tests locally? Also, can you please add a storybook state for this?

Copy link
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

Adds multi-cluster-aware user identity display and logout behavior in the TopBar, including a hook fix to keep multi-cluster selection derived from the URL in sync.

Changes:

  • Updated TopBar to fetch/display per-cluster authenticated user info and provide per-cluster (and “logout all”) actions.
  • Added SelfSubjectReview-based user info fetching (getClusterUserInfo) in the v1 cluster API layer.
  • Fixed useSelectedClusters to react to pathname changes (not only cluster changes) for correct multi-cluster state updates.

Reviewed changes

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

File Description
frontend/src/lib/k8s/index.ts Updates useSelectedClusters to recompute when location.pathname changes.
frontend/src/lib/k8s/api/v1/clusterApi.ts Adds ClusterUserInfo + getClusterUserInfo() using the SelfSubjectReview API with fallback behavior.
frontend/src/components/App/TopBar.tsx Implements multi-cluster user menu UX, per-cluster logout, and queries user info for selected clusters.

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

@alokdangre alokdangre force-pushed the feature/multi-cluster-user-logout branch from a9ece5c to a61d03c Compare January 25, 2026 11:45
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 25, 2026
@alokdangre alokdangre requested review from Copilot and illume January 25, 2026 11:47
Copy link
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 7 out of 7 changed files in this pull request and generated 1 comment.


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

@alokdangre alokdangre force-pushed the feature/multi-cluster-user-logout branch from a61d03c to 0c38f12 Compare January 25, 2026 11:59
@illume illume requested a review from Copilot January 25, 2026 13:23
Copy link
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 7 out of 7 changed files in this pull request and generated 7 comments.


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

@alokdangre
Copy link
Contributor Author

@illume sorry for that test error, i forgot to take snapshot, i have also added the requested changes

@alokdangre
Copy link
Contributor Author

@illume ptal

@joaquimrocha
Copy link
Contributor

@illume ,

There is precedent for wanting to logout with only one account in a few apps when you can sign in multiple times. For example, inside MS products that allow multiple logins it's possible to select which login you want to sign-out with. I use this functionality personally in a few different websites.

Sure, but this I would say is the equivalent of logging out of a cluster from the home view, which is showing all clusters there.
In this PR we are saying that users group clusters together (which do not get saved anywhere, it's an intentional and temporary measure), and from this aggregated view they want to log out from a single cluster.

I would err on not providing this option and instead just the "Log out of these grouped clusters" if we need a log out from all while visualizing a group of clusters.

@illume illume modified the milestones: v0.40.0, v0.41.0 Feb 4, 2026
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 4, 2026
Implement getClusterUserInfo in clusterApi to fetch user details using SelfSubjectReview. Export the function in apiProxy and add unit tests.

Signed-off-by: alokdangre <alokdangre@gmail.com>
…anges

Update useSelectedClusters to use useLocation and track pathname changes, fixing a bug where cluster selection state could become stale.

Signed-off-by: alokdangre <alokdangre@gmail.com>
Fetch and display authenticated user information per cluster in the user menu.
Fallback to showing the cluster name if no user info is available.
Update TopBar stories to reflect multi-user scenarios.
Update e2e tests to match the new menu item structure.

Signed-off-by: alokdangre <alokdangre@gmail.com>
@alokdangre alokdangre force-pushed the feature/multi-cluster-user-logout branch from a806ab8 to fe0a589 Compare February 5, 2026 14:14
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 5, 2026
@illume illume requested a review from Copilot February 10, 2026 19:35
@illume
Copy link
Contributor

illume commented Feb 10, 2026

@alokdangre what do you think of the last comment?

If it’s not clear, can you please ask Joaquim to expand on the bits that aren’t clear? If you disagree on some points, can you please explain why?

Copy link
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 21 out of 21 changed files in this pull request and generated 2 comments.


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

@alokdangre
Copy link
Contributor Author

@illume ,

There is precedent for wanting to logout with only one account in a few apps when you can sign in multiple times. For example, inside MS products that allow multiple logins it's possible to select which login you want to sign-out with. I use this functionality personally in a few different websites.

Sure, but this I would say is the equivalent of logging out of a cluster from the home view, which is showing all clusters there. In this PR we are saying that users group clusters together (which do not get saved anywhere, it's an intentional and temporary measure), and from this aggregated view they want to log out from a single cluster.

I would err on not providing this option and instead just the "Log out of these grouped clusters" if we need a log out from all while visualizing a group of clusters.

this seems good to me,
but my logic behind implementing the logout from specific cluster during multicluster view is that,
becuase it is just a view of group of cluster, sometimes, user may don't want any cluster to view from his selected cluster of view, so instead of going back again and selecting again, he can just remove it by logging out
that's what i thought
but @joaquimrocha consideration seems also right to me
so i will remove the logout from specific cluster logic and only keep logout from all
@illume .

@alokdangre alokdangre force-pushed the feature/multi-cluster-user-logout branch from fe0a589 to d1b2010 Compare February 12, 2026 07:23
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 12, 2026
Add logic to handle logout from specific clusters in a multi-cluster context. Update the URL to remove the logged-out cluster while persisting the view for remaining clusters.

Signed-off-by: alokdangre <alokdangre@gmail.com>
@alokdangre alokdangre force-pushed the feature/multi-cluster-user-logout branch from d1b2010 to 03c29fd Compare February 12, 2026 07:30
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Feb 12, 2026
@illume illume requested a review from Copilot February 12, 2026 09:04
Copy link
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 21 out of 21 changed files in this pull request and generated 2 comments.


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

Copy link
Contributor

@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! 🎉

I won’t merge it yet, will leave it open a bit longer to give Joaquim or others another chance to have a look.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alokdangre, illume

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Contributor

@joaquimrocha joaquimrocha left a comment

Choose a reason for hiding this comment

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

Found some code that can be optimized for readability.

@alokdangre alokdangre force-pushed the feature/multi-cluster-user-logout branch from 824137e to 3b20d05 Compare February 12, 2026 11:32
Remove per-cluster logout functionality as it is not desired. Add unit tests for handleLogoutPathUpdate and ensure stories use isolated query clients.

Signed-off-by: alokdangre <alokdangre@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. frontend Issues related to the frontend kind/feature Categorizes issue or PR as related to a new feature. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WIP: Topbar: Needs to support multi cluster users

5 participants