@@ -5,6 +5,7 @@ import { html } from '../../../../web_modules/lit-html/lit-html.js';
5
5
import { MonacoLoader } from '../../../../web_modules/@advanced-rest-client/monaco-support/index.js' ;
6
6
import { ArcNavigationEventTypes , ProjectActions , ConfigEventTypes , DataImportEventTypes , WorkspaceEvents , ImportEvents , WorkspaceEventTypes , ArcNavigationEvents , RestApiEventTypes } from '../../../../web_modules/@advanced-rest-client/arc-events/index.js' ;
7
7
import { ArcModelEvents , ArcModelEventTypes , ImportFactory , ImportNormalize , isSingleRequest } from '../../../../web_modules/@advanced-rest-client/arc-models/index.js' ;
8
+ import { ArcMessagingService } from '../../../../web_modules/@advanced-rest-client/arc-messages/index.js' ;
8
9
import { ModulesRegistry , RequestCookies } from '../../../../web_modules/@advanced-rest-client/request-engine/index.js' ;
9
10
import { classMap } from '../../../../web_modules/lit-html/directives/class-map.js' ;
10
11
import { styleMap } from '../../../../web_modules/lit-html/directives/style-map.js' ;
@@ -43,6 +44,7 @@ import '../../../../web_modules/@api-components/api-navigation/api-navigation.js
43
44
import '../../../../web_modules/@advanced-rest-client/exchange-search-panel/exchange-search-panel.js' ;
44
45
// import '../../../../web_modules/@api-components/api-request-panel/api-request-panel.js';
45
46
// import '../../../../web_modules/@api-components/api-documentation/api-documentation.js';
47
+ import '../../../../web_modules/@advanced-rest-client/arc-messages/arc-messages-dialog.js' ;
46
48
import { Request } from './Request.js' ;
47
49
import { ContextMenu } from '../context-menu/ContextMenu.js' ;
48
50
import { ContextMenuStyles } from '../context-menu/ContextMenu.styles.js' ;
@@ -145,6 +147,9 @@ const arcNavigationTemplate = Symbol('arcNavigationTemplate');
145
147
const exchangeSearchTemplate = Symbol ( 'exchangeSearchTemplate' ) ;
146
148
const exchangeSelectionHandler = Symbol ( 'exchangeSelectionHandler' ) ;
147
149
const themeActivateHandler = Symbol ( 'themeActivateHandler' ) ;
150
+ const unreadMessagesTemplate = Symbol ( 'unreadMessagesTemplate' ) ;
151
+ const appMessagesDialogTemplate = Symbol ( 'appMessagesDialogTemplate' ) ;
152
+ const openMessagesHandler = Symbol ( 'openMessagesHandler' ) ;
148
153
149
154
/**
150
155
* A routes that does not go through the router and should not be remembered in the history.
@@ -268,6 +273,11 @@ export class AdvancedRestClientApplication extends ApplicationPage {
268
273
269
274
ga = new GoogleAnalytics ( ) ;
270
275
276
+ /**
277
+ * A service that requests fro the data from the ARC server fore new messages.
278
+ */
279
+ appMessages = new ArcMessagingService ( 'electron' ) ;
280
+
271
281
/**
272
282
* @returns {ArcRequestWorkspaceElement }
273
283
*/
@@ -323,6 +333,7 @@ export class AdvancedRestClientApplication extends ApplicationPage {
323
333
'workspaceSendButton' , 'workspaceProgressInfo' , 'workspaceBodyEditor' , 'workspaceAutoEncode' ,
324
334
'navigationWidth' ,
325
335
'requestDetailsOpened' , 'requestMetaOpened' , 'metaRequestId' , 'metaRequestType' ,
336
+ 'unreadAppMessages' , 'applicationMessages' ,
326
337
) ;
327
338
328
339
/**
@@ -421,6 +432,11 @@ export class AdvancedRestClientApplication extends ApplicationPage {
421
432
this . requestMetaOpened = false ;
422
433
this . metaRequestId = undefined ;
423
434
this . metaRequestType = undefined ;
435
+
436
+ /**
437
+ * @type {number } The number of unread messages in the application.
438
+ */
439
+ this . unreadAppMessages = 0 ;
424
440
}
425
441
426
442
async initialize ( ) {
@@ -455,6 +471,7 @@ export class AdvancedRestClientApplication extends ApplicationPage {
455
471
await this . afterInitialization ( ) ;
456
472
await this . loadMonaco ( ) ;
457
473
this . initializing = false ;
474
+ this . unreadAppMessages = await this . appMessages . run ( ) ;
458
475
}
459
476
460
477
/**
@@ -518,6 +535,7 @@ export class AdvancedRestClientApplication extends ApplicationPage {
518
535
this . listType = cnf . view . listType ;
519
536
}
520
537
}
538
+
521
539
if ( cnf . requestEditor ) {
522
540
if ( typeof cnf . requestEditor . sendButton === 'boolean' ) {
523
541
this . workspaceSendButton = cnf . requestEditor . sendButton ;
@@ -532,6 +550,13 @@ export class AdvancedRestClientApplication extends ApplicationPage {
532
550
this . workspaceAutoEncode = cnf . requestEditor . autoEncode ;
533
551
}
534
552
}
553
+
554
+ if ( cnf . updater ) {
555
+ const { channel } = cnf . updater ;
556
+ if ( typeof channel === 'string' ) {
557
+ this . appMessages . channel = channel ;
558
+ }
559
+ }
535
560
}
536
561
537
562
/**
@@ -841,6 +866,7 @@ export class AdvancedRestClientApplication extends ApplicationPage {
841
866
case 'export-workspace' : this . exportWorkspace ( ) ; break ;
842
867
case 'login-external-webservice' : this . workspaceElement . openWebUrlInput ( ) ; break ;
843
868
case 'open-workspace-details' : this . workspaceElement . openWorkspaceDetails ( ) ; break ;
869
+ case 'open-messages' : this . openAppMessages ( ) ; break ;
844
870
default :
845
871
this . logger . warn ( `Unhandled IO command ${ action } ` ) ;
846
872
}
@@ -1306,6 +1332,20 @@ export class AdvancedRestClientApplication extends ApplicationPage {
1306
1332
this . compatibility = e . detail === ThemeManager . anypointTheme ;
1307
1333
}
1308
1334
1335
+ [ openMessagesHandler ] ( ) {
1336
+ this . openAppMessages ( ) ;
1337
+ }
1338
+
1339
+ async openAppMessages ( ) {
1340
+ if ( ! this . applicationMessages ) {
1341
+ this . applicationMessages = await this . appMessages . readMessages ( ) ;
1342
+ }
1343
+ const dialog = document . querySelector ( 'arc-messages-dialog' ) ;
1344
+ dialog . opened = true ;
1345
+ await this . appMessages . markAllRead ( ) ;
1346
+ this . unreadAppMessages = 0 ;
1347
+ }
1348
+
1309
1349
appTemplate ( ) {
1310
1350
const { initializing } = this ;
1311
1351
if ( initializing ) {
@@ -1320,6 +1360,7 @@ export class AdvancedRestClientApplication extends ApplicationPage {
1320
1360
${ this [ navigationTemplate ] ( ) }
1321
1361
${ this [ pageTemplate ] ( this . route ) }
1322
1362
</ div >
1363
+ ${ this [ appMessagesDialogTemplate ] ( ) }
1323
1364
` ;
1324
1365
}
1325
1366
@@ -1345,15 +1386,30 @@ export class AdvancedRestClientApplication extends ApplicationPage {
1345
1386
< header >
1346
1387
${ isWorkspace ? '' :
1347
1388
html `
1348
- < anypoint-icon-button title ="Back to the request workspace " @click ="${ this [ mainBackHandler ] } ">
1389
+ < anypoint-icon-button title ="Back to the request workspace " @click ="${ this [ mainBackHandler ] } " class =" header-action-button " >
1349
1390
< arc-icon icon ="arrowBack "> </ arc-icon >
1350
1391
</ anypoint-icon-button > ` }
1351
1392
API Client
1352
1393
< span class ="spacer "> </ span >
1394
+ ${ this [ unreadMessagesTemplate ] ( ) }
1353
1395
${ this [ environmentTemplate ] ( ) }
1354
1396
</ header > ` ;
1355
1397
}
1356
1398
1399
+ /**
1400
+ * @returns {TemplateResult|string } The template for the unread notifications icon button
1401
+ */
1402
+ [ unreadMessagesTemplate ] ( ) {
1403
+ const { unreadAppMessages } = this ;
1404
+ if ( ! unreadAppMessages ) {
1405
+ return '' ;
1406
+ }
1407
+ return html `
1408
+ < anypoint-icon-button title ="You have unread messages " class ="header-action-button " @click ="${ this [ openMessagesHandler ] } ">
1409
+ < arc-icon icon ="notificationsActive "> </ arc-icon >
1410
+ </ anypoint-icon-button > ` ;
1411
+ }
1412
+
1357
1413
/**
1358
1414
* @returns {TemplateResult|string } The template for the environment selector and the overlay.
1359
1415
*/
@@ -1726,4 +1782,16 @@ export class AdvancedRestClientApplication extends ApplicationPage {
1726
1782
> </ exchange-search-panel >
1727
1783
` ;
1728
1784
}
1785
+
1786
+ /**
1787
+ * @returns {TemplateResult } The template for the dialog with application messages
1788
+ */
1789
+ [ appMessagesDialogTemplate ] ( ) {
1790
+ return html `
1791
+ < arc-messages-dialog
1792
+ .messages ="${ this . applicationMessages } "
1793
+ ?compatibility ="${ this . compatibility } "
1794
+ modal
1795
+ > </ arc-messages-dialog > ` ;
1796
+ }
1729
1797
}
0 commit comments