[PR #19794] [MERGED] Closes: #19793 - Nav menu link customization #15717

Closed
opened 2025-12-30 00:23:37 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/19794
Author: @bctiemann
Created: 6/30/2025
Status: Merged
Merged: 7/14/2025
Merged by: @jeremystretch

Base: mainHead: nav-menu-callables


📝 Commits (10+)

  • d012981 Support menu items that are callables
  • 874d020 Merge branch 'main' into nav-menu-callables
  • 4ca4884 Fix quote on add button
  • 9a46c8e Merge branch 'main' into nav-menu-callables
  • fbf639f Merge branch 'main' into nav-menu-callables
  • 9d6abcf Merge branch 'main' into nav-menu-callables
  • 600f85c Clarify docstring to differentiate link and url
  • e400a7c Merge remote-tracking branch 'origin/nav-menu-callables' into nav-menu-callables
  • aa4533e Merge branch 'main' into nav-menu-callables
  • 7338898 Back out support for callables but keep alternate prerendered url param

📊 Changes

3 files changed (+58 additions, -4 deletions)

View changed files

📝 netbox/netbox/navigation/__init__.py (+28 -0)
📝 netbox/netbox/plugins/navigation.py (+28 -2)
📝 netbox/utilities/templates/navigation/menu.html (+2 -2)

📄 Description

Closes: #19793

Changes the PluginMenuItem and PluginMenuButton classes to handle an alternate pre-rendered literal url init parameter, rather than just supporting link which must be a view name suitable for {% url %}.

This allows plugin authors to supply link target URLs that might require additional (arbitrary) kwargs for resolution, rather than relying on built-in NetBox view names.

Note that Django does not provide a supported way of passing arbitrary kwargs to {% url %}; the params must be known in advance and specified explicitly (i.e. {% url 'view_name' arg1='foo' arg2='bar' %}). This prevents us from implementing this functionality in a more elegant way, i.e. being able to pass a link_kwargs dict which could then be plugged into the template directly like {% url item.link **item.link_kwargs %}.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/19794 **Author:** [@bctiemann](https://github.com/bctiemann) **Created:** 6/30/2025 **Status:** ✅ Merged **Merged:** 7/14/2025 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `main` ← **Head:** `nav-menu-callables` --- ### 📝 Commits (10+) - [`d012981`](https://github.com/netbox-community/netbox/commit/d0129811e287af48636baace28521401deb70fc5) Support menu items that are callables - [`874d020`](https://github.com/netbox-community/netbox/commit/874d020d574062c2965248bbdfe3cb8c44e4946e) Merge branch 'main' into nav-menu-callables - [`4ca4884`](https://github.com/netbox-community/netbox/commit/4ca48843af279fda77343631736d28868ad9fe1d) Fix quote on add button - [`9a46c8e`](https://github.com/netbox-community/netbox/commit/9a46c8e30da66de50605050529c5d8480683f51e) Merge branch 'main' into nav-menu-callables - [`fbf639f`](https://github.com/netbox-community/netbox/commit/fbf639fad1726c8cde6d9e063acefbec18376160) Merge branch 'main' into nav-menu-callables - [`9d6abcf`](https://github.com/netbox-community/netbox/commit/9d6abcf57bfa927644004c1e5c0deddf7f14d952) Merge branch 'main' into nav-menu-callables - [`600f85c`](https://github.com/netbox-community/netbox/commit/600f85ca835c2bb909fe95a65c2560244ab9223c) Clarify docstring to differentiate link and url - [`e400a7c`](https://github.com/netbox-community/netbox/commit/e400a7cb299bdad7c682a6ba0b1336dd08ace3e0) Merge remote-tracking branch 'origin/nav-menu-callables' into nav-menu-callables - [`aa4533e`](https://github.com/netbox-community/netbox/commit/aa4533e33178a6d335f00c3a6b1c57747e9c481a) Merge branch 'main' into nav-menu-callables - [`7338898`](https://github.com/netbox-community/netbox/commit/7338898ccb88e10f95a3a3d50518f8acb11241af) Back out support for callables but keep alternate prerendered url param ### 📊 Changes **3 files changed** (+58 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `netbox/netbox/navigation/__init__.py` (+28 -0) 📝 `netbox/netbox/plugins/navigation.py` (+28 -2) 📝 `netbox/utilities/templates/navigation/menu.html` (+2 -2) </details> ### 📄 Description ### Closes: #19793 Changes the `PluginMenuItem` and `PluginMenuButton` classes to handle an alternate pre-rendered literal `url` init parameter, rather than just supporting `link` which must be a view name suitable for `{% url %}`. This allows plugin authors to supply link target URLs that might require additional (arbitrary) kwargs for resolution, rather than relying on built-in NetBox view names. Note that Django does not provide a supported way of passing arbitrary kwargs to `{% url %}`; the params must be known in advance and specified explicitly (i.e. `{% url 'view_name' arg1='foo' arg2='bar' %}`). This prevents us from implementing this functionality in a more elegant way, i.e. being able to pass a `link_kwargs` dict which could then be plugged into the template directly like `{% url item.link **item.link_kwargs %}`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-30 00:23:37 +01:00
adam closed this issue 2025-12-30 00:23:37 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15717