Cleanup rendering of "plugins" display

This commit is contained in:
Oliver Walters 2022-11-01 23:21:16 +11:00
parent 00e570ca2a
commit 53007dc416
2 changed files with 71 additions and 46 deletions

View File

@ -47,52 +47,19 @@
<table class='table table-striped table-condensed'>
<thead>
<tr>
<th>{% trans "Admin" %}</th>
<th>{% trans "Name" %}</th>
<th>{% trans "Key" %}</th>
<th>{% trans "Author" %}</th>
<th>{% trans "Date" %}</th>
<th>{% trans "Version" %}</th>
<th></th>
</tr>
</thead>
<tbody>
{% plugin_list as pl_list %}
{% for plugin_key, plugin in pl_list.items %}
{% mixin_enabled plugin 'urls' as urls %}
{% mixin_enabled plugin 'settings' as settings %}
<tr>
<td>
{% if user.is_staff and perms.plugin.change_pluginconfig %}
{% url 'admin:plugin_pluginconfig_change' plugin.pk as url %}
{% include "admin_button.html" with url=url %}
{% endif %}
</td>
<td>{{ plugin.human_name }}<span class="text-muted"> - {{plugin_key}}</span>
{% define plugin.registered_mixins as mixin_list %}
{% if plugin.is_sample %}
<a class='sidebar-selector' id='select-plugin-{{plugin_key}}' data-bs-parent="#sidebar">
<span class='badge bg-info rounded-pill badge-right'>{% trans "Sample" %}</span>
</a>
{% endif %}
{% if mixin_list %}
{% for mixin in mixin_list %}
<a class='sidebar-selector' id='select-plugin-{{plugin_key}}' data-bs-parent="#sidebar">
<span class='badge bg-dark badge-right rounded-pill'>{{ mixin.human_name }}</span>
</a>
{% endfor %}
{% endif %}
{% if plugin.website %}
<a href="{{ plugin.website }}"><span class="fas fa-globe"></span></a>
{% endif %}
</td>
<td>{{ plugin.author }}</td>
<td>{% render_date plugin.pub_date %}</td>
<td>{% if plugin.version %}{{ plugin.version }}{% endif %}</td>
</tr>
{% include "InvenTree/settings/plugin_details.html" with plugin=plugin plugin_key=plugin_key %}
{% endfor %}
{% inactive_plugin_list as in_pl_list %}
@ -100,16 +67,7 @@
<tr><td colspan="5"></td></tr>
<tr><td colspan="5"><h6>{% trans 'Inactive plugins' %}</h6></td></tr>
{% for plugin_key, plugin in in_pl_list.items %}
<tr>
<td>
{% if user.is_staff and perms.plugin.change_pluginconfig %}
{% url 'admin:plugin_pluginconfig_change' plugin.pk as url %}
{% include "admin_button.html" with url=url %}
{% endif %}
</td>
<td>{{plugin.name}}<span class="text-muted"> - {{plugin.key}}</span></td>
<td colspan="3"></td>
</tr>
{% include "InvenTree/settings/plugin_details.html" with plugin=plugin plugin_key=plugin_key %}
{% endfor %}
{% endif %}
</tbody>

View File

@ -0,0 +1,67 @@
{% load inventree_extras %}
{% load i18n %}
<tr>
<td>
{% if plugin.human_name %}
{{ plugin.human_name }}
{% elif plugin.name %}
{{ plugin.name }}
{% endif %}
{% define plugin.registered_mixins as mixin_list %}
{% if mixin_list %}
{% for mixin in mixin_list %}
<a class='sidebar-selector' id='select-plugin-{{plugin_key}}' data-bs-parent="#sidebar">
<span class='badge bg-dark badge-right rounded-pill'>{{ mixin.human_name }}</span>
</a>
{% endfor %}
{% endif %}
{% if plugin.is_builtin %}
<a class='sidebar-selector' id='select-plugin-{{ plugin_key }}' data-bs-parent='#sidebar'>
<span class='badge bg-success rounded-pill badge-right'>{% trans "Builtin" %}</span>
</a>
{% endif %}
{% if plugin.is_sample %}
<a class='sidebar-selector' id='select-plugin-{{plugin_key}}' data-bs-parent="#sidebar">
<span class='badge bg-info rounded-pill badge-right'>{% trans "Sample" %}</span>
</a>
{% endif %}
{% if plugin.website %}
<a href="{{ plugin.website }}"><span class="fas fa-globe"></span></a>
{% endif %}
</td>
<td>{{ plugin_key }}</td>
{% trans "Unvailable" as no_info %}
<td>
{% if plugin.author %}
{{ plugin.author }}
{% else %}
<em>{{ no_info }}</em>
{% endif %}
</td>
<td>
{% if plugin.pub_date %}
{% render_date plugin.pub_date %}
{% else %}
<em>{{ no_info }}</em>
{% endif %}
</td>
<td>
{% if plugin.version %}
{{ plugin.version }}
{% else %}
<em>{{ no_info }}</em>
{% endif %}
</td>
<td>
{% if user.is_staff and perms.plugin.change_pluginconfig %}
{% url 'admin:plugin_pluginconfig_change' plugin.pk as url %}
{% include "admin_button.html" with url=url %}
{% endif %}
</td>
</tr>