@@ -16,6 +16,7 @@ import * as yaml from 'js-yaml';
1616import * as semver from 'semver' ;
1717import * as fs from 'fs' ;
1818import {
19+ bundledEnvironmentIsInstalled ,
1920 clearSession ,
2021 EnvironmentInstallStatus ,
2122 getBundledPythonEnvPath ,
@@ -392,6 +393,12 @@ export class JupyterApplication implements IApplication, IDisposable {
392393 installUpdatesAutomatically : settings . getValue (
393394 SettingType . installUpdatesAutomatically
394395 ) ,
396+ notifyOnBundledEnvUpdates : settings . getValue (
397+ SettingType . notifyOnBundledEnvUpdates
398+ ) ,
399+ updateBundledEnvAutomatically : settings . getValue (
400+ SettingType . updateBundledEnvAutomatically
401+ ) ,
395402 defaultWorkingDirectory : userSettings . getValue (
396403 SettingType . defaultWorkingDirectory
397404 ) ,
@@ -429,7 +436,9 @@ export class JupyterApplication implements IApplication, IDisposable {
429436 isDarkTheme : this . _isDarkTheme ,
430437 defaultPythonPath : userSettings . getValue ( SettingType . pythonPath ) ,
431438 app : this ,
432- activateTab
439+ activateTab,
440+ bundledEnvInstallationExists : bundledEnvironmentIsInstalled ( ) ,
441+ bundledEnvInstallationLatest : this . _registry . bundledEnvironmentIsLatest ( )
433442 } ) ;
434443
435444 this . _managePythonEnvDialog = dialog ;
@@ -529,7 +538,16 @@ export class JupyterApplication implements IApplication, IDisposable {
529538 } ;
530539
531540 dialog . showMessageBox ( dialogOpts ) . then ( returnValue => {
532- if ( returnValue . response === 0 ) autoUpdater . quitAndInstall ( ) ;
541+ if ( returnValue . response === 0 ) {
542+ if (
543+ userSettings . getValue ( SettingType . updateBundledEnvAutomatically ) &&
544+ bundledEnvironmentIsInstalled ( )
545+ ) {
546+ appData . updateBundledEnvOnRestart = true ;
547+ appData . save ( ) ;
548+ }
549+ autoUpdater . quitAndInstall ( ) ;
550+ }
533551 } ) ;
534552 } ) ;
535553
@@ -773,6 +791,27 @@ export class JupyterApplication implements IApplication, IDisposable {
773791 }
774792 ) ;
775793
794+ this . _evm . registerEventHandler (
795+ EventTypeMain . UpdateBundledPythonEnv ,
796+ async event => {
797+ const choice = dialog . showMessageBoxSync ( {
798+ type : 'warning' ,
799+ message : 'Update bundled environment' ,
800+ detail :
801+ 'App will restart and the existing environment installation will be deleted before the update. Would you like to continue?' ,
802+ buttons : [ 'Update' , 'Cancel' ] ,
803+ defaultId : 1 ,
804+ cancelId : 1
805+ } ) ;
806+
807+ if ( choice === 0 ) {
808+ appData . updateBundledEnvOnRestart = true ;
809+ app . relaunch ( ) ;
810+ app . quit ( ) ;
811+ }
812+ }
813+ ) ;
814+
776815 this . _evm . registerEventHandler (
777816 EventTypeMain . ShowManagePythonEnvironmentsDialog ,
778817 async ( event , activateTab ) => {
@@ -1091,6 +1130,15 @@ export class JupyterApplication implements IApplication, IDisposable {
10911130 }
10921131 ) ;
10931132
1133+ this . _evm . registerEventHandler (
1134+ EventTypeMain . SetSettings ,
1135+ ( _event , settings : { [ key : string ] : any } ) => {
1136+ for ( const key in settings ) {
1137+ userSettings . setValue ( key as SettingType , settings [ key ] ) ;
1138+ }
1139+ }
1140+ ) ;
1141+
10941142 this . _evm . registerSyncEventHandler (
10951143 EventTypeMain . GetServerInfo ,
10961144 ( event ) : IServerInfo => {
0 commit comments