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>
This commit is contained in:
Arthur Hanson 2024-05-09 05:06:53 -07:00 committed by GitHub
parent 0cc2963e6f
commit 1a56e8e23b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 29 additions and 37 deletions

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">