Move files under vs/code/electron-browser/issue

This commit is contained in:
Rachel Macfarlane
2018-01-18 17:11:52 -08:00
parent 69c2797641
commit f31ea9bba3
10 changed files with 8 additions and 6 deletions

View 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>
`;
}
}