Skip to content

Commit 92e5541

Browse files
author
minjk-bl
committed
Add alert modal to update version (daily check)
1 parent ea9bbf9 commit 92e5541

File tree

2 files changed

+36
-73
lines changed

2 files changed

+36
-73
lines changed

js/com/com_Config.js

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -376,9 +376,10 @@ define([
376376
this.getPackageVersion().then(function(latestVersion) {
377377
if (nowVersion === latestVersion) {
378378
// if it's already up to date
379+
// hide version update icon
380+
$('#vp_versionUpdater').hide();
379381
if (background) {
380-
// hide version update icon
381-
$('#vp_versionUpdater').hide();
382+
;
382383
} else {
383384
let msg = com_util.formatString('Visual Python is up to date. ({0})', latestVersion);
384385
com_util.renderInfoModal(msg);
@@ -389,45 +390,42 @@ define([
389390
let msg = com_util.formatString('Visual Python updates are available.<br/>(Latest version: {0} / Your version: {1})',
390391
latestVersion, nowVersion);
391392
// show version update icon
392-
$('#vp_versionUpdater').attr('title', msg);
393+
$('#vp_versionUpdater').attr('title', msg.replace('<br/>', ''));
393394
$('#vp_versionUpdater').data('version', latestVersion);
394395
$('#vp_versionUpdater').show();
395-
if (background) {
396-
;
397-
} else {
398-
// render update modal (same as menu/MenuFrame.js:_bindEvent()-Click version updater)
399-
com_util.renderModal({
400-
title: 'Update version',
401-
message: msg,
402-
buttons: ['Cancel', 'Update'],
403-
defaultButtonIdx: 0,
404-
buttonClass: ['cancel', 'activated'],
405-
finish: function(clickedBtnIdx) {
406-
switch (clickedBtnIdx) {
407-
case 0:
408-
// cancel
409-
break;
410-
case 1:
411-
// update
412-
let info = [
413-
'## Visual Python Upgrade',
414-
'NOTE: ',
415-
'- Refresh your web browser to start a new version.',
416-
'- Save VP Note before refreshing the page.'
417-
];
418-
com_interface.insertCell('markdown', info.join('\n'));
419-
com_interface.insertCell('code', '!pip install visualpython --upgrade');
420-
com_interface.insertCell('code', '!visualpy install');
396+
397+
// render update modal
398+
com_util.renderModal({
399+
title: 'Update version',
400+
message: msg,
401+
buttons: ['Cancel', 'Update'],
402+
defaultButtonIdx: 0,
403+
buttonClass: ['cancel', 'activated'],
404+
finish: function(clickedBtnIdx) {
405+
switch (clickedBtnIdx) {
406+
case 0:
407+
// cancel
408+
break;
409+
case 1:
410+
// update
411+
let info = [
412+
'## Visual Python Upgrade',
413+
'NOTE: ',
414+
'- Refresh your web browser to start a new version.',
415+
'- Save VP Note before refreshing the page.'
416+
];
417+
com_interface.insertCell('markdown', info.join('\n'));
418+
com_interface.insertCell('code', '!pip install visualpython --upgrade');
419+
com_interface.insertCell('code', '!visualpy install');
421420

422-
// update version_timestamp
423-
that.setData({ 'version_timestamp': new Date().getTime() }, 'vpcfg');
424-
// hide updater
425-
$('#vp_versionUpdater').hide();
426-
break;
427-
}
421+
// update version_timestamp
422+
that.setData({ 'version_timestamp': new Date().getTime() }, 'vpcfg');
423+
// hide updater
424+
$('#vp_versionUpdater').hide();
425+
break;
428426
}
429-
})
430-
}
427+
}
428+
});
431429
}
432430
}).catch(function(err) {
433431
if (background) {

js/menu/MenuFrame.js

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -101,42 +101,7 @@ define([
101101
});
102102
// Click version updater
103103
$(this.wrapSelector('#vp_versionUpdater')).on('click', function() {
104-
let latestVersion = $(this).data('version');
105-
let nowVersion = vpConfig.getVpInstalledVersion();
106-
let msg = com_util.formatString('Visualpython updates are available.<br/>(Latest version: {0} / Your version: {1})',
107-
latestVersion, nowVersion);
108-
// render update modal (same as com/com_Config.js:checkVpVersion())
109-
com_util.renderModal({
110-
title: 'Update version',
111-
message: msg,
112-
buttons: ['Cancel', 'Update'],
113-
defaultButtonIdx: 0,
114-
buttonClass: ['cancel', 'activated'],
115-
finish: function(clickedBtnIdx) {
116-
switch (clickedBtnIdx) {
117-
case 0:
118-
// cancel
119-
break;
120-
case 1:
121-
// update
122-
let info = [
123-
'## Visual Python Upgrade',
124-
'NOTE: ',
125-
'- Refresh your web browser to start a new version.',
126-
'- Save VP Note before refreshing the page.'
127-
];
128-
com_interface.insertCell('markdown', info.join('\n'));
129-
com_interface.insertCell('code', '!pip install visualpython --upgrade');
130-
com_interface.insertCell('code', '!visualpy install');
131-
132-
// update version_timestamp
133-
vpConfig.setData({ 'version_timestamp': new Date().getTime() }, 'vpcfg');
134-
// hide updater
135-
$(that.wrapSelector('#vp_versionUpdater')).hide();
136-
break;
137-
}
138-
}
139-
});
104+
vpConfig.checkVpVersion();
140105
});
141106
}
142107

0 commit comments

Comments
 (0)