Skip to content

Fix "New Item" sidebar URL when browsing a folder view#740

Open
dakanggo wants to merge 1 commit intojenkinsci:masterfrom
dakanggo:master
Open

Fix "New Item" sidebar URL when browsing a folder view#740
dakanggo wants to merge 1 commit intojenkinsci:masterfrom
dakanggo:master

Conversation

@dakanggo
Copy link
Copy Markdown

@dakanggo dakanggo commented Apr 8, 2026

Problem

With the Folders plugin, the sidebar "New Item" link is rendered from Folder/tasks-create.jelly using getNearestAncestorUrl(request, folder), which resolves to the folder URL only (e.g. job/myfolder/). When the user is on a non-default view inside that folder (e.g. job/myfolder/view/my_view/), the link incorrectly points to .../newJob under the folder root instead of .../view/my_view/newJob.

Solution

Compute the link prefix from the current View when the Jelly context exposes the view variable (as set by Jenkins core’s View/index.jelly before the side panel is rendered), and fall back to the folder URL when that is not available.

Testing

  • Manual: create a folder, add a non-primary list view, open that view, click "New Item" in the sidebar and confirm the URL includes view/<name>/.
  • Regression: open the folder’s primary/default view and confirm "New Item" still works.

Proposed changelog entries

  • Fix sidebar "New Item" URL when a folder view other than the primary view is selected.

@dakanggo dakanggo requested a review from a team as a code owner April 8, 2026 01:37
@jtnord
Copy link
Copy Markdown
Member

jtnord commented Apr 8, 2026

When the user is on a non-default view inside that folder (e.g. job/myfolder/view/my_view/), the link incorrectly points to .../newJob under the folder root instead of .../view/my_view/newJob.

Why is this an issue, what problems does it cause?

@@ -24,5 +24,9 @@ THE SOFTWARE.
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:s="/lib/form">
<j:set var="url" value="${h.getNearestAncestorUrl(request2,it)}"/>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@dakanggo
Copy link
Copy Markdown
Author

dakanggo commented Apr 9, 2026

When the user is on a non-default view inside that folder (e.g. job/myfolder/view/my_view/), the link incorrectly points to .../newJob under the folder root instead of .../view/my_view/newJob.

Why is this an issue, what problems does it cause?

When I create a folder on the home page, navigate into that folder, and then create a view inside it, selecting that view to create a job does not place the job under the current view. Instead, the job is created directly under the folder.

Example:

  • home page → Create new item select Folder and named myFolder
  • home page/myFolder → Create new view named myView
  • home page/myFolder/myView → Attempt to create new item named myJob

Expected behavior: myJob should reside under home page/myFolder/myView.
Actual behavior: myJob is incorrectly placed under home page/myFolder instead.

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