Skip to content
Snippets Groups Projects

Add patch for revalidation button in status UI to handle missing form

1 file
+ 35
31
Compare changes
  • Side-by-side
  • Inline
@@ -252,37 +252,41 @@
// set up accordion
$('#accordion').on('hidden.bs.collapse', toggleIcon);
$('#accordion').on('shown.bs.collapse', toggleIcon);
// bind to ECA status lookup submit
document.getElementById("eclipse-eca-lookup-form").addEventListener("submit", function (e) {
// don't submit the form as we will handle it w/ ajax
e.preventDefault();
// grab the constants from the form and perform a check
const inputVal = $(e.target).find('#email-input').val();
const $submitButton = $(e.target).find('button');
// disable the button so that requests won't be spammed
$submitButton.attr("disabled", "disabled");
// use ajax to check the ECA status of the user
$.ajax({
url: `/git/eca/lookup`,
data: {
email: inputVal
},
success: function (data) {
toast(`There is a valid ECA on file for <em>${escapeHTML(inputVal)}</em>`, 'success');
},
error: function (xhr) {
console.log(xhr.status);
if (xhr.status == '403') {
toast(`There is no valid ECA on file for <em>${escapeHTML(inputVal)}</em>`, 'danger');
} else {
toast(`No Eclipse Foundation account found for <em>${escapeHTML(inputVal)}</em>`, 'warning');
}
},
complete: function () {
$submitButton.removeAttr("disabled");
}
});
});
// bind to ECA status lookup submit if present
var lookupForm = document.getElementById("eclipse-eca-lookup-form");
if (lookupForm !== null) {
lookupForm.addEventListener("submit", function (e) {
// don't submit the form as we will handle it w/ ajax
e.preventDefault();
// grab the constants from the form and perform a check
const inputVal = $(e.target).find('#email-input').val();
const $submitButton = $(e.target).find('button');
// disable the button so that requests won't be spammed
$submitButton.attr("disabled", "disabled");
// use ajax to check the ECA status of the user
$.ajax({
url: `/git/eca/lookup`,
data: {
email: inputVal
},
success: function (data) {
toast(`There is a valid ECA on file for <em>${escapeHTML(inputVal)}</em>`, 'success');
},
error: function (xhr) {
console.log(xhr.status);
if (xhr.status == '403') {
toast(`There is no valid ECA on file for <em>${escapeHTML(inputVal)}</em>`, 'danger');
} else {
toast(`No Eclipse Foundation account found for <em>${escapeHTML(inputVal)}</em>`, 'warning');
}
},
complete: function () {
$submitButton.removeAttr("disabled");
}
});
});
}
// Revalidation button binding
const revalidationForm = document.getElementById("git-eca-hook-revalidation");
Loading