mik-laj commented on a change in pull request #12558:
URL: https://github.com/apache/airflow/pull/12558#discussion_r538290133
##########
File path: airflow/www/static/js/connection_form.js
##########
@@ -87,7 +40,7 @@ $(document).ready(function () {
$(this).text($(this).attr("orig_text"));
});
$(".form-control").each(function(){$(this).attr('placeholder', '')});
-
+ let config = JSON.parse(decode($("#field_behaviours")[0].innerHTML))
Review comment:
or
```diff
From e3960ffd12c95084c6215d3d5f7c5039a53fc0f8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kamil=20Bregu=C5=82a?= <[email protected]>
Date: Tue, 8 Dec 2020 13:03:08 +0100
Subject: Display field_behaviour as a JSON
---
airflow/www/static/js/connection_form.js | 6 +-----
airflow/www/templates/airflow/conn_create.html | 2 +-
airflow/www/templates/airflow/conn_edit.html | 2 +-
3 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/airflow/www/static/js/connection_form.js
b/airflow/www/static/js/connection_form.js
index 6bfa11aa7..7a60d6add 100644
--- a/airflow/www/static/js/connection_form.js
+++ b/airflow/www/static/js/connection_form.js
@@ -20,10 +20,6 @@
* Created by janomar on 23/07/15.
*/
-function decode(str) {
- return new DOMParser().parseFromString(str,
"text/html").documentElement.textContent
-}
-
$(document).ready(function () {
function connTypeChange(connectionType) {
@@ -38,7 +34,7 @@ $(document).ready(function () {
$(this).text($(this).attr("orig_text"));
});
$(".form-control").each(function(){$(this).attr('placeholder', '')});
- let config = JSON.parse(decode($("#field_behaviours").text()))
+ let config = JSON.parse($("#field_behaviours").text())
if (config[connectionType] != undefined) {
$.each(config[connectionType].hidden_fields, function (i, field) {
$("#" + field).parent().parent().addClass('hide')
diff --git a/airflow/www/templates/airflow/conn_create.html
b/airflow/www/templates/airflow/conn_create.html
index b335dd883..1971eb764 100644
--- a/airflow/www/templates/airflow/conn_create.html
+++ b/airflow/www/templates/airflow/conn_create.html
@@ -22,5 +22,5 @@
{% block tail %}
{{ super() }}
<script src="{{ url_for_asset('connectionForm.js') }}"></script>
- <script id="field_behaviours" type="text/json">{{
widgets["add"].field_behaviours }}</script>
+ <script id="field_behaviours" type="text/json">{{
widgets["add"].field_behaviours | safe}}</script>
{% endblock %}
diff --git a/airflow/www/templates/airflow/conn_edit.html
b/airflow/www/templates/airflow/conn_edit.html
index c4e9ba1f8..43ce0edae 100644
--- a/airflow/www/templates/airflow/conn_edit.html
+++ b/airflow/www/templates/airflow/conn_edit.html
@@ -22,5 +22,5 @@
{% block tail %}
{{ super() }}
<script src="{{ url_for_asset(filename='connectionForm.js') }}"></script>
- <script id="field_behaviours" type="text/json">{{
widgets["edit"].field_behaviours }}</script>
+ <script id="field_behaviours" type="text/json">{{
widgets["edit"].field_behaviours | safe }}</script>
{% endblock %}
--
2.28.0
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]