Skip to content

Commit

Permalink
Simplify plugin attributes for is_installed column
Browse files Browse the repository at this point in the history
  • Loading branch information
bctiemann committed Mar 3, 2025
1 parent 633d0c9 commit f934712
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 5 additions & 7 deletions netbox/core/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ class Plugin:
is_certified: bool = False
release_latest: PluginVersion = field(default_factory=PluginVersion)
release_recent_history: list[PluginVersion] = field(default_factory=list)
is_local: bool = False # extra field for locally installed plugins
is_installed: bool = False
failed_to_load: bool = False
is_local: bool = False # Indicates that the plugin is listed in settings.PLUGINS (i.e. installed)
is_loaded: bool = False # Indicates whether the plugin successfully loaded at launch
installed_version: str = ''
netbox_min_version: str = ''
netbox_max_version: str = ''
Expand Down Expand Up @@ -94,8 +93,7 @@ def get_local_plugins(plugins=None):
tag_line=plugin_config.description,
description_short=plugin_config.description,
is_local=True,
is_installed=True,
failed_to_load=plugin_name not in registry['plugins']['installed'],
is_loaded=plugin_name in registry['plugins']['installed'],
installed_version=installed_version,
netbox_min_version=plugin_config.min_version,
netbox_max_version=plugin_config.max_version,
Expand All @@ -104,8 +102,8 @@ def get_local_plugins(plugins=None):
# 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 = v.is_installed
plugins[k].is_local = v.is_local
plugins[k].is_loaded = v.is_loaded
plugins[k].installed_version = v.installed_version
else:
plugins[k] = v
Expand Down
10 changes: 6 additions & 4 deletions netbox/core/tables/template_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
"""

PLUGIN_IS_INSTALLED = """
{% if record.failed_to_load %}
<span class="text-danger"><i class="mdi mdi-alert" data-bs-toggle="tooltip" title="Could not load due to NetBox version incompatibility. Min version: {{ record.netbox_min_version }}, max version: {{ record.netbox_max_version }}"></i></span>
{% elif value is True %}
<span class="text-success"><i class="mdi mdi-check-bold"></i></span>
{% if record.is_local %}
{% if record.is_loaded %}
<span class="text-success"><i class="mdi mdi-check-bold"></i></span>
{% else %}
<span class="text-danger"><i class="mdi mdi-alert" data-bs-toggle="tooltip" title="Could not load plugin. Version may be incompatible. Min version: {{ record.netbox_min_version }}, max version: {{ record.netbox_max_version }}"></i></span>
{% endif %}
{% else %}
<span class="text-danger"><i class="mdi mdi-close-thick"></i></span>
{% endif %}
Expand Down

0 comments on commit f934712

Please sign in to comment.