5
5
6
6
import * as nls from 'vs/nls' ;
7
7
import severity from 'vs/base/common/severity' ;
8
- import { Action } from 'vs/base/common/actions' ;
9
8
import { Disposable , MutableDisposable } from 'vs/base/common/lifecycle' ;
10
9
import { URI } from 'vs/base/common/uri' ;
11
10
import { IActivityService , NumberBadge , IBadge , ProgressBadge } from 'vs/workbench/services/activity/common/activity' ;
@@ -36,73 +35,39 @@ export const RELEASE_NOTES_URL = new RawContextKey<string>('releaseNotesUrl', ''
36
35
37
36
let releaseNotesManager : ReleaseNotesManager | undefined = undefined ;
38
37
39
- export function showReleaseNotes ( instantiationService : IInstantiationService , version : string ) {
38
+ export function showReleaseNotesInEditor ( instantiationService : IInstantiationService , version : string ) {
40
39
if ( ! releaseNotesManager ) {
41
40
releaseNotesManager = instantiationService . createInstance ( ReleaseNotesManager ) ;
42
41
}
43
42
44
43
return releaseNotesManager . show ( version ) ;
45
44
}
46
45
47
- export class OpenLatestReleaseNotesInBrowserAction extends Action {
46
+ async function openLatestReleaseNotesInBrowser ( accessor : ServicesAccessor ) {
47
+ const openerService = accessor . get ( IOpenerService ) ;
48
+ const productService = accessor . get ( IProductService ) ;
48
49
49
- constructor (
50
- @IOpenerService private readonly openerService : IOpenerService ,
51
- @IProductService private readonly productService : IProductService
52
- ) {
53
- super ( 'update.openLatestReleaseNotes' , nls . localize ( 'releaseNotes' , "Release Notes" ) , undefined , true ) ;
54
- }
55
-
56
- override async run ( ) : Promise < void > {
57
- if ( this . productService . releaseNotesUrl ) {
58
- const uri = URI . parse ( this . productService . releaseNotesUrl ) ;
59
- await this . openerService . open ( uri ) ;
60
- } else {
61
- throw new Error ( nls . localize ( 'update.noReleaseNotesOnline' , "This version of {0} does not have release notes online" , this . productService . nameLong ) ) ;
62
- }
50
+ if ( productService . releaseNotesUrl ) {
51
+ const uri = URI . parse ( productService . releaseNotesUrl ) ;
52
+ await openerService . open ( uri ) ;
53
+ } else {
54
+ throw new Error ( nls . localize ( 'update.noReleaseNotesOnline' , "This version of {0} does not have release notes online" , productService . nameLong ) ) ;
63
55
}
64
56
}
65
57
66
- export abstract class AbstractShowReleaseNotesAction extends Action {
67
-
68
- constructor (
69
- id : string ,
70
- label : string ,
71
- private version : string ,
72
- @IInstantiationService private readonly instantiationService : IInstantiationService
73
- ) {
74
- super ( id , label , undefined , true ) ;
75
- }
76
-
77
- override async run ( ) : Promise < void > {
78
- if ( ! this . enabled ) {
79
- return ;
80
- }
81
- this . enabled = false ;
82
-
58
+ async function showReleaseNotes ( accessor : ServicesAccessor , version : string ) {
59
+ const instantiationService = accessor . get ( IInstantiationService ) ;
60
+ try {
61
+ await showReleaseNotesInEditor ( instantiationService , version ) ;
62
+ } catch ( err ) {
83
63
try {
84
- await showReleaseNotes ( this . instantiationService , this . version ) ;
85
- } catch ( err ) {
86
- const action = this . instantiationService . createInstance ( OpenLatestReleaseNotesInBrowserAction ) ;
87
- try {
88
- await action . run ( ) ;
89
- } catch ( err2 ) {
90
- throw new Error ( `${ err . message } and ${ err2 . message } ` ) ;
91
- }
64
+ await instantiationService . invokeFunction ( openLatestReleaseNotesInBrowser ) ;
65
+ } catch ( err2 ) {
66
+ throw new Error ( `${ err . message } and ${ err2 . message } ` ) ;
92
67
}
93
68
}
94
69
}
95
70
96
- export class ShowReleaseNotesAction extends AbstractShowReleaseNotesAction {
97
-
98
- constructor (
99
- version : string ,
100
- @IInstantiationService instantiationService : IInstantiationService
101
- ) {
102
- super ( 'update.showReleaseNotes' , nls . localize ( 'releaseNotes' , "Release Notes" ) , version , instantiationService ) ;
103
- }
104
- }
105
-
106
71
interface IVersion {
107
72
major : number ;
108
73
minor : number ;
@@ -159,7 +124,7 @@ export class ProductContribution implements IWorkbenchContribution {
159
124
160
125
// was there a major/minor update? if so, open release notes
161
126
if ( shouldShowReleaseNotes && ! environmentService . skipReleaseNotes && releaseNotesUrl && lastVersion && currentVersion && isMajorMinorUpdate ( lastVersion , currentVersion ) ) {
162
- showReleaseNotes ( instantiationService , productService . version )
127
+ showReleaseNotesInEditor ( instantiationService , productService . version )
163
128
. then ( undefined , ( ) => {
164
129
notificationService . prompt (
165
130
severity . Info ,
@@ -317,9 +282,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
317
282
} , {
318
283
label : nls . localize ( 'releaseNotes' , "Release Notes" ) ,
319
284
run : ( ) => {
320
- const action = this . instantiationService . createInstance ( ShowReleaseNotesAction , update . productVersion ) ;
321
- action . run ( ) ;
322
- action . dispose ( ) ;
285
+ this . instantiationService . invokeFunction ( accessor => showReleaseNotes ( accessor , update . productVersion ) ) ;
323
286
}
324
287
} ]
325
288
) ;
@@ -343,9 +306,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
343
306
} , {
344
307
label : nls . localize ( 'releaseNotes' , "Release Notes" ) ,
345
308
run : ( ) => {
346
- const action = this . instantiationService . createInstance ( ShowReleaseNotesAction , update . productVersion ) ;
347
- action . run ( ) ;
348
- action . dispose ( ) ;
309
+ this . instantiationService . invokeFunction ( accessor => showReleaseNotes ( accessor , update . productVersion ) ) ;
349
310
}
350
311
} ]
351
312
) ;
@@ -370,9 +331,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
370
331
actions . push ( {
371
332
label : nls . localize ( 'releaseNotes' , "Release Notes" ) ,
372
333
run : ( ) => {
373
- const action = this . instantiationService . createInstance ( ShowReleaseNotesAction , update . productVersion ) ;
374
- action . run ( ) ;
375
- action . dispose ( ) ;
334
+ this . instantiationService . invokeFunction ( accessor => showReleaseNotes ( accessor , update . productVersion ) ) ;
376
335
}
377
336
} ) ;
378
337
}
0 commit comments