mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-03 06:51:53 +01:00
Move files under vs/code/electron-browser/issue
This commit is contained in:
132
src/vs/code/electron-browser/issue/issueReporterModel.ts
Normal file
132
src/vs/code/electron-browser/issue/issueReporterModel.ts
Normal file
@@ -0,0 +1,132 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
|
||||
export interface IssueReporterData {
|
||||
issueType?: number;
|
||||
issueDescription?: string;
|
||||
versionInfo?: any;
|
||||
systemInfo?: any;
|
||||
processInfo?: any;
|
||||
workspaceInfo?: any;
|
||||
includeSystemInfo?: boolean;
|
||||
includeWorkspaceInfo?: boolean;
|
||||
includeProcessInfo?: boolean;
|
||||
}
|
||||
|
||||
export class IssueReporterModel {
|
||||
private _data: IssueReporterData;
|
||||
|
||||
constructor(initialData?: IssueReporterData) {
|
||||
this._data = initialData || {};
|
||||
}
|
||||
|
||||
getData(): IssueReporterData {
|
||||
return this._data;
|
||||
}
|
||||
|
||||
update(newData: IssueReporterData): void {
|
||||
assign(this._data, newData);
|
||||
}
|
||||
|
||||
serialize(): string {
|
||||
return `
|
||||
### Issue Type
|
||||
${this.getIssueTypeTitle()}
|
||||
|
||||
### Description
|
||||
|
||||
${this._data.issueDescription}
|
||||
|
||||
### VS Code Info
|
||||
|
||||
VS Code version: ${this._data.versionInfo && this._data.versionInfo.vscodeVersion}
|
||||
OS version: ${this._data.versionInfo && this._data.versionInfo.os}
|
||||
|
||||
${this.getInfos()}
|
||||
|
||||
<!-- Generated by VS Code Issue Helper -->
|
||||
`;
|
||||
}
|
||||
|
||||
private getIssueTypeTitle(): string {
|
||||
if (this._data.issueType === 0) {
|
||||
return 'Bug';
|
||||
} else if (this._data.issueType === 1) {
|
||||
return 'Performance Issue';
|
||||
} else {
|
||||
return 'Feature Request';
|
||||
}
|
||||
}
|
||||
|
||||
private getInfos(): string {
|
||||
let info = '';
|
||||
|
||||
if (this._data.includeSystemInfo) {
|
||||
info += this.generateSystemInfoMd();
|
||||
}
|
||||
|
||||
// For perf issue, add process info and workspace info too
|
||||
if (this._data.issueType === 1) {
|
||||
|
||||
if (this._data.includeProcessInfo) {
|
||||
info += this.generateProcessInfoMd();
|
||||
}
|
||||
|
||||
if (this._data.includeWorkspaceInfo) {
|
||||
info += this.generateWorkspaceInfoMd();
|
||||
}
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
private generateSystemInfoMd(): string {
|
||||
let md = `<details>
|
||||
<summary>System Info</summary>
|
||||
|
||||
|Item|Value|
|
||||
|---|---|
|
||||
`;
|
||||
|
||||
Object.keys(this._data.systemInfo).forEach(k => {
|
||||
md += `|${k}|${this._data.systemInfo[k]}|\n`;
|
||||
});
|
||||
|
||||
md += '\n</details>';
|
||||
|
||||
return md;
|
||||
}
|
||||
|
||||
private generateProcessInfoMd(): string {
|
||||
let md = `<details>
|
||||
<summary>Process Info</summary>
|
||||
|
||||
|pid|CPU|Memory (MB)|Name|
|
||||
|---|---|---|---|
|
||||
`;
|
||||
|
||||
this._data.processInfo.forEach(p => {
|
||||
md += `|${p.pid}|${p.cpu}|${p.memory}|${p.name}|\n`;
|
||||
});
|
||||
|
||||
md += '\n</details>';
|
||||
|
||||
return md;
|
||||
}
|
||||
|
||||
private generateWorkspaceInfoMd(): string {
|
||||
return `<details>
|
||||
<summary>Workspace Info</summary>
|
||||
|
||||
\`\`\`
|
||||
${this._data.workspaceInfo};
|
||||
\`\`\`
|
||||
|
||||
</details>
|
||||
`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user