Skip to content

Commit 80f0cbc

Browse files
authored
Update remote help if installed extensions change (microsoft#182233)
1 parent a37ecd5 commit 80f0cbc

File tree

1 file changed

+77
-72
lines changed
  • src/vs/workbench/contrib/remote/browser

1 file changed

+77
-72
lines changed

src/vs/workbench/contrib/remote/browser/remote.ts

Lines changed: 77 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import { IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
4545
import { ITreeRenderer, ITreeNode, IAsyncDataSource } from 'vs/base/browser/ui/tree/tree';
4646
import { WorkbenchAsyncDataTree } from 'vs/platform/list/browser/listService';
4747
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';
4949
import { ExtensionsRegistry, IExtensionPointUser } from 'vs/workbench/services/extensions/common/extensionsRegistry';
5050
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
5151
import * as icons from 'vs/workbench/contrib/remote/browser/remoteIcons';
@@ -115,6 +115,7 @@ const remoteHelpExtPoint = ExtensionsRegistry.registerExtensionPoint<HelpInforma
115115
});
116116

117117
interface IViewModel {
118+
onDidChangeHelpInformation: Event<void>;
118119
helpInformation: HelpInformation[];
119120
}
120121

@@ -173,105 +174,106 @@ interface IHelpItem {
173174
icon: ThemeIcon;
174175
iconClasses: string[];
175176
label: string;
177+
values: HelpItemValue[];
176178
handleClick(): Promise<void>;
177179
}
178180

179181
class HelpModel {
180182
items: IHelpItem[] | undefined;
181183

182184
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
191193
) {
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() {
192208
const helpItems: IHelpItem[] = [];
193-
const getStarted = viewModel.helpInformation.filter(info => info.getStarted);
194209

210+
const getStarted = this.viewModel.helpInformation.filter(info => info.getStarted);
195211
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(
197214
icons.getStartedIcon,
198215
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);
213226
}
214227

215-
const documentation = viewModel.helpInformation.filter(info => info.documentation);
216-
228+
const documentation = this.viewModel.helpInformation.filter(info => info.documentation);
217229
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(
219232
icons.documentationIcon,
220233
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);
234243
}
235244

236-
const issues = viewModel.helpInformation.filter(info => info.issues);
237-
245+
const issues = this.viewModel.helpInformation.filter(info => info.issues);
238246
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(
240249
icons.reviewIssuesIcon,
241250
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);
255260
}
256261

257262
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(
259265
icons.reportIssuesIcon,
260266
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);
275277
}
276278

277279
if (helpItems.length) {
@@ -579,6 +581,8 @@ class HelpPanelDescriptor implements IViewDescriptor {
579581
class RemoteViewPaneContainer extends FilterViewPaneContainer implements IViewModel {
580582
private helpPanelDescriptor = new HelpPanelDescriptor(this);
581583
helpInformation: HelpInformation[] = [];
584+
private _onDidChangeHelpInformation = new Emitter<void>();
585+
public onDidChangeHelpInformation: Event<void> = this._onDidChangeHelpInformation.event;
582586
private hasSetSwitchForConnection: boolean = false;
583587

584588
constructor(
@@ -604,6 +608,7 @@ class RemoteViewPaneContainer extends FilterViewPaneContainer implements IViewMo
604608
}
605609

606610
this.helpInformation = helpInformation;
611+
this._onDidChangeHelpInformation.fire();
607612

608613
const viewsRegistry = Registry.as<IViewsRegistry>(Extensions.ViewsRegistry);
609614
if (this.helpInformation.length) {

0 commit comments

Comments
 (0)