Improve git hash info error handling in home.js

Instead of showing a generic error message alert when an error occurs,
it displays an error message at the same place where the success output
goes.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
Maurício Meneghini Fauth 2023-09-20 14:14:28 -03:00
parent 80865af230
commit 5e8ec69240
No known key found for this signature in database
GPG Key ID: 6A16FD38AFC89CC8
3 changed files with 15 additions and 7 deletions

View File

@ -894,11 +894,16 @@ $(document).on('submit', 'form', AJAX.requestHandler);
* Gracefully handle fatal server errors
* (e.g: 500 - Internal server error)
*/
$(document).on('ajaxError', function (event, request) {
$(document).on('ajaxError', function (event, request, settings) {
if (AJAX.debug) {
// eslint-disable-next-line no-console
console.log('AJAX error: status=' + request.status + ', text=' + request.statusText);
}
if (settings.url.includes('/git-revision')) {
return;
}
// Don't handle aborted requests
if (request.status !== 0 || request.statusText !== 'abort') {
var details = '';

View File

@ -105,13 +105,15 @@ const GitInfo = {
'server': CommonParams.get('server'),
'ajax_request': true,
'no_debug': true
},
function (data) {
if (typeof data !== 'undefined' && data.success === true) {
$(data.message).insertAfter('#li_pma_version');
}
}
);
).done(function (data) {
if (typeof data !== 'undefined' && data.success === true) {
$(data.message).insertAfter('#li_pma_version');
}
}).fail(function () {
const gitHashInfoLi = '<li id="li_pma_version_git" class="list-group-item">' + window.Messages.errorLoadingGitInformation + '</li>';
$(gitHashInfoLi).insertAfter('#li_pma_version');
});
}
};

View File

@ -608,6 +608,7 @@ final class JavaScriptMessagesController
/* l10n: Latest available phpMyAdmin version */
'strLatestAvailable' => __(', latest stable version:'),
'strUpToDate' => __('up to date'),
'errorLoadingGitInformation' => __('There was an error in loading the Git information.'),
/* Error Reporting */
'strErrorOccurred' => __('A fatal JavaScript error has occurred. Would you like to send an error report?'),