mirror of
https://github.com/coder/code-server.git
synced 2026-05-28 16:09:35 +00:00
Merge commit 'be3e8236086165e5e45a5a10783823874b3f3ebd' as 'lib/vscode'
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import { ICommandAction, MenuId, MenuRegistry } from 'vs/platform/actions/common/actions';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import { CATEGORIES } from 'vs/workbench/common/actions';
|
||||
import { Extensions as WorkbenchExtensions, IWorkbenchContribution, IWorkbenchContributionsRegistry } from 'vs/workbench/common/contributions';
|
||||
import { IWebIssueService, WebIssueService } from 'vs/workbench/contrib/issue/browser/issueService';
|
||||
import { OpenIssueReporterArgs, OpenIssueReporterActionId } from 'vs/workbench/contrib/issue/common/commands';
|
||||
|
||||
class RegisterIssueContribution implements IWorkbenchContribution {
|
||||
|
||||
constructor(@IProductService readonly productService: IProductService) {
|
||||
if (productService.reportIssueUrl) {
|
||||
const OpenIssueReporterActionLabel = nls.localize({ key: 'reportIssueInEnglish', comment: ['Translate this to "Report Issue in English" in all languages please!'] }, "Report Issue");
|
||||
|
||||
CommandsRegistry.registerCommand(OpenIssueReporterActionId, function (accessor, args?: [string] | OpenIssueReporterArgs) {
|
||||
let extensionId: string | undefined;
|
||||
if (args) {
|
||||
if (Array.isArray(args)) {
|
||||
[extensionId] = args;
|
||||
} else {
|
||||
extensionId = args.extensionId;
|
||||
}
|
||||
}
|
||||
|
||||
return accessor.get(IWebIssueService).openReporter({ extensionId });
|
||||
});
|
||||
|
||||
const command: ICommandAction = {
|
||||
id: OpenIssueReporterActionId,
|
||||
title: { value: OpenIssueReporterActionLabel, original: 'Report Issue' },
|
||||
category: CATEGORIES.Help
|
||||
};
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(RegisterIssueContribution, LifecyclePhase.Starting);
|
||||
|
||||
CommandsRegistry.registerCommand('_issues.getSystemStatus', (accessor) => {
|
||||
return nls.localize('statusUnsupported', "The --status argument is not yet supported in browsers.");
|
||||
});
|
||||
|
||||
registerSingleton(IWebIssueService, WebIssueService, true);
|
||||
@@ -0,0 +1,67 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { normalizeGitHubUrl } from 'vs/platform/issue/common/issueReporterUtil';
|
||||
import { IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { ExtensionType } from 'vs/platform/extensions/common/extensions';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IOpenerService } from 'vs/platform/opener/common/opener';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
|
||||
export const IWebIssueService = createDecorator<IWebIssueService>('webIssueService');
|
||||
|
||||
export interface IIssueReporterOptions {
|
||||
extensionId?: string;
|
||||
}
|
||||
|
||||
export interface IWebIssueService {
|
||||
readonly _serviceBrand: undefined;
|
||||
openReporter(options?: IIssueReporterOptions): Promise<void>;
|
||||
}
|
||||
|
||||
export class WebIssueService implements IWebIssueService {
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
constructor(
|
||||
@IExtensionManagementService private readonly extensionManagementService: IExtensionManagementService,
|
||||
@IOpenerService private readonly openerService: IOpenerService,
|
||||
@IProductService private readonly productService: IProductService
|
||||
) { }
|
||||
|
||||
async openReporter(options: IIssueReporterOptions): Promise<void> {
|
||||
let repositoryUrl = this.productService.reportIssueUrl;
|
||||
if (options.extensionId) {
|
||||
const extensionGitHubUrl = await this.getExtensionGitHubUrl(options.extensionId);
|
||||
if (extensionGitHubUrl) {
|
||||
repositoryUrl = extensionGitHubUrl + '/issues/new';
|
||||
}
|
||||
}
|
||||
|
||||
if (repositoryUrl) {
|
||||
return this.openerService.open(URI.parse(repositoryUrl)).then(_ => { });
|
||||
} else {
|
||||
throw new Error(`Unable to find issue reporting url for ${options.extensionId}`);
|
||||
}
|
||||
}
|
||||
|
||||
private async getExtensionGitHubUrl(extensionId: string): Promise<string> {
|
||||
let repositoryUrl = '';
|
||||
|
||||
const extensions = await this.extensionManagementService.getInstalled(ExtensionType.User);
|
||||
const selectedExtension = extensions.filter(ext => ext.identifier.id === extensionId)[0];
|
||||
const bugsUrl = selectedExtension?.manifest.bugs?.url;
|
||||
const extensionUrl = selectedExtension?.manifest.repository?.url;
|
||||
|
||||
// If given, try to match the extension's bug url
|
||||
if (bugsUrl && bugsUrl.match(/^https?:\/\/github\.com\/(.*)/)) {
|
||||
repositoryUrl = normalizeGitHubUrl(bugsUrl);
|
||||
} else if (extensionUrl && extensionUrl.match(/^https?:\/\/github\.com\/(.*)/)) {
|
||||
repositoryUrl = normalizeGitHubUrl(extensionUrl);
|
||||
}
|
||||
|
||||
return repositoryUrl;
|
||||
}
|
||||
}
|
||||
12
lib/vscode/src/vs/workbench/contrib/issue/common/commands.ts
Normal file
12
lib/vscode/src/vs/workbench/contrib/issue/common/commands.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
export const OpenIssueReporterActionId = 'workbench.action.openIssueReporter';
|
||||
|
||||
export interface OpenIssueReporterArgs {
|
||||
readonly extensionId?: string;
|
||||
readonly issueTitle?: string;
|
||||
readonly issueBody?: string;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Registry } from 'vs/platform/registry/common/platform';
|
||||
import * as nls from 'vs/nls';
|
||||
import product from 'vs/platform/product/common/product';
|
||||
import { SyncActionDescriptor, ICommandAction, MenuRegistry, MenuId } from 'vs/platform/actions/common/actions';
|
||||
import { IWorkbenchActionRegistry, Extensions, CATEGORIES } from 'vs/workbench/common/actions';
|
||||
import { ReportPerformanceIssueUsingReporterAction, OpenProcessExplorer } from 'vs/workbench/contrib/issue/electron-sandbox/issueActions';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { IWorkbenchIssueService } from 'vs/workbench/contrib/issue/electron-sandbox/issue';
|
||||
import { WorkbenchIssueService } from 'vs/workbench/contrib/issue/electron-sandbox/issueService';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { IssueReporterData } from 'vs/platform/issue/common/issue';
|
||||
import { IIssueService } from 'vs/platform/issue/electron-sandbox/issue';
|
||||
import { OpenIssueReporterArgs, OpenIssueReporterActionId } from 'vs/workbench/contrib/issue/common/commands';
|
||||
|
||||
const workbenchActionsRegistry = Registry.as<IWorkbenchActionRegistry>(Extensions.WorkbenchActions);
|
||||
|
||||
if (!!product.reportIssueUrl) {
|
||||
workbenchActionsRegistry.registerWorkbenchAction(SyncActionDescriptor.from(ReportPerformanceIssueUsingReporterAction), 'Help: Report Performance Issue', CATEGORIES.Help.value);
|
||||
|
||||
const OpenIssueReporterActionLabel = nls.localize({ key: 'reportIssueInEnglish', comment: ['Translate this to "Report Issue in English" in all languages please!'] }, "Report Issue...");
|
||||
|
||||
CommandsRegistry.registerCommand(OpenIssueReporterActionId, function (accessor, args?: [string] | OpenIssueReporterArgs) {
|
||||
const data: Partial<IssueReporterData> = Array.isArray(args)
|
||||
? { extensionId: args[0] }
|
||||
: args || {};
|
||||
|
||||
return accessor.get(IWorkbenchIssueService).openReporter(data);
|
||||
});
|
||||
|
||||
const command: ICommandAction = {
|
||||
id: OpenIssueReporterActionId,
|
||||
title: { value: OpenIssueReporterActionLabel, original: 'Report Issue' },
|
||||
category: CATEGORIES.Help
|
||||
};
|
||||
|
||||
MenuRegistry.appendMenuItem(MenuId.CommandPalette, { command });
|
||||
}
|
||||
|
||||
workbenchActionsRegistry.registerWorkbenchAction(SyncActionDescriptor.from(OpenProcessExplorer), 'Developer: Open Process Explorer', CATEGORIES.Developer.value);
|
||||
|
||||
registerSingleton(IWorkbenchIssueService, WorkbenchIssueService, true);
|
||||
|
||||
CommandsRegistry.registerCommand('_issues.getSystemStatus', (accessor) => {
|
||||
return accessor.get(IIssueService).getSystemStatus();
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IssueReporterData } from 'vs/platform/issue/common/issue';
|
||||
|
||||
export const IWorkbenchIssueService = createDecorator<IWorkbenchIssueService>('workbenchIssueService');
|
||||
|
||||
export interface IWorkbenchIssueService {
|
||||
readonly _serviceBrand: undefined;
|
||||
openReporter(dataOverrides?: Partial<IssueReporterData>): Promise<void>;
|
||||
openProcessExplorer(): Promise<void>;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Action } from 'vs/base/common/actions';
|
||||
import * as nls from 'vs/nls';
|
||||
import { IssueType } from 'vs/platform/issue/common/issue';
|
||||
import { IWorkbenchIssueService } from 'vs/workbench/contrib/issue/electron-sandbox/issue';
|
||||
|
||||
export class OpenProcessExplorer extends Action {
|
||||
static readonly ID = 'workbench.action.openProcessExplorer';
|
||||
static readonly LABEL = nls.localize('openProcessExplorer', "Open Process Explorer");
|
||||
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IWorkbenchIssueService private readonly issueService: IWorkbenchIssueService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(): Promise<boolean> {
|
||||
return this.issueService.openProcessExplorer().then(() => true);
|
||||
}
|
||||
}
|
||||
|
||||
export class ReportPerformanceIssueUsingReporterAction extends Action {
|
||||
static readonly ID = 'workbench.action.reportPerformanceIssueUsingReporter';
|
||||
static readonly LABEL = nls.localize({ key: 'reportPerformanceIssue', comment: [`Here, 'issue' means problem or bug`] }, "Report Performance Issue");
|
||||
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IWorkbenchIssueService private readonly issueService: IWorkbenchIssueService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(): Promise<boolean> {
|
||||
return this.issueService.openReporter({ issueType: IssueType.PerformanceIssue }).then(() => true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IssueReporterStyles, IssueReporterData, ProcessExplorerData, IssueReporterExtensionData } from 'vs/platform/issue/common/issue';
|
||||
import { IIssueService } from 'vs/platform/issue/electron-sandbox/issue';
|
||||
import { IColorTheme, IThemeService } from 'vs/platform/theme/common/themeService';
|
||||
import { textLinkForeground, inputBackground, inputBorder, inputForeground, buttonBackground, buttonHoverBackground, buttonForeground, inputValidationErrorBorder, foreground, inputActiveOptionBorder, scrollbarSliderActiveBackground, scrollbarSliderBackground, scrollbarSliderHoverBackground, editorBackground, editorForeground, listHoverBackground, listHoverForeground, listHighlightForeground, textLinkActiveForeground, inputValidationErrorBackground, inputValidationErrorForeground } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
|
||||
import { IExtensionManagementService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
||||
import { IWorkbenchExtensionEnablementService } from 'vs/workbench/services/extensionManagement/common/extensionManagement';
|
||||
import { getZoomLevel } from 'vs/base/browser/browser';
|
||||
import { IWorkbenchIssueService } from 'vs/workbench/contrib/issue/electron-sandbox/issue';
|
||||
import { INativeWorkbenchEnvironmentService } from 'vs/workbench/services/environment/electron-sandbox/environmentService';
|
||||
import { ExtensionType } from 'vs/platform/extensions/common/extensions';
|
||||
import { process } from 'vs/base/parts/sandbox/electron-sandbox/globals';
|
||||
import { IProductService } from 'vs/platform/product/common/productService';
|
||||
|
||||
export class WorkbenchIssueService implements IWorkbenchIssueService {
|
||||
declare readonly _serviceBrand: undefined;
|
||||
|
||||
constructor(
|
||||
@IIssueService private readonly issueService: IIssueService,
|
||||
@IThemeService private readonly themeService: IThemeService,
|
||||
@IExtensionManagementService private readonly extensionManagementService: IExtensionManagementService,
|
||||
@IWorkbenchExtensionEnablementService private readonly extensionEnablementService: IWorkbenchExtensionEnablementService,
|
||||
@INativeWorkbenchEnvironmentService private readonly environmentService: INativeWorkbenchEnvironmentService,
|
||||
@IProductService private readonly productService: IProductService
|
||||
) { }
|
||||
|
||||
async openReporter(dataOverrides: Partial<IssueReporterData> = {}): Promise<void> {
|
||||
const extensions = await this.extensionManagementService.getInstalled();
|
||||
const enabledExtensions = extensions.filter(extension => this.extensionEnablementService.isEnabled(extension));
|
||||
const extensionData = enabledExtensions.map((extension): IssueReporterExtensionData => {
|
||||
const { manifest } = extension;
|
||||
const manifestKeys = manifest.contributes ? Object.keys(manifest.contributes) : [];
|
||||
const isTheme = !manifest.activationEvents && manifestKeys.length === 1 && manifestKeys[0] === 'themes';
|
||||
const isBuiltin = extension.type === ExtensionType.System;
|
||||
return {
|
||||
name: manifest.name,
|
||||
publisher: manifest.publisher,
|
||||
version: manifest.version,
|
||||
repositoryUrl: manifest.repository && manifest.repository.url,
|
||||
bugsUrl: manifest.bugs && manifest.bugs.url,
|
||||
displayName: manifest.displayName,
|
||||
id: extension.identifier.id,
|
||||
isTheme,
|
||||
isBuiltin,
|
||||
};
|
||||
});
|
||||
const theme = this.themeService.getColorTheme();
|
||||
const issueReporterData: IssueReporterData = Object.assign({
|
||||
styles: getIssueReporterStyles(theme),
|
||||
zoomLevel: getZoomLevel(),
|
||||
enabledExtensions: extensionData,
|
||||
}, dataOverrides);
|
||||
return this.issueService.openReporter(issueReporterData);
|
||||
}
|
||||
|
||||
openProcessExplorer(): Promise<void> {
|
||||
const theme = this.themeService.getColorTheme();
|
||||
const data: ProcessExplorerData = {
|
||||
pid: this.environmentService.configuration.mainPid,
|
||||
zoomLevel: getZoomLevel(),
|
||||
styles: {
|
||||
backgroundColor: getColor(theme, editorBackground),
|
||||
color: getColor(theme, editorForeground),
|
||||
hoverBackground: getColor(theme, listHoverBackground),
|
||||
hoverForeground: getColor(theme, listHoverForeground),
|
||||
highlightForeground: getColor(theme, listHighlightForeground),
|
||||
},
|
||||
platform: process.platform,
|
||||
applicationName: this.productService.applicationName
|
||||
};
|
||||
return this.issueService.openProcessExplorer(data);
|
||||
}
|
||||
}
|
||||
|
||||
export function getIssueReporterStyles(theme: IColorTheme): IssueReporterStyles {
|
||||
return {
|
||||
backgroundColor: getColor(theme, SIDE_BAR_BACKGROUND),
|
||||
color: getColor(theme, foreground),
|
||||
textLinkColor: getColor(theme, textLinkForeground),
|
||||
textLinkActiveForeground: getColor(theme, textLinkActiveForeground),
|
||||
inputBackground: getColor(theme, inputBackground),
|
||||
inputForeground: getColor(theme, inputForeground),
|
||||
inputBorder: getColor(theme, inputBorder),
|
||||
inputActiveBorder: getColor(theme, inputActiveOptionBorder),
|
||||
inputErrorBorder: getColor(theme, inputValidationErrorBorder),
|
||||
inputErrorBackground: getColor(theme, inputValidationErrorBackground),
|
||||
inputErrorForeground: getColor(theme, inputValidationErrorForeground),
|
||||
buttonBackground: getColor(theme, buttonBackground),
|
||||
buttonForeground: getColor(theme, buttonForeground),
|
||||
buttonHoverBackground: getColor(theme, buttonHoverBackground),
|
||||
sliderActiveColor: getColor(theme, scrollbarSliderActiveBackground),
|
||||
sliderBackgroundColor: getColor(theme, scrollbarSliderBackground),
|
||||
sliderHoverColor: getColor(theme, scrollbarSliderHoverBackground),
|
||||
};
|
||||
}
|
||||
|
||||
function getColor(theme: IColorTheme, key: string): string | undefined {
|
||||
const color = theme.getColor(key);
|
||||
return color ? color.toString() : undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user