You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ep...@apache.org on 2023/08/02 11:27:25 UTC

[airflow] branch main updated: Revert "fix: save codemirror content to extra textarea (#32893)" (#33032)

This is an automated email from the ASF dual-hosted git repository.

ephraimanierobi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 077fa4d9bd Revert "fix: save codemirror content to extra textarea (#32893)" (#33032)
077fa4d9bd is described below

commit 077fa4d9bdeee7ee80bcca94f78ea7d1514618c2
Author: Pankaj Koti <pa...@gmail.com>
AuthorDate: Wed Aug 2 16:57:17 2023 +0530

    Revert "fix: save codemirror content to extra textarea (#32893)" (#33032)
    
    This reverts commit f86e3a1cf722edfe0e470b5ac9aa5b981d81d777.
---
 airflow/www/static/js/connection_form.js | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/airflow/www/static/js/connection_form.js b/airflow/www/static/js/connection_form.js
index 03043a2abd..453be58411 100644
--- a/airflow/www/static/js/connection_form.js
+++ b/airflow/www/static/js/connection_form.js
@@ -202,21 +202,6 @@ $(document).ready(() => {
     $("form#model_form div.well.well-sm button:submit")
   );
 
-  // Change conn.extra TextArea widget to CodeMirror
-  const textArea = document.getElementById("extra");
-  const editor = CodeMirror.fromTextArea(textArea, {
-    mode: { name: "javascript", json: true },
-    gutters: ["CodeMirror-lint-markers"],
-    lineWrapping: true,
-    lint: true,
-  });
-
-  // beautify JSON
-  const jsonData = editor.getValue();
-  const parsedData = JSON.parse(jsonData);
-  const formattedData = JSON.stringify(parsedData, null, 2);
-  editor.setValue(formattedData);
-
   /**
    * Changes the connection type.
    * @param {string} connType The connection type to change to.
@@ -311,8 +296,6 @@ $(document).ready(() => {
         // payload.
         if (this.name === "extra") {
           let extra;
-          // save the contents of the CodeMirror editor to the textArea
-          editor.save();
           try {
             extra = JSON.parse(this.value);
           } catch (e) {
@@ -370,4 +353,19 @@ $(document).ready(() => {
 
   // Initialize the form by setting a connection type.
   changeConnType(connTypeElem.value);
+
+  // Change conn.extra TextArea widget to CodeMirror
+  const textArea = document.getElementById("extra");
+  const editor = CodeMirror.fromTextArea(textArea, {
+    mode: { name: "javascript", json: true },
+    gutters: ["CodeMirror-lint-markers"],
+    lineWrapping: true,
+    lint: true,
+  });
+
+  // beautify JSON
+  const jsonData = editor.getValue();
+  const data = JSON.parse(jsonData);
+  const formattedData = JSON.stringify(data, null, 2);
+  editor.setValue(formattedData);
 });