@@ -45,7 +45,7 @@ import { IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
45
45
import { ITreeRenderer , ITreeNode , IAsyncDataSource } from 'vs/base/browser/ui/tree/tree' ;
46
46
import { WorkbenchAsyncDataTree } from 'vs/platform/list/browser/listService' ;
47
47
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
48
- import { Event } from 'vs/base/common/event' ;
48
+ import { Event , Emitter } from 'vs/base/common/event' ;
49
49
import { ExtensionsRegistry , IExtensionPointUser } from 'vs/workbench/services/extensions/common/extensionsRegistry' ;
50
50
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors' ;
51
51
import * as icons from 'vs/workbench/contrib/remote/browser/remoteIcons' ;
@@ -115,6 +115,7 @@ const remoteHelpExtPoint = ExtensionsRegistry.registerExtensionPoint<HelpInforma
115
115
} ) ;
116
116
117
117
interface IViewModel {
118
+ onDidChangeHelpInformation : Event < void > ;
118
119
helpInformation : HelpInformation [ ] ;
119
120
}
120
121
@@ -173,105 +174,106 @@ interface IHelpItem {
173
174
icon : ThemeIcon ;
174
175
iconClasses : string [ ] ;
175
176
label : string ;
177
+ values : HelpItemValue [ ] ;
176
178
handleClick ( ) : Promise < void > ;
177
179
}
178
180
179
181
class HelpModel {
180
182
items : IHelpItem [ ] | undefined ;
181
183
182
184
constructor (
183
- viewModel : IViewModel ,
184
- openerService : IOpenerService ,
185
- quickInputService : IQuickInputService ,
186
- commandService : ICommandService ,
187
- remoteExplorerService : IRemoteExplorerService ,
188
- environmentService : IWorkbenchEnvironmentService ,
189
- workspaceContextService : IWorkspaceContextService ,
190
- walkthroughsService : IWalkthroughsService
185
+ private viewModel : IViewModel ,
186
+ private openerService : IOpenerService ,
187
+ private quickInputService : IQuickInputService ,
188
+ private commandService : ICommandService ,
189
+ private remoteExplorerService : IRemoteExplorerService ,
190
+ private environmentService : IWorkbenchEnvironmentService ,
191
+ private workspaceContextService : IWorkspaceContextService ,
192
+ private walkthroughsService : IWalkthroughsService
191
193
) {
194
+ this . updateItems ( ) ;
195
+ viewModel . onDidChangeHelpInformation ( ( ) => this . updateItems ( ) ) ;
196
+ }
197
+
198
+ private createHelpItemValue ( info : HelpInformation , infoKey : Exclude < keyof HelpInformation , 'extensionDescription' | 'remoteName' | 'virtualWorkspace' > ) {
199
+ return new HelpItemValue ( this . commandService ,
200
+ this . walkthroughsService ,
201
+ info . extensionDescription ,
202
+ ( typeof info . remoteName === 'string' ) ? [ info . remoteName ] : info . remoteName ,
203
+ info . virtualWorkspace ,
204
+ info [ infoKey ] ) ;
205
+ }
206
+
207
+ private updateItems ( ) {
192
208
const helpItems : IHelpItem [ ] = [ ] ;
193
- const getStarted = viewModel . helpInformation . filter ( info => info . getStarted ) ;
194
209
210
+ const getStarted = this . viewModel . helpInformation . filter ( info => info . getStarted ) ;
195
211
if ( getStarted . length ) {
196
- helpItems . push ( new GetStartedHelpItem (
212
+ const helpItemValues = getStarted . map ( ( info : HelpInformation ) => this . createHelpItemValue ( info , 'getStarted' ) ) ;
213
+ const getStartedHelpItem = this . items ?. find ( item => item . icon === icons . getStartedIcon ) ?? new GetStartedHelpItem (
197
214
icons . getStartedIcon ,
198
215
nls . localize ( 'remote.help.getStarted' , "Get Started" ) ,
199
- getStarted . map ( ( info : HelpInformation ) => ( new HelpItemValue ( commandService ,
200
- walkthroughsService ,
201
- info . extensionDescription ,
202
- ( typeof info . remoteName === 'string' ) ? [ info . remoteName ] : info . remoteName ,
203
- info . virtualWorkspace ,
204
- info . getStarted )
205
- ) ) ,
206
- quickInputService ,
207
- environmentService ,
208
- openerService ,
209
- remoteExplorerService ,
210
- workspaceContextService ,
211
- commandService
212
- ) ) ;
216
+ helpItemValues ,
217
+ this . quickInputService ,
218
+ this . environmentService ,
219
+ this . openerService ,
220
+ this . remoteExplorerService ,
221
+ this . workspaceContextService ,
222
+ this . commandService
223
+ ) ;
224
+ getStartedHelpItem . values = helpItemValues ;
225
+ helpItems . push ( getStartedHelpItem ) ;
213
226
}
214
227
215
- const documentation = viewModel . helpInformation . filter ( info => info . documentation ) ;
216
-
228
+ const documentation = this . viewModel . helpInformation . filter ( info => info . documentation ) ;
217
229
if ( documentation . length ) {
218
- helpItems . push ( new HelpItem (
230
+ const helpItemValues = documentation . map ( ( info : HelpInformation ) => this . createHelpItemValue ( info , 'documentation' ) ) ;
231
+ const documentationHelpItem = this . items ?. find ( item => item . icon === icons . documentationIcon ) ?? new HelpItem (
219
232
icons . documentationIcon ,
220
233
nls . localize ( 'remote.help.documentation' , "Read Documentation" ) ,
221
- documentation . map ( ( info : HelpInformation ) => ( new HelpItemValue ( commandService ,
222
- walkthroughsService ,
223
- info . extensionDescription ,
224
- ( typeof info . remoteName === 'string' ) ? [ info . remoteName ] : info . remoteName ,
225
- info . virtualWorkspace ,
226
- info . documentation ! )
227
- ) ) ,
228
- quickInputService ,
229
- environmentService ,
230
- openerService ,
231
- remoteExplorerService ,
232
- workspaceContextService
233
- ) ) ;
234
+ helpItemValues ,
235
+ this . quickInputService ,
236
+ this . environmentService ,
237
+ this . openerService ,
238
+ this . remoteExplorerService ,
239
+ this . workspaceContextService
240
+ ) ;
241
+ documentationHelpItem . values = helpItemValues ;
242
+ helpItems . push ( documentationHelpItem ) ;
234
243
}
235
244
236
- const issues = viewModel . helpInformation . filter ( info => info . issues ) ;
237
-
245
+ const issues = this . viewModel . helpInformation . filter ( info => info . issues ) ;
238
246
if ( issues . length ) {
239
- helpItems . push ( new HelpItem (
247
+ const helpItemValues = issues . map ( ( info : HelpInformation ) => this . createHelpItemValue ( info , 'issues' ) ) ;
248
+ const reviewIssuesHelpItem = this . items ?. find ( item => item . icon === icons . reviewIssuesIcon ) ?? new HelpItem (
240
249
icons . reviewIssuesIcon ,
241
250
nls . localize ( 'remote.help.issues' , "Review Issues" ) ,
242
- issues . map ( ( info : HelpInformation ) => ( new HelpItemValue ( commandService ,
243
- walkthroughsService ,
244
- info . extensionDescription ,
245
- ( typeof info . remoteName === 'string' ) ? [ info . remoteName ] : info . remoteName ,
246
- info . virtualWorkspace ,
247
- info . issues ! )
248
- ) ) ,
249
- quickInputService ,
250
- environmentService ,
251
- openerService ,
252
- remoteExplorerService ,
253
- workspaceContextService
254
- ) ) ;
251
+ helpItemValues ,
252
+ this . quickInputService ,
253
+ this . environmentService ,
254
+ this . openerService ,
255
+ this . remoteExplorerService ,
256
+ this . workspaceContextService
257
+ ) ;
258
+ reviewIssuesHelpItem . values = helpItemValues ;
259
+ helpItems . push ( reviewIssuesHelpItem ) ;
255
260
}
256
261
257
262
if ( helpItems . length ) {
258
- helpItems . push ( new IssueReporterItem (
263
+ const helpItemValues = this . viewModel . helpInformation . map ( info => this . createHelpItemValue ( info , 'reportIssue' ) ) ;
264
+ const issueReporterItem = this . items ?. find ( item => item . icon === icons . reportIssuesIcon ) ?? new IssueReporterItem (
259
265
icons . reportIssuesIcon ,
260
266
nls . localize ( 'remote.help.report' , "Report Issue" ) ,
261
- viewModel . helpInformation . map ( info => ( new HelpItemValue ( commandService ,
262
- walkthroughsService ,
263
- info . extensionDescription ,
264
- ( typeof info . remoteName === 'string' ) ? [ info . remoteName ] : info . remoteName ,
265
- info . virtualWorkspace ,
266
- info . reportIssue
267
- ) ) ) ,
268
- quickInputService ,
269
- environmentService ,
270
- commandService ,
271
- openerService ,
272
- remoteExplorerService ,
273
- workspaceContextService
274
- ) ) ;
267
+ helpItemValues ,
268
+ this . quickInputService ,
269
+ this . environmentService ,
270
+ this . commandService ,
271
+ this . openerService ,
272
+ this . remoteExplorerService ,
273
+ this . workspaceContextService
274
+ ) ;
275
+ issueReporterItem . values = helpItemValues ;
276
+ helpItems . push ( issueReporterItem ) ;
275
277
}
276
278
277
279
if ( helpItems . length ) {
@@ -579,6 +581,8 @@ class HelpPanelDescriptor implements IViewDescriptor {
579
581
class RemoteViewPaneContainer extends FilterViewPaneContainer implements IViewModel {
580
582
private helpPanelDescriptor = new HelpPanelDescriptor ( this ) ;
581
583
helpInformation : HelpInformation [ ] = [ ] ;
584
+ private _onDidChangeHelpInformation = new Emitter < void > ( ) ;
585
+ public onDidChangeHelpInformation : Event < void > = this . _onDidChangeHelpInformation . event ;
582
586
private hasSetSwitchForConnection : boolean = false ;
583
587
584
588
constructor (
@@ -604,6 +608,7 @@ class RemoteViewPaneContainer extends FilterViewPaneContainer implements IViewMo
604
608
}
605
609
606
610
this . helpInformation = helpInformation ;
611
+ this . _onDidChangeHelpInformation . fire ( ) ;
607
612
608
613
const viewsRegistry = Registry . as < IViewsRegistry > ( Extensions . ViewsRegistry ) ;
609
614
if ( this . helpInformation . length ) {
0 commit comments