mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-25 01:48:38 -06:00
Rename Installed column to Active, and add custom PluginActiveColumn with tooltip
This commit is contained in:
parent
55b5b7c53a
commit
28cf67b732
@ -67,6 +67,8 @@ class Plugin:
|
||||
is_local: bool = False # extra field for locally installed plugins
|
||||
is_installed: bool = False
|
||||
installed_version: str = ''
|
||||
netbox_min_version: str = ''
|
||||
netbox_max_version: str = ''
|
||||
|
||||
|
||||
def get_local_plugins(plugins=None):
|
||||
@ -93,13 +95,15 @@ def get_local_plugins(plugins=None):
|
||||
is_local=True,
|
||||
is_installed=plugin_name in registry['plugins']['installed'],
|
||||
installed_version=installed_version,
|
||||
netbox_min_version=plugin_config.min_version,
|
||||
netbox_max_version=plugin_config.max_version,
|
||||
)
|
||||
|
||||
# Update catalog entries for local plugins, or add them to the list if not listed
|
||||
for k, v in local_plugins.items():
|
||||
if k in plugins:
|
||||
plugins[k].is_local = True
|
||||
plugins[k].is_installed = k in registry['plugins']['installed']
|
||||
plugins[k].is_installed = k in v.is_installed
|
||||
plugins[k].installed_version = v.installed_version
|
||||
else:
|
||||
plugins[k] = v
|
||||
|
@ -50,8 +50,8 @@ class CatalogPluginTable(BaseTable):
|
||||
is_local = columns.BooleanColumn(
|
||||
verbose_name=_('Local')
|
||||
)
|
||||
is_installed = columns.BooleanColumn(
|
||||
verbose_name=_('Installed')
|
||||
is_installed = columns.PluginActiveColumn(
|
||||
verbose_name=_('Active')
|
||||
)
|
||||
is_certified = columns.BooleanColumn(
|
||||
verbose_name=_('Certified')
|
||||
|
@ -707,3 +707,22 @@ class DistanceColumn(TemplateColumn):
|
||||
|
||||
def __init__(self, template_code=template_code, order_by='_abs_distance', **kwargs):
|
||||
super().__init__(template_code=template_code, order_by=order_by, **kwargs)
|
||||
|
||||
|
||||
class PluginActiveColumn(BooleanColumn):
|
||||
ALERT_MARK = (
|
||||
'<span class="text-danger"><i class="mdi mdi-alert" data-bs-toggle="tooltip" title="{tooltip}"></i></span>'
|
||||
)
|
||||
|
||||
def __init__(self, *args, tooltip=None, **kwargs):
|
||||
self.tooltip = tooltip
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def render(self, value, record, table, **kwargs):
|
||||
if not value and self.false_mark:
|
||||
tooltip = (
|
||||
f'Could not load due to NetBox version incompatibility. '
|
||||
f'Min version: {record.netbox_min_version}, max version: {record.netbox_max_version}'
|
||||
)
|
||||
return mark_safe(self.ALERT_MARK.format(tooltip=tooltip))
|
||||
return super().render(value)
|
||||
|
Loading…
Reference in New Issue
Block a user