55
66import * as nls from 'vs/nls' ;
77import severity from 'vs/base/common/severity' ;
8- import { Action } from 'vs/base/common/actions' ;
98import { Disposable , MutableDisposable } from 'vs/base/common/lifecycle' ;
109import { URI } from 'vs/base/common/uri' ;
1110import { IActivityService , NumberBadge , IBadge , ProgressBadge } from 'vs/workbench/services/activity/common/activity' ;
@@ -36,73 +35,39 @@ export const RELEASE_NOTES_URL = new RawContextKey<string>('releaseNotesUrl', ''
3635
3736let releaseNotesManager : ReleaseNotesManager | undefined = undefined ;
3837
39- export function showReleaseNotes ( instantiationService : IInstantiationService , version : string ) {
38+ export function showReleaseNotesInEditor ( instantiationService : IInstantiationService , version : string ) {
4039 if ( ! releaseNotesManager ) {
4140 releaseNotesManager = instantiationService . createInstance ( ReleaseNotesManager ) ;
4241 }
4342
4443 return releaseNotesManager . show ( version ) ;
4544}
4645
47- export class OpenLatestReleaseNotesInBrowserAction extends Action {
46+ async function openLatestReleaseNotesInBrowser ( accessor : ServicesAccessor ) {
47+ const openerService = accessor . get ( IOpenerService ) ;
48+ const productService = accessor . get ( IProductService ) ;
4849
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 ) ) ;
6355 }
6456}
6557
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 ) {
8363 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 } ` ) ;
9267 }
9368 }
9469}
9570
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-
10671interface IVersion {
10772 major : number ;
10873 minor : number ;
@@ -159,7 +124,7 @@ export class ProductContribution implements IWorkbenchContribution {
159124
160125 // was there a major/minor update? if so, open release notes
161126 if ( shouldShowReleaseNotes && ! environmentService . skipReleaseNotes && releaseNotesUrl && lastVersion && currentVersion && isMajorMinorUpdate ( lastVersion , currentVersion ) ) {
162- showReleaseNotes ( instantiationService , productService . version )
127+ showReleaseNotesInEditor ( instantiationService , productService . version )
163128 . then ( undefined , ( ) => {
164129 notificationService . prompt (
165130 severity . Info ,
@@ -317,9 +282,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
317282 } , {
318283 label : nls . localize ( 'releaseNotes' , "Release Notes" ) ,
319284 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 ) ) ;
323286 }
324287 } ]
325288 ) ;
@@ -343,9 +306,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
343306 } , {
344307 label : nls . localize ( 'releaseNotes' , "Release Notes" ) ,
345308 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 ) ) ;
349310 }
350311 } ]
351312 ) ;
@@ -370,9 +331,7 @@ export class UpdateContribution extends Disposable implements IWorkbenchContribu
370331 actions . push ( {
371332 label : nls . localize ( 'releaseNotes' , "Release Notes" ) ,
372333 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 ) ) ;
376335 }
377336 } ) ;
378337 }
0 commit comments