mik-laj commented on a change in pull request #12558:
URL: https://github.com/apache/airflow/pull/12558#discussion_r538288171
##########
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:
I guess Ash didn't want to convert HTML to JSON.
```python
From 050901a0c75122c98cb110fe54765eb489aa89de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kamil=20Bregu=C5=82a?= <[email protected]>
Date: Tue, 8 Dec 2020 13:00:02 +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 +-
airflow/www/views.py | 2 +-
4 files changed, 4 insertions(+), 8 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..f69696214 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 | tojson }}</script>
{% endblock %}
diff --git a/airflow/www/templates/airflow/conn_edit.html
b/airflow/www/templates/airflow/conn_edit.html
index c4e9ba1f8..9e4098b2a 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 | tojson }}</script>
{% endblock %}
diff --git a/airflow/www/views.py b/airflow/www/views.py
index ae1ffea15..a2c21b5ee 100644
--- a/airflow/www/views.py
+++ b/airflow/www/views.py
@@ -2826,7 +2826,7 @@ def
lazy_add_provider_discovered_options_to_connection_form():
class ConnectionFormWidget(FormWidget):
"""Form widget used to display connection"""
- field_behaviours = json.dumps(ProvidersManager().field_behaviours)
+ field_behaviours = ProvidersManager().field_behaviours
class ConnectionModelView(AirflowModelView):
--
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]