[PR #19087] [MERGED] 19073 allow plugins to be marked as hidden or disabled in plugins table #15523

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

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/19087
Author: @arthanson
Created: 4/4/2025
Status: Merged
Merged: 4/9/2025
Merged by: @jeremystretch

Base: featureHead: 19073-plugin-display


📝 Commits (5)

  • ef253e3 19073 allow plugins to be marked as hidden or disabled in plugins table
  • e801af5 19073 allow plugins to be marked as hidden or disabled in plugins table
  • 4b481cb 19073 allow plugins to be marked as hidden or disabled in plugins table
  • c0b889c 19073 review changes
  • 472688e Rename 'unlinked' to 'static' & update docs

📊 Changes

5 files changed (+37 additions, -2 deletions)

View changed files

📝 docs/configuration/plugins.md (+18 -0)
📝 netbox/core/plugins.py (+7 -0)
📝 netbox/core/tables/plugins.py (+9 -2)
📝 netbox/core/views.py (+2 -0)
📝 netbox/netbox/settings.py (+1 -0)

📄 Description

Fixes: #19073

Defined a new config parameter PLUGINS_CATALOG_CONFIG, I kept it separate from PLUGINS_CONFIG as those settings are directly controlled by the plugin itself and I didn't want to potentially break it if there were overlap In the names or the plugin wasn't expecting additional params for some reason (probably very unlikely, but...)

PLUGINS_CATALOG_CONFIG = {
    'hidden': ['netbox_acls',],
    'unlinked': ['netbox_bgp',],
}

With this config can see netbox_acls was removed from the list and netbox_bgp is not a clickable link anymore:

Monosnap Plugins | NetBox 2025-04-04 09-09-59

In netbox/core/views.py could unfold the if q: lines to make one loop through the list, but thought this was clearer and list comprehension is very fast (and a short list). I also wanted to keep the list with the hidden flags instead of removing them when it initially generates the list as we may potentially want to use the complete list for other things in the future (including hidden items).

        plugins = self.get_cached_plugins(request).values()
        if q:
            plugins = [obj for obj in plugins if q.casefold() in obj.title_short.casefold()]

        plugins = [plugin for plugin in plugins if not plugin.hidden]

🔄 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/19087 **Author:** [@arthanson](https://github.com/arthanson) **Created:** 4/4/2025 **Status:** ✅ Merged **Merged:** 4/9/2025 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `feature` ← **Head:** `19073-plugin-display` --- ### 📝 Commits (5) - [`ef253e3`](https://github.com/netbox-community/netbox/commit/ef253e3879563c5e721976a4c3eeb73f76b61872) 19073 allow plugins to be marked as hidden or disabled in plugins table - [`e801af5`](https://github.com/netbox-community/netbox/commit/e801af513868de5862fb176fe324973be74e1692) 19073 allow plugins to be marked as hidden or disabled in plugins table - [`4b481cb`](https://github.com/netbox-community/netbox/commit/4b481cbacf34485b98fff13c44d384f7d7827e14) 19073 allow plugins to be marked as hidden or disabled in plugins table - [`c0b889c`](https://github.com/netbox-community/netbox/commit/c0b889ceee0edf907fd57d707d56295530ab8e7f) 19073 review changes - [`472688e`](https://github.com/netbox-community/netbox/commit/472688eb503e22d03960242fbf158d82cedffabe) Rename 'unlinked' to 'static' & update docs ### 📊 Changes **5 files changed** (+37 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `docs/configuration/plugins.md` (+18 -0) 📝 `netbox/core/plugins.py` (+7 -0) 📝 `netbox/core/tables/plugins.py` (+9 -2) 📝 `netbox/core/views.py` (+2 -0) 📝 `netbox/netbox/settings.py` (+1 -0) </details> ### 📄 Description ### Fixes: #19073 Defined a new config parameter PLUGINS_CATALOG_CONFIG, I kept it separate from PLUGINS_CONFIG as those settings are directly controlled by the plugin itself and I didn't want to potentially break it if there were overlap In the names or the plugin wasn't expecting additional params for some reason (probably very unlikely, but...) ``` PLUGINS_CATALOG_CONFIG = { 'hidden': ['netbox_acls',], 'unlinked': ['netbox_bgp',], } ``` With this config can see netbox_acls was removed from the list and netbox_bgp is not a clickable link anymore: ![Monosnap Plugins | NetBox 2025-04-04 09-09-59](https://github.com/user-attachments/assets/4b00addf-9154-411b-a2b1-8e8b04ad3634) In netbox/core/views.py could unfold the `if q:` lines to make one loop through the list, but thought this was clearer and list comprehension is very fast (and a short list). I also wanted to keep the list with the hidden flags instead of removing them when it initially generates the list as we may potentially want to use the complete list for other things in the future (including hidden items). ``` plugins = self.get_cached_plugins(request).values() if q: plugins = [obj for obj in plugins if q.casefold() in obj.title_short.casefold()] plugins = [plugin for plugin in plugins if not plugin.hidden] ``` --- <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:22:28 +01:00
adam closed this issue 2025-12-30 00:22:28 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#15523