Add support for automatic updates in the pgAdmin 4 Desktop application on macOS. #5766

This commit is contained in:
Anil Sahoo
2025-07-31 11:30:19 +05:30
committed by GitHub
parent 6db0cc5c5d
commit 9eec4f5b8c
19 changed files with 5737 additions and 181 deletions
+34 -6
View File
@@ -15,6 +15,7 @@ import { send_heartbeat, stop_heartbeat } from './heartbeat';
import getApiInstance from '../../../static/js/api_instance';
import usePreferences, { setupPreferenceBroadcast } from '../../../preferences/static/js/store';
import checkNodeVisibility from '../../../static/js/check_node_visibility';
import {appAutoUpdateNotifier} from '../../../static/js/helpers/appAutoUpdateNotifier';
define('pgadmin.browser', [
'sources/gettext', 'sources/url_for', 'sources/pgadmin',
@@ -272,12 +273,34 @@ define('pgadmin.browser', [
checkMasterPassword(data, self.masterpass_callback_queue, cancel_callback);
},
check_version_update: function() {
check_version_update: async function(trigger_update_check=false) {
getApiInstance().get(
url_for('misc.upgrade_check')
url_for('misc.upgrade_check') + '?trigger_update_check=' + trigger_update_check
).then((res)=> {
const data = res.data.data;
if(data.outdated) {
window.electronUI?.sendDataForAppUpdate({
'check_for_updates': data.check_for_auto_updates,
});
const isDesktopWithAutoUpdate = pgAdmin.server_mode == 'False' && data.check_for_auto_updates && data.auto_update_url !== '';
const isUpdateAvailable = data.outdated && data.upgrade_version_int > data.current_version_int;
const noUpdateMessage = 'No update available...';
// This is for desktop installers whose auto_update_url is mentioned in https://www.pgadmin.org/versions.json
if (isDesktopWithAutoUpdate) {
if (isUpdateAvailable) {
const message = `${gettext('You are currently running version %s of %s, however the current version is %s.', data.current_version, data.product_name, data.upgrade_version)}`;
appAutoUpdateNotifier(
message,
'warning',
() => {
window.electronUI?.sendDataForAppUpdate(data);
},
null,
'Update available',
'download_update'
);
}
} else if(data.outdated) {
//This is for server mode or auto-update not supported desktop installer or not mentioned auto_update_url
pgAdmin.Browser.notifier.warning(
`
${gettext('You are currently running version %s of %s, <br/>however the current version is %s.', data.current_version, data.product_name, data.upgrade_version)}
@@ -287,9 +310,14 @@ define('pgadmin.browser', [
null
);
}
}).catch(function() {
// Suppress any errors
// If the user manually triggered a check for updates (trigger_update_check is true)
// and no update is available (data.outdated is false), show an info notification.
if (!data.outdated && trigger_update_check){
appAutoUpdateNotifier(noUpdateMessage, 'info', null, 10000);
}
}).catch((error)=>{
console.error('Error during version check', error);
pgAdmin.Browser.notifier.error(gettext(`${error.response?.data?.errormsg || error?.message}`));
});
},