Skip to content

Conversation

@SohamJuneja
Copy link

This PR adds integration with the Favorites plugin to automatically show/hide the app navigation button when there are no other links defined and a favorite is added or removed. Solves #203 .
Key changes:

  • Created FavoriteIntegrationListener to respond to favorite changes
  • Added ID field to AppNavLink for tracking favorite links
  • Enhanced HeaderRootAction with favorite status change notification
  • Implemented comprehensive frontend event handling to detect favorite changes
  • Added periodic check for app-nav visibility as a fallback

Testing done

I manually tested this by:

  1. Installing both the Customizable Header plugin and Favorites plugin
  2. Adding a favorite item (job) and verifying the app-nav button appeared automatically
  3. Removing all favorites and confirming the app-nav button disappeared
  4. Testing different scenarios with existing user-defined links to ensure proper behavior

image
image

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@SohamJuneja SohamJuneja requested a review from a team as a code owner April 23, 2025 16:27
Copy link
Contributor

@mawinter69 mawinter69 left a comment

Choose a reason for hiding this comment

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

Way too complex. This can be achieved much simpler.

Copy link
Contributor

Choose a reason for hiding this comment

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

This class is not needed. When the appnav button is visible it will fetch dynamically all links including the currently defined favorites for a user.

this.logo = logo;
}

@Exported
Copy link
Contributor

Choose a reason for hiding this comment

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

Not needed

Copy link
Contributor

Choose a reason for hiding this comment

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

Changes are not needed

Copy link
Contributor

@mawinter69 mawinter69 Apr 23, 2025

Choose a reason for hiding this comment

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

The favorite plugin already sends a javascript event favorite-plugin-icon-change
See https://github.com/jenkinsci/favorite-plugin/blob/da0aca35f77d219c65bff687c6eac96bb9404445/src/main/resources/hudson/plugins/favorite/assets.js
Lines 14 and 23
So all you need to do is setup and event listener to react on that event and then ask via a fetch call if links are defined or not.

Copy link
Contributor

@mawinter69 mawinter69 Apr 23, 2025

Choose a reason for hiding this comment

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

Reacting if someone adds a link (could also be an admin that configured the first link) or you toggle the favorite in another window would be a nice to have but is not a must here. For that it is sufficient to just ask if links are defined for the user every 5 to 10 seconds and then show/hide the app-nav button accordingly

<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form" xmlns:st="jelly:stapler" xmlns:l="/lib/layout">
<f:entry>
<f:textarea field="message" previewEndpoint="/markupFormatter/previewDescription"/>
<f:textarea field="message" previewEndpoint="/markupFormatter/previewDescription?isPreview=true"/>
Copy link
Contributor

Choose a reason for hiding this comment

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

That seems to be unrelated for the purpose of this PR

<j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout">
<j:if test="${!it.dismissed}">
<div class="jenkins-alert jenkins-alert-${it.level.name()} custom-header__system-message-header">
<!-- Use a conditional style for previews -->
Copy link
Contributor

Choose a reason for hiding this comment

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

That seems to be unrelated for the purpose of this PR

@SohamJuneja
Copy link
Author

@mawinter69 Thank you for the feedback! I apologize for the overly complex approach.
Would you like me to update this PR with the simplified solution you suggested, using only the favorite-plugin-icon-change event and periodic checks? Or would you prefer I create a fresh PR instead?

@mawinter69
Copy link
Contributor

I have to apologize I should have formulated the issue more clearly.
Maybe open a new PR is better so we keep the things in here out.
Also make sure to be based on the latest state, Jenkins 2.507 changed the header in Jenkins and the plugin was adjusted accordingly.

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.

2 participants