Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions netbox/core/tables/plugins.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
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
from .template_code import PLUGIN_IS_INSTALLED
from .template_code import PLUGIN_IS_INSTALLED, PLUGIN_NAME_TEMPLATE

__all__ = (
'CatalogPluginTable',
'PluginVersionTable',
)


PLUGIN_NAME_TEMPLATE = """
<img class="plugin-icon" src="{{ record.icon_url }}">
<a href="{% url 'core:plugin' record.config_name %}">{{ record.title_long }}</a>
"""


class PluginVersionTable(BaseTable):
version = tables.Column(
verbose_name=_('Version')
Expand Down Expand Up @@ -93,10 +85,4 @@ class Meta(BaseTable.Meta):
)
# 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>")
order_by = ('-is_installed', '-is_certified', 'title_long')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about the behavior of is_installed. Since it is a field that only renders a template fragment based on the values of is_local and is_loaded, and there is no is_installed concrete field on the Plugin (anymore), is it meaningful to use it as an ordering column?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I guess this depends on #20267, with which it would make sense, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review!

You’re right: order_by="-is_installed" predates this PR and is currently broken because there’s no concrete field. That will be fixed by #20267.
This PR only corrects the bad reference by changing order_by="name" to order_by="title_long".

10 changes: 10 additions & 0 deletions netbox/core/tables/template_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@
{% endif %}
"""

PLUGIN_NAME_TEMPLATE = """
{% load static %}
{% if record.icon_url %}
<img class="plugin-icon" src="{{ record.icon_url }}">
{% else %}
<img class="plugin-icon" src="{% static 'plugin-default.svg' %}">
{% endif %}
<a href="{% url 'core:plugin' record.config_name %}">{{ record.title_long }}</a>
"""

DATA_SOURCE_SYNC_BUTTON = """
{% load helpers %}
{% load i18n %}
Expand Down
1 change: 1 addition & 0 deletions netbox/project-static/img/plugin-default.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.