Compare commits

...

3 Commits

Author SHA1 Message Date
Jeremy Stretch 510e7020b5
Merge ba8b0ebf79 into f40fb6a707 2024-05-09 07:37:26 -07:00
teapot f40fb6a707 Fixes #16051: Wrap empty_text with gettext_lazy() 2024-05-09 08:09:53 -04:00
Arthur Hanson 1a56e8e23b
15148 add copy button to config context (#15954)
* 15148 add copy button to config context

* Merge configcontext_format.html into configcontext_data.html

---------

Co-authored-by: Jeremy Stretch <jstretch@netboxlabs.com>
2024-05-09 08:06:53 -04:00
6 changed files with 30 additions and 38 deletions

View File

@ -52,7 +52,7 @@ class BaseTable(tables.Table):
# Set default empty_text if none was provided
if self.empty_text is None:
self.empty_text = f"No {self._meta.model._meta.verbose_name_plural} found"
self.empty_text = _("No {model_name} found").format(model_name=self._meta.model._meta.verbose_name_plural)
# Determine the table columns to display by checking the following:
# 1. User's configuration for the table

View File

@ -77,15 +77,9 @@
</div>
</div>
<div class="col col-md-7">
{% include 'inc/sync_warning.html' %}
<div class="card">
<h5 class="card-header d-flex justify-content-between">
{% trans "Data" %}
{% include 'extras/inc/configcontext_format.html' %}
</h5>
<div class="card-body">
{% include 'inc/sync_warning.html' %}
{% include 'extras/inc/configcontext_data.html' with data=object.data format=format %}
</div>
{% include 'extras/inc/configcontext_data.html' with title="Data" data=object.data format=format copyid="data" %}
</div>
</div>
</div>

View File

@ -1,5 +1,17 @@
{% load helpers %}
{% load i18n %}
<div class="rendered-context-data mt-1">
<pre class="block">{% if format == 'json' %}{{ data|json }}{% elif format == 'yaml' %}{{ data|yaml }}{% else %}{{ data }}{% endif %}</pre>
{% if title %}
<h5 class="card-header d-flex justify-content-between">
{% trans title %}
<div>
{% if copyid %}{% copy_content copyid %}{% endif %}
{% include 'extras/inc/format_toggle.html' %}
</div>
</h5>
{% endif %}
<div class="card-body">
<div class="rendered-context-data mt-1">
<pre class="block" {% if copyid %}id="{{ copyid }}{% endif %}">{% if format == 'json' %}{{ data|json }}{% elif format == 'yaml' %}{{ data|yaml }}{% else %}{{ data }}{% endif %}</pre>
</div>
</div>

View File

@ -1,6 +0,0 @@
<div>
<div class="btn-group btn-group-sm" role="group">
<a href="?format=json" type="button" class="btn btn-outline-dark{% if format == 'json' %} active{% endif %}">JSON</a>
<a href="?format=yaml" type="button" class="btn btn-outline-dark{% if format == 'yaml' %} active{% endif %}">YAML</a>
</div>
</div>

View File

@ -0,0 +1,4 @@
<div class="btn-group btn-group-sm" role="group">
<a href="?format=json" type="button" class="btn btn-outline-dark{% if format == 'json' %} active{% endif %}">JSON</a>
<a href="?format=yaml" type="button" class="btn btn-outline-dark{% if format == 'yaml' %} active{% endif %}">YAML</a>
</div>

View File

@ -6,28 +6,13 @@
{% block content %}
<div class="row">
<div class="col col-md-6">
<div class="card">
<h5 class="card-header d-flex justify-content-between">
{% trans "Rendered Context" %}
{% include 'extras/inc/configcontext_format.html' %}
</h5>
<div class="card-body">
{% include 'extras/inc/configcontext_data.html' with data=rendered_context format=format %}
</div>
</div>
<div class="card">
{% include 'extras/inc/configcontext_data.html' with title="Rendered Context" data=rendered_context format=format copyid="rendered_context" %}
</div>
</div>
<div class="col col-md-6">
<div class="card">
<h5 class="card-header">
{% trans "Local Context" %}
</h5>
<div class="card-body">
{% if object.local_context_data %}
{% include 'extras/inc/configcontext_data.html' with data=object.local_context_data format=format %}
{% else %}
<span class="text-muted">{% trans "None" %}</span>
{% endif %}
</div>
{% include 'extras/inc/configcontext_data.html' with title="Local Context" data=object.local_context_data format=format copyid="local_context" %}
<div class="card-footer">
<span class="help-block">
<i class="mdi mdi-information-outline"></i>
@ -36,8 +21,11 @@
</div>
</div>
<div class="card">
<h5 class="card-header">
{% trans "Source Contexts" %}
<h5 class="card-header d-flex justify-content-between">
{% trans "Source Contexts" %}
<div>
{% include 'extras/inc/format_toggle.html' %}
</div>
</h5>
{% for context in source_contexts %}
<div class="card-body">