Merge branch 'master' into rmacfarlane/disable-extensions

This commit is contained in:
Benjamin Pasero
2018-02-21 06:42:11 +01:00
committed by GitHub
488 changed files with 7967 additions and 4536 deletions

View File

@@ -66,8 +66,7 @@ export class IssueReporter extends Disposable {
private telemetryService: ITelemetryService;
private logService: ILogService;
private issueReporterModel: IssueReporterModel;
private shouldQueueSearch = true;
private features: IssueReporterFeatures;
private numberOfSearchResultsDisplayed = 0;
private receivedSystemInfo = false;
private receivedPerformanceInfo = false;
@@ -85,8 +84,6 @@ export class IssueReporter extends Disposable {
extensionsDisabled: this.environmentService.disableExtensions,
});
this.features = configuration.features;
ipcRenderer.on('issuePerformanceInfoResponse', (event, info) => {
this.logService.trace('issueReporter: Received performance data');
this.issueReporterModel.update(info);
@@ -187,15 +184,15 @@ export class IssueReporter extends Disposable {
}
if (styles.sliderBackgroundColor) {
content.push(`.issues-container::-webkit-scrollbar-thumb, body::-webkit-scrollbar-thumb { background-color: ${styles.sliderBackgroundColor}; }`);
content.push(`::-webkit-scrollbar-thumb { background-color: ${styles.sliderBackgroundColor}; }`);
}
if (styles.sliderActiveColor) {
content.push(`.issues-container::-webkit-scrollbar-thumb:active, body::-webkit-scrollbar-thumb:active { background-color: ${styles.sliderActiveColor}; }`);
content.push(`::-webkit-scrollbar-thumb:active { background-color: ${styles.sliderActiveColor}; }`);
}
if (styles.sliderHoverColor) {
content.push(`.issues-container::-webkit-scrollbar-thumb:hover, body::-webkit-scrollbar-thumb:hover { background-color: ${styles.sliderHoverColor}; }`);
content.push(`::--webkit-scrollbar-thumb:hover { background-color: ${styles.sliderHoverColor}; }`);
}
styleTag.innerHTML = content.join('\n');
@@ -337,13 +334,23 @@ export class IssueReporter extends Disposable {
const issueDescription = (<HTMLInputElement>event.target).value;
this.issueReporterModel.update({ issueDescription });
if (this.features.useDuplicateSearch) {
const title = (<HTMLInputElement>document.getElementById('issue-title')).value;
const title = (<HTMLInputElement>document.getElementById('issue-title')).value;
if (title || issueDescription) {
this.searchDuplicates(title, issueDescription);
} else {
this.clearSearchResults();
}
});
document.getElementById('issue-title').addEventListener('input', (e) => { this.searchIssues(e); });
document.getElementById('issue-title').addEventListener('input', (e) => {
const description = this.issueReporterModel.getData().issueDescription;
const title = (<HTMLInputElement>event.target).value;
if (title || description) {
this.searchDuplicates(title, description);
} else {
this.clearSearchResults();
}
});
document.getElementById('github-submit-btn').addEventListener('click', () => this.createIssue());
@@ -425,24 +432,10 @@ export class IssueReporter extends Disposable {
return false;
}
@debounce(300)
private searchIssues(event: Event): void {
const title = (<HTMLInputElement>event.target).value;
if (title) {
if (this.features.useDuplicateSearch) {
const description = this.issueReporterModel.getData().issueDescription;
this.searchDuplicates(title, description);
} else {
this.searchGitHub(title);
}
} else {
this.clearSearchResults();
}
}
private clearSearchResults(): void {
const similarIssues = document.getElementById('similar-issues');
similarIssues.innerHTML = '';
this.numberOfSearchResultsDisplayed = 0;
}
@debounce(300)
@@ -476,53 +469,17 @@ export class IssueReporter extends Disposable {
});
}
private searchGitHub(title: string): void {
const query = `is:issue+repo:microsoft/vscode+${title}`;
const similarIssues = document.getElementById('similar-issues');
window.fetch(`https://api.github.com/search/issues?q=${query}`).then((response) => {
response.json().then(result => {
similarIssues.innerHTML = '';
if (result && result.items) {
this.displaySearchResults(result.items);
} else {
// If the items property isn't present, the rate limit has been hit
const message = $('div.list-title');
message.textContent = localize('rateLimited', "GitHub query limit exceeded. Please wait.");
similarIssues.appendChild(message);
const resetTime = response.headers.get('X-RateLimit-Reset');
const timeToWait = parseInt(resetTime) - Math.floor(Date.now() / 1000);
if (this.shouldQueueSearch) {
this.shouldQueueSearch = false;
setTimeout(() => {
this.searchGitHub(title);
this.shouldQueueSearch = true;
}, timeToWait * 1000);
}
throw new Error(result.message);
}
}).catch((error) => {
this.logSearchError(error);
});
}).catch((error) => {
this.logSearchError(error);
});
}
private displaySearchResults(results: SearchResult[]) {
const similarIssues = document.getElementById('similar-issues');
if (results.length) {
const hasIssueState = results.every(result => !!result.state);
const issues = hasIssueState ? $('div.issues-container') : $('ul.issues-container');
const issues = $('div.issues-container');
const issuesText = $('div.list-title');
issuesText.textContent = localize('similarIssues', "Similar issues");
const numResultsToDisplay = results.length < 5 ? results.length : 5;
for (let i = 0; i < numResultsToDisplay; i++) {
this.numberOfSearchResultsDisplayed = results.length < 5 ? results.length : 5;
for (let i = 0; i < this.numberOfSearchResultsDisplayed; i++) {
const issue = results[i];
const link = issue.state ? $('a.issue-link', { href: issue.html_url }) : $('a', { href: issue.html_url });
const link = $('a.issue-link', { href: issue.html_url });
link.textContent = issue.title;
link.title = issue.title;
link.addEventListener('click', (e) => this.openLink(e));
@@ -544,7 +501,7 @@ export class IssueReporter extends Disposable {
issueState.appendChild(issueStateLabel);
}
const item = issue.state ? $('div.issue', {}, issueState, link) : $('li.issue', {}, link);
const item = $('div.issue', {}, issueState, link);
issues.appendChild(item);
}
@@ -561,7 +518,7 @@ export class IssueReporter extends Disposable {
this.logService.warn('issueReporter#search ', error.message);
/* __GDPR__
"issueReporterSearchError" : {
"message" : { "classification": "SystemMetaData", "purpose": "PerformanceAndHealth" }
"message" : { "classification": "CallstackOrException", "purpose": "PerformanceAndHealth" }
}
*/
this.telemetryService.publicLog('issueReporterSearchError', { message: error.message });
@@ -675,14 +632,13 @@ export class IssueReporter extends Disposable {
return false;
}
if (this.telemetryService) {
/* __GDPR__
"issueReporterSubmit" : {
"issueType" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
this.telemetryService.publicLog('issueReporterSubmit', { issueType: this.issueReporterModel.getData().issueType });
}
/* __GDPR__
"issueReporterSubmit" : {
"issueType" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"numSimilarIssuesDisplayed" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
this.telemetryService.publicLog('issueReporterSubmit', { issueType: this.issueReporterModel.getData().issueType, numSimilarIssuesDisplayed: this.numberOfSearchResultsDisplayed });
const issueTitle = encodeURIComponent((<HTMLInputElement>document.getElementById('issue-title')).value);
const queryStringPrefix = product.reportIssueUrl.indexOf('?') === -1 ? '?' : '&';
@@ -804,11 +760,9 @@ export class IssueReporter extends Disposable {
shell.openExternal((<HTMLAnchorElement>event.target).href);
/* __GDPR__
"issueReporterViewSimilarIssue" : {
"usingDuplicatesAPI" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
"issueReporterViewSimilarIssue" : { }
*/
this.telemetryService.publicLog('issueReporterViewSimilarIssue', { usingDuplicatesAPI: this.features.useDuplicateSearch });
this.telemetryService.publicLog('issueReporterViewSimilarIssue');
}
}
}