Skip to content

Fixes #17405: Added plugin icon to plugin list/detail #19333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions netbox/core/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class Plugin:
The representation of a NetBox plugin in the catalog API.
"""
id: str = ''
icon_url: str = ''
status: str = ''
title_short: str = ''
title_long: str = ''
Expand Down Expand Up @@ -193,6 +194,7 @@ def make_plugin_dict():
# Populate plugin data
plugins[data['config_name']] = Plugin(
id=data['id'],
icon_url=data['icon'],
status=data['status'],
title_short=data['title_short'],
title_long=data['title_long'],
Expand Down
10 changes: 8 additions & 2 deletions netbox/core/tables/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
)


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 @@ -39,8 +45,8 @@ class Meta(BaseTable.Meta):


class CatalogPluginTable(BaseTable):
title_long = tables.Column(
linkify=('core:plugin', [tables.A('config_name')]),
title_long = columns.TemplateColumn(
template_code=PLUGIN_NAME_TEMPLATE,
verbose_name=_('Name')
)
author = tables.Column(
Expand Down
2 changes: 1 addition & 1 deletion netbox/project-static/dist/netbox.css

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions netbox/project-static/styles/custom/_misc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,15 @@ span.color-label {
.btn-grey, .btn-gray {
@extend .btn-secondary;
}

img.plugin-icon {
max-width: 1.4285em;
Copy link
Member Author

@jnovinger jnovinger Apr 25, 2025

Choose a reason for hiding this comment

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

This was eye-balled (at ~9/7) so that it matched the font-size. I didn't immediately see any variables to re-use here.

height: auto;
}

body[data-bs-theme=dark] {
// Assuming icon is black/white line art, invert it and tone down brightness
img.plugin-icon {
filter: grayscale(100%) invert(100%) brightness(80%);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Not loving this approach, unless we'll only ever accept black/white line-drawing-ish icons.

Copy link
Contributor

@pheus pheus Apr 28, 2025

Choose a reason for hiding this comment

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

Just a quick drive-by thought: you could consider adding grayscale() to the filter as well:

filter: grayscale() invert() brightness(80%);

Also, small note - you don't need to specify 100% for invert; invert(), invert(1), and invert(100%) are equivalent. (See MDN docs if helpful.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks @pheus , appreciate the pointers.

}
2 changes: 1 addition & 1 deletion netbox/templates/core/plugin.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% load i18n %}
{% load render_table from django_tables2 %}

{% block title %}{{ plugin.title_long }}{% endblock %}
{% block title %}<img class="plugin-icon" src="{{ plugin.icon_url }}">&nbsp;{{ plugin.title_long }}{% endblock %}

{% block object_identifier %}
{% endblock object_identifier %}
Expand Down