14731 review changes

This commit is contained in:
Arthur Hanson 2024-07-23 14:56:38 +07:00
parent 3faf6dfbac
commit 56fb5382a9
5 changed files with 54 additions and 26 deletions

View File

@ -63,6 +63,7 @@ class Plugin:
release_recent_history: list[PluginVersion] = field(default_factory=list)
is_local: bool = False # extra field for locally installed plugins
is_installed: bool = False
installed_version: str = ''
def get_local_plugins():
@ -81,6 +82,7 @@ def get_local_plugins():
description_short=plugin_config.description,
is_local=True,
is_installed=True,
installed_version=plugin_config.version,
)
return plugins

View File

@ -62,11 +62,15 @@ class CatalogPluginTable(BaseTable):
updated_at = columns.DateTimeColumn(
verbose_name=_('Updated')
)
installed_version = tables.Column(
verbose_name=_('Installed version')
)
class Meta(BaseTable.Meta):
empty_text = _('No plugin data found')
fields = (
'title_short', 'author', 'is_local', 'is_installed', 'is_certified', 'created_at', 'updated_at',
'installed_version',
)
default_columns = (
'title_short', 'author', 'is_local', 'is_installed', 'is_certified', 'created_at', 'updated_at',

View File

@ -654,7 +654,7 @@ class PluginListView(UserPassesTestMixin, View):
plugins = get_plugins().values()
if q:
plugins = [obj for obj in plugins if q.casefold() in obj.name.casefold()]
plugins = [obj for obj in plugins if q.casefold() in obj.title_short.casefold()]
table = CatalogPluginTable(plugins, user=request.user)
table.configure(request)
@ -678,6 +678,8 @@ class PluginView(UserPassesTestMixin, View):
def get(self, request, name):
plugins = get_plugins()
if name not in plugins:
raise Http404(_("Plugin {name} not found").format(name=name))
plugin = plugins[name]
table = PluginVersionTable(plugin.release_recent_history, user=request.user)

View File

@ -15,7 +15,7 @@
{% block subtitle %}
<div class="text-secondary fs-5">
{{ plugin.tag_line }}
<a href="{{ plugin.homepage.url }}" target="_blank">Learn more <i class="mdi mdi-launch"></i></a>
<a href="{{ plugin.homepage_url }}" target="_blank">Learn more <i class="mdi mdi-launch"></i></a>
</div>
{% endblock subtitle %}
@ -53,12 +53,40 @@
<div class="row">
<div class="col col-md-12">
<div class="card">
<h5 class="card-header">{% trans "Author" %}</h5>
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Author" %}</th>
<td>{{ plugin.author.name }}</td>
</tr>
<tr>
<th scope="row">{% trans "Org id" %}</th>
<td>{{ plugin.author.org_id|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "URL" %}</th>
<td>{{ plugin.author.url|urlize|placeholder }}</td>
</tr>
</table>
</div>
<div class="card">
<h5 class="card-header">{% trans "Plugin" %}</h5>
<table class="table table-hover attr-table">
<tr>
<th scope="row">{% trans "Name" %}</th>
<td>{{ plugin.title_short }}</td>
</tr>
<tr>
<th scope="row">{% trans "Tag line" %}</th>
<td>{{ plugin.tag_line|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Status" %}</th>
<td>{% badge object.get_status_display bg_color=object.get_status_color %}</td>
</tr>
<tr>
<th scope="row">{% trans "License" %}</th>
<td>{{ plugin.license_type }}</td>
@ -67,6 +95,22 @@
<th scope="row">{% trans "Description" %}</th>
<td>{{ plugin.description_short|markdown }}</td>
</tr>
<tr>
<th scope="row">{% trans "URL" %}</th>
<td>{{ plugin.homepage_url|urlize|placeholder }}</td>
</tr>
<tr>
<th scope="row">{% trans "Certified" %}</th>
<td>{% checkmark plugin.is_certified %}</td>
</tr>
<tr>
<th scope="row">{% trans "Local" %}</th>
<td>{% checkmark plugin.is_local %}</td>
</tr>
<tr>
<th scope="row">{% trans "Installed" %}</th>
<td>{% checkmark plugin.is_installed %}</td>
</tr>
</table>
</div>
</div>

View File

@ -17,27 +17,3 @@
</ul>
{% endblock tabs %}
{% block content %}
<div class="tab-pane show active" id="object-list" role="tabpanel" aria-labelledby="object-list-tab">
<p>{% trans "NetBox plugins enable you to document and model new kinds of resources, connect automations, add workflows, and much more." %}</p>
<div class="row mb-3" id="results">
<div class="col-auto d-print-none">
<div class="input-group input-group-flat me-2 quicksearch" hx-disinherit="hx-select hx-swap">
<input type="search" results="5" name="q" id="quicksearch" class="form-control" placeholder="{% trans "Quick search" %}"
hx-get="{{ request.full_path }}" hx-target="#object_list" hx-trigger="keyup changed delay:500ms, search"/>
<span class="input-group-text py-1">
<a href="#" id="quicksearch_clear" class="invisible text-secondary"><i class="mdi mdi-close-circle"></i></a>
</span>
</div>
</div>
</div>
<div class="card">
<div class="htmx-container table-responsive" id="object_list">
{% include 'htmx/table.html' %}
</div>
</div>
</div>
{% endblock content %}