mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-26 18:38:38 -06:00
19073 allow plugins to be marked as hidden or disabled in plugins table
This commit is contained in:
parent
5e44e49a8a
commit
ef253e3879
@ -109,6 +109,16 @@ def get_local_plugins(plugins=None):
|
||||
else:
|
||||
plugins[k] = v
|
||||
|
||||
# Update plugin table config for hidden and disabled plugins
|
||||
for k, v in plugins.items():
|
||||
v.hidden = False
|
||||
v.disabled = False
|
||||
if k in settings.PLUGINS_TABLE_CONFIG:
|
||||
if 'hidden' in settings.PLUGINS_TABLE_CONFIG[k]:
|
||||
v.hidden = settings.PLUGINS_TABLE_CONFIG[k]['hidden']
|
||||
if 'disabled' in settings.PLUGINS_TABLE_CONFIG[k]:
|
||||
v.disabled = settings.PLUGINS_TABLE_CONFIG[k]['disabled']
|
||||
|
||||
return plugins
|
||||
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
import django_tables2 as tables
|
||||
from django.urls import reverse
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from netbox.tables import BaseTable, columns
|
||||
@ -41,7 +43,6 @@ class PluginVersionTable(BaseTable):
|
||||
|
||||
class CatalogPluginTable(BaseTable):
|
||||
title_long = tables.Column(
|
||||
linkify=('core:plugin', [tables.A('config_name')]),
|
||||
verbose_name=_('Name')
|
||||
)
|
||||
author = tables.Column(
|
||||
@ -86,3 +87,10 @@ class CatalogPluginTable(BaseTable):
|
||||
# List installed plugins first, then certified plugins, then
|
||||
# everything else (with each tranche ordered alphabetically)
|
||||
order_by = ('-is_installed', '-is_certified', 'name')
|
||||
|
||||
def render_title_long(self, value, record):
|
||||
if record.disabled:
|
||||
return f"{value}"
|
||||
|
||||
url = reverse('core:plugin', args=[record.config_name])
|
||||
return mark_safe(f"<a href='{url}'>{value}</a>")
|
||||
|
@ -613,6 +613,8 @@ class PluginListView(BasePluginView):
|
||||
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]
|
||||
|
||||
table = CatalogPluginTable(plugins, user=request.user)
|
||||
table.configure(request)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user