Skip to content

Commit efbd443

Browse files
committed
IPC event and some functions and UpdateCheckNotify.jsx file renamed
1 parent a2637ee commit efbd443

File tree

5 files changed

+32
-32
lines changed

5 files changed

+32
-32
lines changed

runtime/src/js/pgadmin.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ let [pythonPath, pgadminFile] = misc.getAppPaths(__dirname);
4949

5050
const menuCallbacks = {
5151
'check_for_updates': ()=>{
52-
pgAdminMainScreen.webContents.send('appUpdateNotifier', {check_version_update: true});
52+
pgAdminMainScreen.webContents.send('notifyAppAutoUpdate', {check_version_update: true});
5353
},
5454
'restart_to_update': ()=>{
5555
forceQuitAndInstallUpdate();
@@ -451,11 +451,11 @@ function notifyUpdateInstalled() {
451451
configStore.set('update_installed', false);
452452
// Notify renderer
453453
if (pgAdminMainScreen) {
454-
pgAdminMainScreen.webContents.send('appUpdateNotifier', {update_installed: true});
454+
pgAdminMainScreen.webContents.send('notifyAppAutoUpdate', {update_installed: true});
455455
} else {
456456
// If main screen not ready, wait and send after it's created
457457
app.once('browser-window-created', (event, window) => {
458-
window.webContents.send('appUpdateNotifier', {update_installed: true});
458+
window.webContents.send('notifyAppAutoUpdate', {update_installed: true});
459459
});
460460
}
461461
}
@@ -510,25 +510,25 @@ if (process.platform === 'darwin') {
510510
autoUpdater.on('update-available', () => {
511511
setConfigAndRefreshMenu('update-available');
512512
misc.writeServerLog('[Auto-Updater]: Update downloading...');
513-
pgAdminMainScreen.webContents.send('appUpdateNotifier', {update_downloading: true});
513+
pgAdminMainScreen.webContents.send('notifyAppAutoUpdate', {update_downloading: true});
514514
});
515515

516516
autoUpdater.on('update-not-available', () => {
517517
setConfigAndRefreshMenu('update-not-available');
518518
misc.writeServerLog('[Auto-Updater]: No update available...');
519-
pgAdminMainScreen.webContents.send('appUpdateNotifier', {no_update_available: true});
519+
pgAdminMainScreen.webContents.send('notifyAppAutoUpdate', {no_update_available: true});
520520
});
521521

522522
autoUpdater.on('update-downloaded', () => {
523523
setConfigAndRefreshMenu('update-downloaded');
524524
misc.writeServerLog('[Auto-Updater]: Update downloaded...');
525-
pgAdminMainScreen.webContents.send('appUpdateNotifier', {update_downloaded: true});
525+
pgAdminMainScreen.webContents.send('notifyAppAutoUpdate', {update_downloaded: true});
526526
});
527527

528528
autoUpdater.on('error', (message) => {
529529
setConfigAndRefreshMenu('error-close');
530530
misc.writeServerLog(`[Auto-Updater]: ${message}`);
531-
pgAdminMainScreen.webContents.send('appUpdateNotifier', {error: true, errMsg: message});
531+
pgAdminMainScreen.webContents.send('notifyAppAutoUpdate', {error: true, errMsg: message});
532532
});
533533

534534
ipcMain.on('sendDataForAppUpdate', (_, data) => {
@@ -552,7 +552,7 @@ if (process.platform === 'darwin') {
552552
} catch (err) {
553553
misc.writeServerLog('[Auto-Updater]: Error setting autoUpdater feed URL: ' + err.message);
554554
if (pgAdminMainScreen) {
555-
pgAdminMainScreen.webContents.send('appUpdateNotifier', {error: true, errMsg: 'Failed to check for updates. Please try again later.'});
555+
pgAdminMainScreen.webContents.send('notifyAppAutoUpdate', {error: true, errMsg: 'Failed to check for updates. Please try again later.'});
556556
}
557557
return;
558558
}

runtime/src/js/pgadmin_preload.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ contextBridge.exposeInMainWorld('electronUI', {
3333
downloadBase64UrlData: (...args) => ipcRenderer.invoke('download-base64-url-data', ...args),
3434
downloadTextData: (...args) => ipcRenderer.invoke('download-text-data', ...args),
3535
sendDataForAppUpdate: (data) => ipcRenderer.send('sendDataForAppUpdate', data),
36-
appUpdateNotifier: (callback) => {
37-
ipcRenderer.removeAllListeners('appUpdateNotifier'); // Clean up previous listeners
38-
ipcRenderer.on('appUpdateNotifier', (_, data) => callback(data));
36+
notifyAppAutoUpdate: (callback) => {
37+
ipcRenderer.removeAllListeners('notifyAppAutoUpdate'); // Clean up previous listeners
38+
ipcRenderer.on('notifyAppAutoUpdate', (_, data) => callback(data));
3939
},
4040
});

web/pgadmin/browser/static/js/browser.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import usePreferences, { setupPreferenceBroadcast } from '../../../preferences/s
1717
import checkNodeVisibility from '../../../static/js/check_node_visibility';
1818
import * as showQueryTool from '../../../tools/sqleditor/static/js/show_query_tool';
1919
import {getRandomInt} from 'sources/utils';
20-
import {appUpdateNotifier} from './UpdateCheckNotify';
20+
import {appAutoUpdateNotifier} from '../../../static/js/helpers/appAutoUpdateNotifier';
2121

2222
define('pgadmin.browser', [
2323
'sources/gettext', 'sources/url_for', 'sources/pgadmin',
@@ -301,7 +301,7 @@ define('pgadmin.browser', [
301301
'platform':data.platform,
302302
});
303303
}
304-
appUpdateNotifier(message, 'warning', downloadUpdate, null, 'Update available', 'download_update');
304+
appAutoUpdateNotifier(message, 'warning', downloadUpdate, null, 'Update available', 'download_update');
305305
} else if(data.outdated) {
306306
//This is for server mode or auto-update not supported desktop installer or not mentioned auto_update_url
307307
pgAdmin.Browser.notifier.warning(
@@ -316,7 +316,7 @@ define('pgadmin.browser', [
316316
// If the user manually triggered a check for updates (trigger_update_check is true)
317317
// and no update is available (data.outdated is false), show an info notification.
318318
if (!data.outdated && trigger_update_check){
319-
appUpdateNotifier('No update available.....', 'info', null, 10000);
319+
appAutoUpdateNotifier('No update available.....', 'info', null, 10000);
320320
}
321321
}).catch((error)=>{
322322
console.error('Error during version check', error);

web/pgadmin/static/js/BrowserComponent.jsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import pgWindow from 'sources/window';
3333
import WorkspaceToolbar from '../../misc/workspaces/static/js/WorkspaceToolbar';
3434
import { useWorkspace, WorkspaceProvider } from '../../misc/workspaces/static/js/WorkspaceProvider';
3535
import { PgAdminProvider, usePgAdmin } from './PgAdminProvider';
36-
import { appUpdateNotifier } from '../../browser/static/js/UpdateCheckNotify';
36+
import { appAutoUpdateNotifier } from './helpers/appAutoUpdateNotifier';
3737

3838
const objectExplorerGroup = {
3939
tabLocked: true,
@@ -179,22 +179,22 @@ export default function BrowserComponent({pgAdmin}) {
179179

180180
// Listen for auto-update events from the Electron main process and display notifications
181181
// to the user based on the update status (e.g., update available, downloading, downloaded, installed, or error).
182-
if (window.electronUI && typeof window.electronUI.appUpdateNotifier === 'function') {
183-
window.electronUI.appUpdateNotifier((data)=>{
182+
if (window.electronUI && typeof window.electronUI.notifyAppAutoUpdate === 'function') {
183+
window.electronUI.notifyAppAutoUpdate((data)=>{
184184
if (data?.check_version_update) {
185185
pgAdmin.Browser.check_version_update(true);
186186
} else if (data.update_downloading) {
187-
appUpdateNotifier('Update downloading...', 'info', null, 10000);
187+
appAutoUpdateNotifier('Update downloading...', 'info', null, 10000);
188188
} else if (data.no_update_available) {
189-
appUpdateNotifier('No update available.....', 'info', null, 10000);
189+
appAutoUpdateNotifier('No update available.....', 'info', null, 10000);
190190
} else if (data.update_downloaded) {
191191
const UPDATE_DOWNLOADED_MESSAGE = gettext('An update is ready. Restart the app now to install it, or later to keep using the current version.');
192-
appUpdateNotifier(UPDATE_DOWNLOADED_MESSAGE, 'warning', installUpdate, null, 'Update downloaded', 'update_downloaded');
192+
appAutoUpdateNotifier(UPDATE_DOWNLOADED_MESSAGE, 'warning', installUpdate, null, 'Update downloaded', 'update_downloaded');
193193
} else if (data.error) {
194-
appUpdateNotifier(`${data.errMsg}`, 'error');
194+
appAutoUpdateNotifier(`${data.errMsg}`, 'error');
195195
} else if (data.update_installed) {
196196
const UPDATE_INSTALLED_MESSAGE = gettext('Update installed successfully!');
197-
appUpdateNotifier(UPDATE_INSTALLED_MESSAGE, 'success');
197+
appAutoUpdateNotifier(UPDATE_INSTALLED_MESSAGE, 'success');
198198
}
199199
});
200200
}

web/pgadmin/browser/static/js/UpdateCheckNotify.jsx renamed to web/pgadmin/static/js/helpers/appAutoUpdateNotifier.jsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Box } from '@mui/material';
1212
import { styled } from '@mui/material/styles';
1313
import CloseIcon from '@mui/icons-material/CloseRounded';
1414
import PropTypes from 'prop-types';
15-
import { DefaultButton, PgIconButton } from '../../../static/js/components/Buttons';
15+
import { DefaultButton, PgIconButton } from '../components/Buttons';
1616
import pgAdmin from 'sources/pgadmin';
1717

1818
const StyledBox = styled(Box)(({theme}) => ({
@@ -21,23 +21,23 @@ const StyledBox = styled(Box)(({theme}) => ({
2121
minWidth: '325px',
2222
maxWidth: '400px',
2323
...theme.mixins.panelBorder.all,
24-
'&.UpdateCheckNotify-containerWarning': {
24+
'&.UpdateWarningNotifier-containerWarning': {
2525
borderColor: theme.palette.warning.main,
2626
backgroundColor: theme.palette.warning.light,
2727
},
28-
'& .UpdateCheckNotify-containerHeader': {
28+
'& .UpdateWarningNotifier-containerHeader': {
2929
height: '32px',
3030
display: 'flex',
3131
justifyContent: 'space-between',
3232
fontWeight: 'bold',
3333
alignItems: 'center',
3434
borderTopLeftRadius: 'inherit',
3535
borderTopRightRadius: 'inherit',
36-
'& .UpdateCheckNotify-iconWarning': {
36+
'& .UpdateWarningNotifier-iconWarning': {
3737
color: theme.palette.warning.main,
3838
},
3939
},
40-
'&.UpdateCheckNotify-containerBody': {
40+
'&.UpdateWarningNotifier-containerBody': {
4141
marginTop: '1rem',
4242
overflowWrap: 'break-word',
4343
},
@@ -53,12 +53,12 @@ function UpdateWarningNotifier({desc, title, onClose, onClick, status, uniqueKey
5353
}
5454
};
5555
return (
56-
<StyledBox className={'UpdateCheckNotify-containerWarning'} data-test={'Update-popup-warning'}>
57-
<Box display="flex" justifyContent="space-between" className='UpdateCheckNotify-containerHeader'>
56+
<StyledBox className={'UpdateWarningNotifier-containerWarning'} data-test={'Update-popup-warning'}>
57+
<Box display="flex" justifyContent="space-between" className='UpdateWarningNotifier-containerHeader'>
5858
<Box marginRight={'1rem'}>{title}</Box>
59-
<PgIconButton size="xs" noBorder icon={<CloseIcon />} onClick={handleClose} title={'Close'} className={'UpdateCheckNotify-iconWarning'} />
59+
<PgIconButton size="xs" noBorder icon={<CloseIcon />} onClick={handleClose} title={'Close'} className={'UpdateWarningNotifier-iconWarning'} />
6060
</Box>
61-
<Box className='UpdateCheckNotify-containerBody'>
61+
<Box className='UpdateWarningNotifier-containerBody'>
6262
{desc && <Box>{desc}</Box>}
6363
<Box display="flex">
6464
{onClick && <Box marginTop={'1rem'} display="flex">
@@ -86,7 +86,7 @@ UpdateWarningNotifier.propTypes = {
8686
uniqueKey: PropTypes.string,
8787
};
8888

89-
export function appUpdateNotifier(desc, type, onClick, hideDuration=null, title='', status='download_update') {
89+
export function appAutoUpdateNotifier(desc, type, onClick, hideDuration=null, title='', status='download_update') {
9090
const uniqueKey = `${title}::${desc}`;
9191

9292
// Check if this warning is already active except error type

0 commit comments

Comments
 (0)