Skip to content

Commit

Permalink
Include if client is in unsupported mode & include restricted mode in…
Browse files Browse the repository at this point in the history
… copy (#154209)
  • Loading branch information
TylerLeonhardt committed Jul 6, 2022
1 parent 984df90 commit 8b475a0
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 15 deletions.
5 changes: 5 additions & 0 deletions src/vs/code/electron-sandbox/issue/issueReporterMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export class IssueReporter extends Disposable {
this.handleExtensionData(configuration.data.enabledExtensions);
this.updateExperimentsInfo(configuration.data.experiments);
this.updateRestrictedMode(configuration.data.restrictedMode);
this.updateUnsupportedMode(configuration.data.isUnsupported);
}

render(): void {
Expand Down Expand Up @@ -1154,6 +1155,10 @@ export class IssueReporter extends Disposable {
this.issueReporterModel.update({ restrictedMode });
}

private updateUnsupportedMode(isUnsupported: boolean) {
this.issueReporterModel.update({ isUnsupported });
}

private updateExperimentsInfo(experimentInfo: string | undefined) {
this.issueReporterModel.update({ experimentInfo });
const target = document.querySelector<HTMLElement>('.block-experiments .block-info');
Expand Down
12 changes: 10 additions & 2 deletions src/vs/code/electron-sandbox/issue/issueReporterModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface IssueReporterData {
filterResultCount?: number;
experimentInfo?: string;
restrictedMode?: boolean;
isUnsupported?: boolean;
}

export class IssueReporterModel {
Expand Down Expand Up @@ -61,14 +62,21 @@ export class IssueReporterModel {
}

serialize(): string {
const modes = [];
if (this._data.restrictedMode) {
modes.push('Restricted');
}
if (this._data.isUnsupported) {
modes.push('Unsupported');
}
return `
Issue Type: <b>${this.getIssueTypeTitle()}</b>
Type: <b>${this.getIssueTypeTitle()}</b>
${this._data.issueDescription}
${this.getExtensionVersion()}
VS Code version: ${this._data.versionInfo && this._data.versionInfo.vscodeVersion}
OS version: ${this._data.versionInfo && this._data.versionInfo.os}
Restricted Mode: ${this._data.restrictedMode ? 'Yes' : 'No'}
Modes:${modes.length ? ' ' + modes.join(', ') : ''}
${this.getRemoteOSes()}
${this.getInfos()}
<!-- generated by issue reporter -->`;
Expand Down
42 changes: 30 additions & 12 deletions src/vs/code/test/electron-sandbox/issue/testReporterModel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ suite('IssueReporter', () => {
const issueReporterModel = new IssueReporterModel({});
assert.strictEqual(issueReporterModel.serialize(),
`
Issue Type: <b>Bug</b>
Type: <b>Bug</b>
undefined
VS Code version: undefined
OS version: undefined
Restricted Mode: No
Modes:
Extensions: none
<!-- generated by issue reporter -->`);
Expand All @@ -58,13 +58,13 @@ Extensions: none
});
assert.strictEqual(issueReporterModel.serialize(),
`
Issue Type: <b>Bug</b>
Type: <b>Bug</b>
undefined
VS Code version: undefined
OS version: undefined
Restricted Mode: No
Modes:
<details>
<summary>System Info</summary>
Expand Down Expand Up @@ -102,13 +102,13 @@ Restricted Mode: No
});
assert.strictEqual(issueReporterModel.serialize(),
`
Issue Type: <b>Bug</b>
Type: <b>Bug</b>
undefined
VS Code version: undefined
OS version: undefined
Restricted Mode: No
Modes:
<details>
<summary>System Info</summary>
Expand Down Expand Up @@ -157,13 +157,13 @@ vsins829:30139715
});
assert.strictEqual(issueReporterModel.serialize(),
`
Issue Type: <b>Bug</b>
Type: <b>Bug</b>
undefined
VS Code version: undefined
OS version: undefined
Restricted Mode: No
Modes:
<details>
<summary>System Info</summary>
Expand Down Expand Up @@ -214,13 +214,13 @@ Restricted Mode: No
});
assert.strictEqual(issueReporterModel.serialize(),
`
Issue Type: <b>Bug</b>
Type: <b>Bug</b>
undefined
VS Code version: undefined
OS version: undefined
Restricted Mode: No
Modes:
Remote OS version: Linux x64 4.18.0
<details>
Expand Down Expand Up @@ -263,13 +263,13 @@ Remote OS version: Linux x64 4.18.0
});
assert.strictEqual(issueReporterModel.serialize(),
`
Issue Type: <b>Bug</b>
Type: <b>Bug</b>
undefined
VS Code version: undefined
OS version: undefined
Restricted Mode: No
Modes:
<details>
<summary>System Info</summary>
Expand All @@ -287,6 +287,24 @@ Restricted Mode: No
<!-- generated by issue reporter -->`);
});

test('should supply mode if applicable', () => {
const issueReporterModel = new IssueReporterModel({
isUnsupported: true,
restrictedMode: true
});
assert.strictEqual(issueReporterModel.serialize(),
`
Type: <b>Bug</b>
undefined
VS Code version: undefined
OS version: undefined
Modes: Restricted, Unsupported
Extensions: none
<!-- generated by issue reporter -->`);
});
test('should normalize GitHub urls', () => {
[
'https://github.com/repo',
Expand Down
1 change: 1 addition & 0 deletions src/vs/platform/issue/common/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface IssueReporterData extends WindowData {
extensionId?: string;
experiments?: string;
restrictedMode: boolean;
isUnsupported: boolean;
githubAccessToken: string;
readonly issueTitle?: string;
readonly issueBody?: string;
Expand Down
13 changes: 12 additions & 1 deletion src/vs/workbench/services/issue/electron-sandbox/issueService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { IWorkbenchAssignmentService } from 'vs/workbench/services/assignment/co
import { IAuthenticationService } from 'vs/workbench/services/authentication/common/authentication';
import { registerMainProcessRemoteService } from 'vs/platform/ipc/electron-sandbox/services';
import { IWorkspaceTrustManagementService } from 'vs/platform/workspace/common/workspaceTrust';
import { IIntegrityService } from 'vs/workbench/services/integrity/common/integrity';

export class WorkbenchIssueService implements IWorkbenchIssueService {
declare readonly _serviceBrand: undefined;
Expand All @@ -33,7 +34,8 @@ export class WorkbenchIssueService implements IWorkbenchIssueService {
@IWorkspaceTrustManagementService private readonly workspaceTrustManagementService: IWorkspaceTrustManagementService,
@IProductService private readonly productService: IProductService,
@IWorkbenchAssignmentService private readonly experimentService: IWorkbenchAssignmentService,
@IAuthenticationService private readonly authenticationService: IAuthenticationService
@IAuthenticationService private readonly authenticationService: IAuthenticationService,
@IIntegrityService private readonly integrityService: IIntegrityService
) { }

async openReporter(dataOverrides: Partial<IssueReporterData> = {}): Promise<void> {
Expand Down Expand Up @@ -82,13 +84,22 @@ export class WorkbenchIssueService implements IWorkbenchIssueService {
// Ignore
}

// air on the side of caution and have false be the default
let isUnsupported = false;
try {
isUnsupported = !(await this.integrityService.isPure()).isPure;
} catch (e) {
// Ignore
}

const theme = this.themeService.getColorTheme();
const issueReporterData: IssueReporterData = Object.assign({
styles: getIssueReporterStyles(theme),
zoomLevel: getZoomLevel(),
enabledExtensions: extensionData,
experiments: experiments?.join('\n'),
restrictedMode: !this.workspaceTrustManagementService.isWorkspaceTrusted(),
isUnsupported,
githubAccessToken,
}, dataOverrides);
return this.issueService.openReporter(issueReporterData);
Expand Down

0 comments on commit 8b475a0

Please sign in to comment.