Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/issue/common/issue.contribution.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { Disposable } from '../../../../base/common/lifecycle.js';
7
import { localize, localize2 } from '../../../../nls.js';
8
import { ICommandAction } from '../../../../platform/action/common/action.js';
9
import { Categories } from '../../../../platform/action/common/actionCommonCategories.js';
10
import { MenuId, MenuRegistry } from '../../../../platform/actions/common/actions.js';
11
import { CommandsRegistry, ICommandMetadata } from '../../../../platform/commands/common/commands.js';
12
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
13
import { INotificationService } from '../../../../platform/notification/common/notification.js';
14
import { IProductService } from '../../../../platform/product/common/productService.js';
15
import { IWorkbenchContribution } from '../../../common/contributions.js';
16
import { IssueReporterData, IWorkbenchIssueService } from './issue.js';
17
18
const OpenIssueReporterActionId = 'workbench.action.openIssueReporter';
19
const OpenIssueReporterApiId = 'vscode.openIssueReporter';
20
21
const OpenIssueReporterCommandMetadata: ICommandMetadata = {
22
description: 'Open the issue reporter and optionally prefill part of the form.',
23
args: [
24
{
25
name: 'options',
26
description: 'Data to use to prefill the issue reporter with.',
27
isOptional: true,
28
schema: {
29
oneOf: [
30
{
31
type: 'string',
32
description: 'The extension id to preselect.'
33
},
34
{
35
type: 'object',
36
properties: {
37
extensionId: {
38
type: 'string'
39
},
40
issueTitle: {
41
type: 'string'
42
},
43
issueBody: {
44
type: 'string'
45
}
46
}
47
48
}
49
]
50
}
51
},
52
]
53
};
54
55
interface OpenIssueReporterArgs {
56
readonly extensionId?: string;
57
readonly issueTitle?: string;
58
readonly issueBody?: string;
59
readonly extensionData?: string;
60
}
61
62
export class BaseIssueContribution extends Disposable implements IWorkbenchContribution {
63
constructor(
64
@IProductService productService: IProductService,
65
@IConfigurationService configurationService: IConfigurationService,
66
) {
67
super();
68
69
if (!configurationService.getValue<boolean>('telemetry.feedback.enabled')) {
70
this._register(CommandsRegistry.registerCommand({
71
id: 'workbench.action.openIssueReporter',
72
handler: function (accessor) {
73
const data = accessor.get(INotificationService);
74
data.info('Feedback is disabled.');
75
76
},
77
}));
78
return;
79
}
80
81
if (!productService.reportIssueUrl) {
82
return;
83
}
84
85
this._register(CommandsRegistry.registerCommand({
86
id: OpenIssueReporterActionId,
87
handler: function (accessor, args?: string | [string] | OpenIssueReporterArgs) {
88
const data: Partial<IssueReporterData> =
89
typeof args === 'string'
90
? { extensionId: args }
91
: Array.isArray(args)
92
? { extensionId: args[0] }
93
: args ?? {};
94
95
return accessor.get(IWorkbenchIssueService).openReporter(data);
96
},
97
metadata: OpenIssueReporterCommandMetadata
98
}));
99
100
this._register(CommandsRegistry.registerCommand({
101
id: OpenIssueReporterApiId,
102
handler: function (accessor, args?: string | [string] | OpenIssueReporterArgs) {
103
const data: Partial<IssueReporterData> =
104
typeof args === 'string'
105
? { extensionId: args }
106
: Array.isArray(args)
107
? { extensionId: args[0] }
108
: args ?? {};
109
110
return accessor.get(IWorkbenchIssueService).openReporter(data);
111
},
112
metadata: OpenIssueReporterCommandMetadata
113
}));
114
115
const reportIssue: ICommandAction = {
116
id: OpenIssueReporterActionId,
117
title: localize2({ key: 'reportIssueInEnglish', comment: ['Translate this to "Report Issue in English" in all languages please!'] }, "Report Issue..."),
118
category: Categories.Help
119
};
120
121
this._register(MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command: reportIssue }));
122
123
this._register(MenuRegistry.appendMenuItem(MenuId.MenubarHelpMenu, {
124
group: '3_feedback',
125
command: {
126
id: OpenIssueReporterActionId,
127
title: localize({ key: 'miReportIssue', comment: ['&& denotes a mnemonic', 'Translate this to "Report Issue in English" in all languages please!'] }, "Report &&Issue")
128
},
129
order: 3
130
}));
131
}
132
}
133
134