-
Notifications
You must be signed in to change notification settings - Fork 33.4k
web reporter refactor and issueFormService #212951
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
adb6479
web version working
justschen 06c6cfb
change to mainWindow
justschen 202a62d
PROPER MOVEMENT
justschen ca1536c
working for web as well
justschen 17dfc9b
move issueFormService to workbench/contrib/issue
justschen fcb6ec7
cleaning up{
justschen c205607
more cleanup, added setting
justschen eb3f62d
styling
justschen 42171b1
use mainwindow to open and closee
justschen ed04565
css fixes
justschen 253381d
fix css again
justschen 4a7a4d1
fix CSS and wonky applyCSS rules
justschen 240eede
change gulpfile
justschen 28d56df
add and update system info
justschen 132b517
address some of the comments
justschen cd02d05
move files! small changes
justschen a73028d
move JS and non window specific back to electron sandbox
justschen 47da475
fix on issueReporter.js
justschen 6cbcc8b
fix build file
justschen 232a778
fix gulp file too....
justschen c47a4a9
move everything into contrib
justschen 7befb8c
fix workbench import
justschen 0dc832b
move everything else into contrib, fix import
justschen a19cc3b
change name to web
justschen 17234a1
applying more feedback fixes :D
justschen dd5d59b
fix command and remove unused import:
justschen e04236d
add back issueTroubleshoot
justschen 434be3e
fix gulpile outputs
justschen 61d4b25
fix out exclusion:
justschen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
180 changes: 180 additions & 0 deletions
180
src/vs/workbench/contrib/issue/browser/issueFormService.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import { safeInnerHtml } from 'vs/base/browser/dom'; | ||
import { mainWindow } from 'vs/base/browser/window'; | ||
import { DisposableStore } from 'vs/base/common/lifecycle'; | ||
import { URI } from 'vs/base/common/uri'; | ||
import BaseHtml from 'vs/workbench/contrib/issue/browser/issueReporterPage'; | ||
import 'vs/css!./media/issueReporter'; | ||
import { IMenuService, MenuId } from 'vs/platform/actions/common/actions'; | ||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; | ||
import { PerformanceInfo, SystemInfo } from 'vs/platform/diagnostics/common/diagnostics'; | ||
import { ExtensionIdentifier, ExtensionIdentifierSet } from 'vs/platform/extensions/common/extensions'; | ||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; | ||
import { IIssueMainService, IssueReporterData, ProcessExplorerData } from 'vs/platform/issue/common/issue'; | ||
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 class IssueFormService implements IIssueMainService { | ||
|
||
readonly _serviceBrand: undefined; | ||
|
||
private issueReporterWindow: Window | null = null; | ||
private extensionIdentifierSet: ExtensionIdentifierSet = new ExtensionIdentifierSet(); | ||
|
||
constructor( | ||
@IInstantiationService private readonly instantiationService: IInstantiationService, | ||
@IAuxiliaryWindowService private readonly auxiliaryWindowService: IAuxiliaryWindowService, | ||
@IMenuService private readonly menuService: IMenuService, | ||
@IContextKeyService private readonly contextKeyService: IContextKeyService, | ||
) { | ||
|
||
// listen for messages from the main window | ||
mainWindow.addEventListener('message', async (event) => { | ||
if (event.data && event.data.sendChannel === 'vscode:triggerReporterMenu') { | ||
// creates menu from contributed | ||
const menu = this.menuService.createMenu(MenuId.IssueReporter, this.contextKeyService); | ||
|
||
// render menu and dispose | ||
const actions = menu.getActions({ renderShortTitle: true }).flatMap(entry => entry[1]); | ||
for (const action of actions) { | ||
try { | ||
if (action.item && 'source' in action.item && action.item.source?.id === event.data.extensionId) { | ||
this.extensionIdentifierSet.add(event.data.extensionId); | ||
await action.run(); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
|
||
if (!this.extensionIdentifierSet.has(event.data.extensionId)) { | ||
// send undefined to indicate no action was taken | ||
const replyChannel = `vscode:triggerReporterMenuResponse`; | ||
mainWindow.postMessage({ replyChannel }, '*'); | ||
} | ||
|
||
menu.dispose(); | ||
} | ||
}); | ||
|
||
} | ||
|
||
async openReporter(data: IssueReporterData): Promise<void> { | ||
if (data.extensionId && this.extensionIdentifierSet.has(data.extensionId)) { | ||
const replyChannel = `vscode:triggerReporterMenuResponse`; | ||
mainWindow.postMessage({ data, replyChannel }, '*'); | ||
this.extensionIdentifierSet.delete(new ExtensionIdentifier(data.extensionId)); | ||
} | ||
|
||
if (this.issueReporterWindow) { | ||
this.issueReporterWindow.focus(); | ||
return; | ||
} | ||
|
||
const disposables = new DisposableStore(); | ||
|
||
// Auxiliary Window | ||
const auxiliaryWindow = disposables.add(await this.auxiliaryWindowService.open({ mode: AuxiliaryWindowMode.Normal })); | ||
|
||
this.issueReporterWindow = auxiliaryWindow.window; | ||
|
||
|
||
|
||
if (auxiliaryWindow) { | ||
await auxiliaryWindow.whenStylesHaveLoaded; | ||
auxiliaryWindow.window.document.title = 'Issue Reporter'; | ||
auxiliaryWindow.window.document.body.classList.add('issue-reporter-body'); | ||
|
||
// custom issue reporter wrapper | ||
const div = document.createElement('div'); | ||
div.classList.add('monaco-workbench'); | ||
|
||
// removes preset monaco-workbench | ||
auxiliaryWindow.container.remove(); | ||
auxiliaryWindow.window.document.body.appendChild(div); | ||
safeInnerHtml(div, BaseHtml()); | ||
|
||
// create issue reporter and instantiate | ||
const issueReporter = this.instantiationService.createInstance(IssueWebReporter, false, data, { type: '', arch: '', release: '' }, product, auxiliaryWindow.window); | ||
issueReporter.render(); | ||
} else { | ||
console.error('Failed to open auxiliary window'); | ||
} | ||
|
||
// handle closing issue reporter | ||
this.issueReporterWindow?.addEventListener('beforeunload', () => { | ||
auxiliaryWindow.window.close(); | ||
this.issueReporterWindow = null; | ||
}); | ||
} | ||
|
||
async openProcessExplorer(data: ProcessExplorerData): Promise<void> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
stopTracing(): Promise<void> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
getSystemStatus(): Promise<string> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
$getSystemInfo(): Promise<SystemInfo> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
$getPerformanceInfo(): Promise<PerformanceInfo> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
$reloadWithExtensionsDisabled(): Promise<void> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
$showConfirmCloseDialog(): Promise<void> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
$showClipboardDialog(): Promise<boolean> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
$getIssueReporterUri(extensionId: string): Promise<URI> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
$getIssueReporterData(extensionId: string): Promise<string> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
$getIssueReporterTemplate(extensionId: string): Promise<string> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
$getReporterStatus(extensionId: string, extensionName: string): Promise<boolean[]> { | ||
throw new Error('Method not implemented.'); | ||
} | ||
|
||
justschen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
async $sendReporterMenu(extensionId: string, extensionName: string): Promise<IssueReporterData | undefined> { | ||
const sendChannel = `vscode:triggerReporterMenu`; | ||
mainWindow.postMessage({ sendChannel, extensionId, extensionName }, '*'); | ||
|
||
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:triggerReporterMenuResponse`; | ||
if (event.data && event.data.replyChannel === replyChannel) { | ||
clearTimeout(timeout); | ||
mainWindow.removeEventListener('message', listener); | ||
resolve(event.data.data); | ||
} | ||
}; | ||
mainWindow.addEventListener('message', listener); | ||
}); | ||
|
||
return result as IssueReporterData | undefined; | ||
} | ||
|
||
async $closeReporter(): Promise<void> { | ||
this.issueReporterWindow?.close(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.