Skip to content

Commit

Permalink
chore(trace-viewer): support opening a source location in embedded tr…
Browse files Browse the repository at this point in the history
…ace viewer (#32175)

Related: microsoft/playwright-vscode#513
  • Loading branch information
ruifigueira committed Aug 15, 2024
1 parent e7b7c71 commit b2ccfc3
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/trace-viewer/src/ui/embeddedWorkbenchLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ import { MultiTraceModel } from './modelUtil';
import './embeddedWorkbenchLoader.css';
import { Workbench } from './workbench';
import { currentTheme, toggleTheme } from '@web/theme';
import type { SourceLocation } from './modelUtil';

function openPage(url: string, target?: string) {
if (url)
window.parent!.postMessage({ command: 'openExternal', params: { url, target } }, '*');
window.parent!.postMessage({ method: 'openExternal', params: { url, target } }, '*');
}

function openSourceLocation({ file, line, column }: SourceLocation) {
window.parent!.postMessage({ method: 'openSourceLocation', params: { file, line, column } }, '*');
}

export const EmbeddedWorkbenchLoader: React.FunctionComponent = () => {
Expand Down Expand Up @@ -86,7 +91,7 @@ export const EmbeddedWorkbenchLoader: React.FunctionComponent = () => {
<div className='progress'>
<div className='inner-progress' style={{ width: progress.total ? (100 * progress.done / progress.total) + '%' : 0 }}></div>
</div>
<Workbench model={model} openPage={openPage} showSettings />
<Workbench model={model} openPage={openPage} onOpenExternally={openSourceLocation} showSettings />
{!traceURLs.length && <div className='empty-state'>
<div className='title'>Select test to see the trace</div>
</div>}
Expand Down

0 comments on commit b2ccfc3

Please sign in to comment.