mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-13 16:47:34 -06:00
19073 allow plugins to be marked as hidden or disabled in plugins table (#19087)
* 19073 allow plugins to be marked as hidden or disabled in plugins table * 19073 allow plugins to be marked as hidden or disabled in plugins table * 19073 allow plugins to be marked as hidden or disabled in plugins table * 19073 review changes * Rename 'unlinked' to 'static' & update docs --------- Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
This commit is contained in:
parent
fbd6d8c7fc
commit
076d16ca6b
@ -33,3 +33,21 @@ Note that a plugin must be listed in `PLUGINS` for its configuration to take eff
|
||||
|
||||
---
|
||||
|
||||
## PLUGINS_CATALOG_CONFIG
|
||||
|
||||
Default: Empty
|
||||
|
||||
This parameter controls how individual plugins are displayed in the plugins catalog under Admin > System > Plugins. Adding a plugin to the `hidden` list will omit that plugin from the catalog. Adding a plugin to the `static` list will display the plugin, but not link to the plugin details or upgrade instructions.
|
||||
|
||||
An example configuration is shown below:
|
||||
|
||||
```python
|
||||
PLUGINS_CATALOG_CONFIG = {
|
||||
'hidden': [
|
||||
'plugin1',
|
||||
],
|
||||
'static': [
|
||||
'plugin2',
|
||||
],
|
||||
}
|
||||
```
|
||||
|
@ -109,6 +109,13 @@ def get_local_plugins(plugins=None):
|
||||
else:
|
||||
plugins[k] = v
|
||||
|
||||
# Update plugin table config for hidden and static plugins
|
||||
hidden = settings.PLUGINS_CATALOG_CONFIG.get('hidden', [])
|
||||
static = settings.PLUGINS_CATALOG_CONFIG.get('static', [])
|
||||
for k, v in plugins.items():
|
||||
v.hidden = k in hidden
|
||||
v.static = k in static
|
||||
|
||||
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,8 +43,7 @@ class PluginVersionTable(BaseTable):
|
||||
|
||||
class CatalogPluginTable(BaseTable):
|
||||
title_long = tables.Column(
|
||||
linkify=('core:plugin', [tables.A('config_name')]),
|
||||
verbose_name=_('Name')
|
||||
verbose_name=_('Name'),
|
||||
)
|
||||
author = tables.Column(
|
||||
accessor=tables.A('author__name'),
|
||||
@ -86,3 +87,9 @@ 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.static:
|
||||
return 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)
|
||||
|
||||
|
@ -141,6 +141,7 @@ MEDIA_ROOT = getattr(configuration, 'MEDIA_ROOT', os.path.join(BASE_DIR, 'media'
|
||||
METRICS_ENABLED = getattr(configuration, 'METRICS_ENABLED', False)
|
||||
PLUGINS = getattr(configuration, 'PLUGINS', [])
|
||||
PLUGINS_CONFIG = getattr(configuration, 'PLUGINS_CONFIG', {})
|
||||
PLUGINS_CATALOG_CONFIG = getattr(configuration, 'PLUGINS_CATALOG_CONFIG', {})
|
||||
PROXY_ROUTERS = getattr(configuration, 'PROXY_ROUTERS', ['utilities.proxy.DefaultProxyRouter'])
|
||||
QUEUE_MAPPINGS = getattr(configuration, 'QUEUE_MAPPINGS', {})
|
||||
REDIS = getattr(configuration, 'REDIS') # Required
|
||||
|
Loading…
Reference in New Issue
Block a user