diff --git a/netbox/core/plugins.py b/netbox/core/plugins.py index 8fed9b3b7..d86ad00d0 100644 --- a/netbox/core/plugins.py +++ b/netbox/core/plugins.py @@ -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 diff --git a/netbox/core/tables/plugins.py b/netbox/core/tables/plugins.py index 96c612366..19962d7ca 100644 --- a/netbox/core/tables/plugins.py +++ b/netbox/core/tables/plugins.py @@ -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') diff --git a/netbox/netbox/tables/columns.py b/netbox/netbox/tables/columns.py index cf6e1f133..97ad50a7e 100644 --- a/netbox/netbox/tables/columns.py +++ b/netbox/netbox/tables/columns.py @@ -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 = ( + '' + ) + + 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)