提交 6493a67f 编写于 作者: A Alex Ross

Allow remote help contribution to take command

Fixes #99661
上级 e6124e39
......@@ -74,19 +74,19 @@ const remoteHelpExtPoint = ExtensionsRegistry.registerExtensionPoint<HelpInforma
type: 'object',
properties: {
'getStarted': {
description: nls.localize('RemoteHelpInformationExtPoint.getStarted', "The url to your project's Getting Started page"),
description: nls.localize('RemoteHelpInformationExtPoint.getStarted', "The url, or a command that returns the url, to your project's Getting Started page"),
type: 'string'
},
'documentation': {
description: nls.localize('RemoteHelpInformationExtPoint.documentation', "The url to your project's documentation page"),
description: nls.localize('RemoteHelpInformationExtPoint.documentation', "The url, or a command that returns the url, to your project's documentation page"),
type: 'string'
},
'feedback': {
description: nls.localize('RemoteHelpInformationExtPoint.feedback', "The url to your project's feedback reporter"),
description: nls.localize('RemoteHelpInformationExtPoint.feedback', "The url, or a command that returns the url, to your project's feedback reporter"),
type: 'string'
},
'issues': {
description: nls.localize('RemoteHelpInformationExtPoint.issues', "The url to your project's issues list"),
description: nls.localize('RemoteHelpInformationExtPoint.issues', "The url, or a command that returns the url, to your project's issues list"),
type: 'string'
}
}
......@@ -182,11 +182,11 @@ class HelpModel {
helpItems.push(new HelpItem(
getStartedIcon,
nls.localize('remote.help.getStarted', "Get Started"),
getStarted.map((info: HelpInformation) => ({
extensionDescription: info.extensionDescription,
url: info.getStarted!,
remoteAuthority: (typeof info.remoteName === 'string') ? [info.remoteName] : info.remoteName
})),
getStarted.map((info: HelpInformation) => (new HelpItemValue(commandService,
info.extensionDescription,
(typeof info.remoteName === 'string') ? [info.remoteName] : info.remoteName,
info.getStarted!)
)),
quickInputService,
environmentService,
openerService,
......@@ -200,11 +200,11 @@ class HelpModel {
helpItems.push(new HelpItem(
documentationIcon,
nls.localize('remote.help.documentation', "Read Documentation"),
documentation.map((info: HelpInformation) => ({
extensionDescription: info.extensionDescription,
url: info.documentation!,
remoteAuthority: (typeof info.remoteName === 'string') ? [info.remoteName] : info.remoteName
})),
documentation.map((info: HelpInformation) => (new HelpItemValue(commandService,
info.extensionDescription,
(typeof info.remoteName === 'string') ? [info.remoteName] : info.remoteName,
info.documentation!)
)),
quickInputService,
environmentService,
openerService,
......@@ -218,11 +218,11 @@ class HelpModel {
helpItems.push(new HelpItem(
feedbackIcon,
nls.localize('remote.help.feedback', "Provide Feedback"),
feedback.map((info: HelpInformation) => ({
extensionDescription: info.extensionDescription,
url: info.feedback!,
remoteAuthority: (typeof info.remoteName === 'string') ? [info.remoteName] : info.remoteName
})),
feedback.map((info: HelpInformation) => (new HelpItemValue(commandService,
info.extensionDescription,
(typeof info.remoteName === 'string') ? [info.remoteName] : info.remoteName,
info.feedback!)
)),
quickInputService,
environmentService,
openerService,
......@@ -236,11 +236,11 @@ class HelpModel {
helpItems.push(new HelpItem(
reviewIssuesIcon,
nls.localize('remote.help.issues', "Review Issues"),
issues.map((info: HelpInformation) => ({
extensionDescription: info.extensionDescription,
url: info.issues!,
remoteAuthority: (typeof info.remoteName === 'string') ? [info.remoteName] : info.remoteName
})),
issues.map((info: HelpInformation) => (new HelpItemValue(commandService,
info.extensionDescription,
(typeof info.remoteName === 'string') ? [info.remoteName] : info.remoteName,
info.issues!)
)),
quickInputService,
environmentService,
openerService,
......@@ -252,10 +252,10 @@ class HelpModel {
helpItems.push(new IssueReporterItem(
reportIssuesIcon,
nls.localize('remote.help.report', "Report Issue"),
viewModel.helpInformation.map(info => ({
extensionDescription: info.extensionDescription,
remoteAuthority: (typeof info.remoteName === 'string') ? [info.remoteName] : info.remoteName
})),
viewModel.helpInformation.map(info => (new HelpItemValue(commandService,
info.extensionDescription,
(typeof info.remoteName === 'string') ? [info.remoteName] : info.remoteName
))),
quickInputService,
environmentService,
commandService,
......@@ -269,12 +269,35 @@ class HelpModel {
}
}
class HelpItemValue {
private _url: string | undefined;
constructor(private commandService: ICommandService, public extensionDescription: IExtensionDescription, public remoteAuthority: string[] | undefined, private urlOrCommand?: string) { }
get url(): Promise<string> {
return new Promise(async (resolve) => {
if (this._url === undefined) {
if (this.urlOrCommand) {
let url = URI.parse(this.urlOrCommand);
if (url.authority) {
this._url = this.urlOrCommand;
} else {
this._url = await this.commandService.executeCommand(this.urlOrCommand);
}
} else {
this._url = '';
}
}
resolve(this._url);
});
}
}
abstract class HelpItemBase implements IHelpItem {
public iconClasses: string[] = [];
constructor(
public icon: Codicon,
public label: string,
public values: { extensionDescription: IExtensionDescription, url?: string, remoteAuthority: string[] | undefined }[],
public values: HelpItemValue[],
private quickInputService: IQuickInputService,
private environmentService: IWorkbenchEnvironmentService,
private remoteExplorerService: IRemoteExplorerService
......@@ -285,17 +308,16 @@ abstract class HelpItemBase implements IHelpItem {
async handleClick() {
const remoteAuthority = this.environmentService.configuration.remoteAuthority;
if (!remoteAuthority) {
return;
}
for (let i = 0; i < this.remoteExplorerService.targetType.length; i++) {
if (startsWith(remoteAuthority, this.remoteExplorerService.targetType[i])) {
for (let value of this.values) {
if (value.remoteAuthority) {
for (let authority of value.remoteAuthority) {
if (startsWith(remoteAuthority, authority)) {
await this.takeAction(value.extensionDescription, value.url);
return;
if (remoteAuthority) {
for (let i = 0; i < this.remoteExplorerService.targetType.length; i++) {
if (startsWith(remoteAuthority, this.remoteExplorerService.targetType[i])) {
for (let value of this.values) {
if (value.remoteAuthority) {
for (let authority of value.remoteAuthority) {
if (startsWith(remoteAuthority, authority)) {
await this.takeAction(value.extensionDescription, await value.url);
return;
}
}
}
}
......@@ -304,13 +326,13 @@ abstract class HelpItemBase implements IHelpItem {
}
if (this.values.length > 1) {
let actions = this.values.map(value => {
let actions = await Promise.all(this.values.map(async (value) => {
return {
label: value.extensionDescription.displayName || value.extensionDescription.identifier.value,
description: value.url,
description: await value.url,
extensionDescription: value.extensionDescription
};
});
}));
const action = await this.quickInputService.pick(actions, { placeHolder: nls.localize('pickRemoteExtension', "Select url to open") });
......@@ -318,7 +340,7 @@ abstract class HelpItemBase implements IHelpItem {
await this.takeAction(action.extensionDescription, action.description);
}
} else {
await this.takeAction(this.values[0].extensionDescription, this.values[0].url);
await this.takeAction(this.values[0].extensionDescription, await this.values[0].url);
}
}
......@@ -329,7 +351,7 @@ class HelpItem extends HelpItemBase {
constructor(
icon: Codicon,
label: string,
values: { extensionDescription: IExtensionDescription; url: string, remoteAuthority: string[] | undefined }[],
values: HelpItemValue[],
quickInputService: IQuickInputService,
environmentService: IWorkbenchEnvironmentService,
private openerService: IOpenerService,
......@@ -347,7 +369,7 @@ class IssueReporterItem extends HelpItemBase {
constructor(
icon: Codicon,
label: string,
values: { extensionDescription: IExtensionDescription; remoteAuthority: string[] | undefined }[],
values: HelpItemValue[],
quickInputService: IQuickInputService,
environmentService: IWorkbenchEnvironmentService,
private commandService: ICommandService,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册