Skip to content
Snippets Groups Projects
Commit 907dc7f2 authored by Martin Lowe's avatar Martin Lowe :flag_ca:
Browse files

Merge branch 'malowe/main/revalidation-fix' into 'main'

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

See merge request !187
parents bec0588d 99f828b9
No related branches found
No related tags found
1 merge request!187Add patch for revalidation button in status UI to handle missing form
Pipeline #44033 passed
......@@ -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");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment