mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-13 05:01:08 +01:00
issue reporter re-open save state (#213418)
if anything is typed and we call open reporter again, saves issue title and data
This commit is contained in:
@@ -336,6 +336,14 @@ export class BaseIssueReporterService extends Disposable {
|
||||
}
|
||||
});
|
||||
|
||||
this.addEventListener('issue-title', 'input', _ => {
|
||||
const titleElement = this.getElementById('issue-title') as HTMLInputElement;
|
||||
if (titleElement) {
|
||||
const title = titleElement.value;
|
||||
this.issueReporterModel.update({ issueTitle: title });
|
||||
}
|
||||
});
|
||||
|
||||
this.addEventListener('issue-title', 'input', (e: Event) => {
|
||||
const title = (<HTMLInputElement>e.target).value;
|
||||
const lengthValidationMessage = this.getElementById('issue-title-length-validation-error');
|
||||
|
||||
@@ -18,6 +18,11 @@ import product from 'vs/platform/product/common/product';
|
||||
import { IssueWebReporter } from 'vs/workbench/contrib/issue/browser/issueReporterService';
|
||||
import { AuxiliaryWindowMode, IAuxiliaryWindowService } from 'vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService';
|
||||
|
||||
export interface IssuePassData {
|
||||
issueTitle: string;
|
||||
issueBody: string;
|
||||
}
|
||||
|
||||
export class IssueFormService implements IIssueMainService {
|
||||
|
||||
readonly _serviceBrand: undefined;
|
||||
@@ -71,10 +76,26 @@ export class IssueFormService implements IIssueMainService {
|
||||
}
|
||||
|
||||
if (this.issueReporterWindow) {
|
||||
const getModelData = await this.getIssueData();
|
||||
if (getModelData) {
|
||||
const { issueTitle, issueBody } = getModelData;
|
||||
if (issueTitle || issueBody) {
|
||||
data.issueTitle = data.issueTitle ?? issueTitle;
|
||||
data.issueBody = data.issueBody ?? issueBody;
|
||||
|
||||
// close issue reporter and re-open with new data
|
||||
this.issueReporterWindow.close();
|
||||
this.openAuxIssueReporter(data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.issueReporterWindow.focus();
|
||||
return;
|
||||
}
|
||||
this.openAuxIssueReporter(data);
|
||||
}
|
||||
|
||||
async openAuxIssueReporter(data: IssueReporterData): Promise<void> {
|
||||
const disposables = new DisposableStore();
|
||||
|
||||
// Auxiliary Window
|
||||
@@ -82,8 +103,6 @@ export class IssueFormService implements IIssueMainService {
|
||||
|
||||
this.issueReporterWindow = auxiliaryWindow.window;
|
||||
|
||||
|
||||
|
||||
if (auxiliaryWindow) {
|
||||
await auxiliaryWindow.whenStylesHaveLoaded;
|
||||
auxiliaryWindow.window.document.title = 'Issue Reporter';
|
||||
@@ -174,6 +193,31 @@ export class IssueFormService implements IIssueMainService {
|
||||
return result as IssueReporterData | undefined;
|
||||
}
|
||||
|
||||
// Listens to data from the issue reporter model, which is updated regularly
|
||||
async getIssueData(): Promise<IssuePassData | undefined> {
|
||||
const sendChannel = `vscode:triggerIssueData`;
|
||||
mainWindow.postMessage({ sendChannel }, '*');
|
||||
|
||||
const result = await new Promise((resolve, reject) => {
|
||||
const timeout = setTimeout(() => {
|
||||
mainWindow.removeEventListener('message', listener);
|
||||
reject(new Error('Timeout exceeded'));
|
||||
}, 5000); // Set the timeout value in milliseconds (e.g., 5000 for 5 seconds)
|
||||
|
||||
const listener = (event: MessageEvent) => {
|
||||
const replyChannel = `vscode:triggerIssueDataResponse`;
|
||||
if (event.data && event.data.replyChannel === replyChannel) {
|
||||
clearTimeout(timeout);
|
||||
mainWindow.removeEventListener('message', listener);
|
||||
resolve(event.data.data);
|
||||
}
|
||||
};
|
||||
mainWindow.addEventListener('message', listener);
|
||||
});
|
||||
|
||||
return result as IssuePassData | undefined;
|
||||
}
|
||||
|
||||
async $closeReporter(): Promise<void> {
|
||||
this.issueReporterWindow?.close();
|
||||
}
|
||||
|
||||
@@ -3,12 +3,14 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { mainWindow } from 'vs/base/browser/window';
|
||||
import { isRemoteDiagnosticError, SystemInfo } from 'vs/platform/diagnostics/common/diagnostics';
|
||||
import { ISettingSearchResult, IssueReporterExtensionData, IssueType } from 'vs/platform/issue/common/issue';
|
||||
|
||||
export interface IssueReporterData {
|
||||
issueType: IssueType;
|
||||
issueDescription?: string;
|
||||
issueTitle?: string;
|
||||
extensionData?: string;
|
||||
|
||||
versionInfo?: any;
|
||||
@@ -56,6 +58,15 @@ export class IssueReporterModel {
|
||||
};
|
||||
|
||||
this._data = initialData ? Object.assign(defaultData, initialData) : defaultData;
|
||||
|
||||
mainWindow.addEventListener('message', async (event) => {
|
||||
if (event.data && event.data.sendChannel === 'vscode:triggerIssueData') {
|
||||
mainWindow.postMessage({
|
||||
data: { issueBody: this._data.issueDescription, issueTitle: this._data.issueTitle },
|
||||
replyChannel: 'vscode:triggerIssueDataResponse'
|
||||
}, '*');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getData(): IssueReporterData {
|
||||
|
||||
Reference in New Issue
Block a user