Skip to content

aksd: pass setSelectedTab to project header action components#406

Merged
illume merged 1 commit intoAzure:headlamp-downstreamfrom
gambtho:thgamble/domnav
Mar 12, 2026
Merged

aksd: pass setSelectedTab to project header action components#406
illume merged 1 commit intoAzure:headlamp-downstreamfrom
gambtho:thgamble/domnav

Conversation

@gambtho
Copy link
Collaborator

@gambtho gambtho commented Mar 11, 2026

Summary

  • Extend ProjectHeaderAction interface to pass setSelectedTab as a prop to header action components
  • This gives plugins a type-safe way to switch project detail tabs (e.g. navigating to the Deploy tab after pipeline setup completes)
  • Replaces the previous DOM CustomEvent approach with proper React prop-based data flow

Type of Change

  • New feature (non-breaking change which adds functionality)

Changes Made

  • projectsSlice.ts — Added setSelectedTab?: (tabId: string) => void to ProjectHeaderAction.component props interface
  • ProjectDetails.tsx — Pass setSelectedTab when rendering header action components

Why props over DOM events

  • Type-safe: TypeScript enforces the contract between Headlamp and plugins
  • Follows React data flow: props flow down through the component tree instead of bypassing React via window.dispatchEvent
  • Less coupling: plugins call a function they receive as a prop rather than dispatching magic-string events

Testing

  • Unit tests pass
  • Manual testing completed

Test Cases

  1. Header action component receives setSelectedTab prop
  2. Calling setSelectedTab('deploy') switches to the Deploy tab
  3. Calling with an invalid tab ID updates state (tab rendering handles missing tabs gracefully)

Related to

Copilot AI review requested due to automatic review settings March 11, 2026 13:54
@gambtho gambtho changed the title aksd: support external tab navigation via DOM event aksd: support external tab navigation via DOM events Mar 11, 2026
Copy link

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 a DOM-event-based mechanism for external UI components to programmatically change the selected tab on the Project Details page.

Changes:

  • Introduces a window event listener (navigate-to-deploy-tab) that reads a CustomEvent.detail value as the target tab ID.
  • Updates the selected tab state when a valid tab ID is received.

💡 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.

Copy link

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 1 out of 1 changed files in this pull request and generated 1 comment.


💡 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 previously approved these changes Mar 11, 2026
Copy link
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.

I don't know if this is the best way to do this... I asked for a review from @sniok Maybe a separate API would be good here... or maybe it's just fine.

I think it's ok, and doing it via an API might take much longer to implement, so approving.

@gambtho
Copy link
Collaborator Author

gambtho commented Mar 11, 2026

I don't know if this is the best way to do this... I asked for a review from @sniok Maybe a separate API would be good here... or maybe it's just fine.

I think it's ok, and doing it via an API might take much longer to implement, so approving.

I don't mind trying it that way too -- this doesn't seem urgent, if you'd prefer a different approach

@gambtho
Copy link
Collaborator Author

gambtho commented Mar 11, 2026

I don't know if this is the best way to do this... I asked for a review from @sniok Maybe a separate API would be good here... or maybe it's just fine.
I think it's ok, and doing it via an API might take much longer to implement, so approving.

I don't mind trying it that way too -- this doesn't seem urgent, if you'd prefer a different approach

yeah -- this seems much better, glad you said something

@gambtho gambtho changed the title aksd: support external tab navigation via DOM events aksd: pass setSelectedTab to project header action components Mar 11, 2026
Copilot AI review requested due to automatic review settings March 11, 2026 21:11
Copy link

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 2 out of 2 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.

@sniok
Copy link
Collaborator

sniok commented Mar 11, 2026

I'd expose ProjectDetailsContext to plugins, it already has setSelectedTab there.
But passing it to header action directly is fine too.

Copy link
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 9f7271a into Azure:headlamp-downstream Mar 12, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants