@@ -90,6 +90,7 @@ document.adoptedStyleSheets = document.adoptedStyleSheets.concat(ContextMenuStyl
90
90
/** @typedef {import('@advanced-rest-client/arc-types').Authorization.OAuth2Authorization } OAuth2Authorization */
91
91
/** @typedef {import('@advanced-rest-client/electron-amf-service/types').ApiParseResult } ApiParseResult */
92
92
/** @typedef {import('@advanced-rest-client/exchange-search-panel/src/types').ExchangeAsset } ExchangeAsset */
93
+ /** @typedef {import('electron-updater').UpdateInfo } UpdateInfo */
93
94
94
95
const unhandledRejectionHandler = Symbol ( 'unhandledRejectionHandler' ) ;
95
96
const headerTemplate = Symbol ( 'headerTemplate' ) ;
@@ -154,6 +155,8 @@ const unreadMessagesTemplate = Symbol('unreadMessagesTemplate');
154
155
const appMessagesDialogTemplate = Symbol ( 'appMessagesDialogTemplate' ) ;
155
156
const openMessagesHandler = Symbol ( 'openMessagesHandler' ) ;
156
157
const arcLegacyProjectTemplate = Symbol ( 'arcLegacyProjectTemplate' ) ;
158
+ const updateIndicatorTemplate = Symbol ( 'updateIndicatorTemplate' ) ;
159
+ const updateClickHandler = Symbol ( 'updateClickHandler' ) ;
157
160
158
161
/**
159
162
* A routes that does not go through the router and should not be remembered in the history.
@@ -331,7 +334,7 @@ export class AdvancedRestClientApplication extends ApplicationPage {
331
334
this . initObservableProperties (
332
335
'route' , 'routeParams' , 'initializing' , 'loadingStatus' ,
333
336
'compatibility' , 'oauth2RedirectUri' ,
334
- 'navigationDetached' , 'updateState' , 'hasAppUpdate' ,
337
+ 'navigationDetached' , 'updateState' , 'hasAppUpdate' , 'manualUpdateAvailable' , 'updateVersion' ,
335
338
'popupMenuEnabled' , 'draggableEnabled' , 'historyEnabled' ,
336
339
'listType' , 'detailedSearch' , 'currentEnvironment' ,
337
340
'workspaceSendButton' , 'workspaceProgressInfo' , 'workspaceBodyEditor' , 'workspaceAutoEncode' ,
@@ -382,6 +385,10 @@ export class AdvancedRestClientApplication extends ApplicationPage {
382
385
* Whether application update is available.
383
386
*/
384
387
this . hasAppUpdate = false ;
388
+ /**
389
+ * Set whe an update is available but it has to be triggered manually.
390
+ */
391
+ this . manualUpdateAvailable = false ;
385
392
/**
386
393
* The current state of checking for update.
387
394
* @type {string }
@@ -620,9 +627,18 @@ export class AdvancedRestClientApplication extends ApplicationPage {
620
627
this . logger . info ( 'Checking for application update' ) ;
621
628
this . updateState = 'checking-for-update' ;
622
629
} ) ;
623
- ipc . on ( 'update-available' , ( ) => {
630
+ ipc . on ( 'update-available' ,
631
+ /**
632
+ * @param {Electron.IpcRendererEvent } e
633
+ * @param {UpdateInfo } info
634
+ */
635
+ ( e , info ) => {
636
+ this . updateVersion = info . version ;
624
637
this . logger . info ( 'Application update available.' ) ;
625
638
this . updateState = 'update-available' ;
639
+ if ( process . platform === 'linux' || this . config . updater && this . config . updater . auto === false ) {
640
+ this . manualUpdateAvailable = true ;
641
+ }
626
642
} ) ;
627
643
ipc . on ( 'update-not-available' , ( ) => {
628
644
this . logger . info ( 'Application update not available.' ) ;
@@ -1361,6 +1377,23 @@ export class AdvancedRestClientApplication extends ApplicationPage {
1361
1377
this . unreadAppMessages = 0 ;
1362
1378
}
1363
1379
1380
+ /**
1381
+ * A handler for the application update notification click.
1382
+ * It installs the update when manual installation is not requested.
1383
+ * If manual installation is requested then it opens the release page.
1384
+ */
1385
+ [ updateClickHandler ] ( ) {
1386
+ const { manualUpdateAvailable, hasAppUpdate } = this ;
1387
+ if ( manualUpdateAvailable ) {
1388
+ const { updateVersion } = this ;
1389
+ const base = 'https://github.com/advanced-rest-client/arc-electron/releases/tag' ;
1390
+ const url = `${ base } /v${ updateVersion } ` ;
1391
+ ipc . send ( 'open-external-url' , url ) ;
1392
+ } else if ( hasAppUpdate ) {
1393
+ ipc . send ( 'install-update' ) ;
1394
+ }
1395
+ }
1396
+
1364
1397
appTemplate ( ) {
1365
1398
const { initializing } = this ;
1366
1399
if ( initializing ) {
@@ -1406,11 +1439,26 @@ export class AdvancedRestClientApplication extends ApplicationPage {
1406
1439
</ anypoint-icon-button > ` }
1407
1440
API Client
1408
1441
< span class ="spacer "> </ span >
1442
+ ${ this [ updateIndicatorTemplate ] ( ) }
1409
1443
${ this [ unreadMessagesTemplate ] ( ) }
1410
1444
${ this [ environmentTemplate ] ( ) }
1411
1445
</ header > ` ;
1412
1446
}
1413
1447
1448
+ /**
1449
+ * @returns {TemplateResult|string } The template for the app update indicator
1450
+ */
1451
+ [ updateIndicatorTemplate ] ( ) {
1452
+ const { manualUpdateAvailable, hasAppUpdate } = this ;
1453
+ if ( ! manualUpdateAvailable && ! hasAppUpdate ) {
1454
+ return '' ;
1455
+ }
1456
+ return html `
1457
+ < anypoint-icon-button title ="Application update available " class ="header-action-button " @click ="${ this [ updateClickHandler ] } ">
1458
+ < arc-icon icon ="cloudDownload "> </ arc-icon >
1459
+ </ anypoint-icon-button > ` ;
1460
+ }
1461
+
1414
1462
/**
1415
1463
* @returns {TemplateResult|string } The template for the unread notifications icon button
1416
1464
*/
0 commit comments