Skip to content

Commit

Permalink
Revert "fix: save codemirror content to extra textarea (#32893)" (#33032
Browse files Browse the repository at this point in the history
)

This reverts commit f86e3a1.
  • Loading branch information
pankajkoti authored Aug 2, 2023
1 parent 9cbe494 commit 077fa4d
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions airflow/www/static/js/connection_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
});

0 comments on commit 077fa4d

Please sign in to comment.