Skip to content

Commit

Permalink
Field Deletion Warning when editing Connections (apache#41144)
Browse files Browse the repository at this point in the history
* able to change the 'Changed Row' display message after edit

* added message in connection form to warn of empty fields

* attempt to warn the specific fields cannot be empty

* revert change because need to check fields before save is clicked

* issues warning for specific fields that can't be deleted after save

* removed the individual warnings

* changed status to concise string

* added more concise suggestion

Co-authored-by: Brent Bovenzi <[email protected]>

---------

Co-authored-by: Brent Bovenzi <[email protected]>
  • Loading branch information
lh5844 and bbovenzi authored Aug 14, 2024
1 parent 3f239dc commit c7eba18
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions airflow/www/static/js/connection_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,11 @@ $(document).ready(() => {
/**
* Displays the Flask style alert on UI via JS
*
* @param {boolean} status - true for success, false for error
* @param {string} status - Status can be either success, error, or warning
* @param {string} message - The text message to show in alert box
*/
function displayAlert(status, message) {
const alertClass = status ? "alert-success" : "alert-error";
const alertClass = `alert-${status}`;
let alertBox = $(".container .row .alert");
if (alertBox.length) {
alertBox.removeClass("alert-success").removeClass("alert-error");
Expand All @@ -255,6 +255,11 @@ $(document).ready(() => {
}
}

displayAlert(
"warning",
"Warning: Fields that are currently populated can be modified but cannot be deleted. To delete data from a field, delete the Connection object and create a new one."
);

function hideAlert() {
const alertBox = $(".container .row .alert");
alertBox.hide();
Expand Down Expand Up @@ -303,7 +308,7 @@ $(document).ready(() => {
extra = JSON.parse(this.value);
} catch (e) {
if (e instanceof SyntaxError) {
displayAlert(false, "Extra field value is not valid JSON.");
displayAlert("error", "Extra field value is not valid JSON.");
}
throw e;
}
Expand Down Expand Up @@ -345,10 +350,10 @@ $(document).ready(() => {
dataType: "json",
data: getSerializedFormData("form#model_form"),
success(data) {
displayAlert(data.status, data.message);
displayAlert("success", data.message);
},
error(jq, err, msg) {
displayAlert(false, msg);
displayAlert("error", msg);
},
});
});
Expand Down

0 comments on commit c7eba18

Please sign in to comment.