Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

19073 allow plugins to be marked as hidden or disabled in plugins table #19087

Merged
merged 5 commits into from
Apr 9, 2025

Conversation

arthanson
Copy link
Collaborator

@arthanson arthanson commented Apr 4, 2025

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]

@arthanson arthanson marked this pull request as ready for review April 4, 2025 16:30
@arthanson arthanson requested review from a team and jeremystretch and removed request for a team April 4, 2025 16:30
@arthanson
Copy link
Collaborator Author

Changed from disabled to unlinked as that seems more descriptive. I think unavailable would also be confusing as it is available / installed it just doesn't have installation instructions or details. Not 100% happy with unlinked

@arthanson arthanson requested a review from jeremystretch April 8, 2025 14:33
Copy link
Member

@jeremystretch jeremystretch left a comment

Choose a reason for hiding this comment

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

One note: The detail view for a plugin is still visible even if a plugin has been declared hidden or static. It's unclear to me whether this is intended, so I'm approving this as-is.

@jeremystretch jeremystretch merged commit 076d16c into feature Apr 9, 2025
6 checks passed
@jeremystretch jeremystretch deleted the 19073-plugin-display branch April 9, 2025 12:02
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