Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move trace viewer to the src/web (#5199)
- Loading branch information
1 parent
01bddcd
commit 8d8fa4c
Showing
49 changed files
with
919 additions
and
52 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,16 +1,14 @@ | ||
import { addDecorator } from '@storybook/react'; | ||
import { GlobalStyles } from '../src/cli/traceViewer/web/styles'; | ||
import { applyTheme } from '../src/cli/traceViewer/web/theme'; | ||
import '../src/web/common.css'; | ||
import { applyTheme } from '../src/web/theme'; | ||
|
||
export const parameters = { | ||
actions: { argTypesRegex: "^on[A-Z].*" }, | ||
} | ||
|
||
|
||
addDecorator(storyFn => { | ||
applyTheme(); | ||
return <div style={{backgroundColor: 'var(--background)'}}> | ||
<GlobalStyles /> | ||
{storyFn()} | ||
</div> | ||
}); |
This file contains 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 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 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,36 @@ | ||
/* | ||
Copyright (c) Microsoft Corporation. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
.pw-source { | ||
white-space: pre; | ||
overflow: auto; | ||
font-family: var(--monospace-font); | ||
font-size: 11px; | ||
line-height: 16px; | ||
background: white; | ||
} | ||
|
||
.pw-source-line { | ||
display: flex; | ||
} | ||
|
||
.pw-source-line-number { | ||
padding: 0 8px; | ||
width: 30px; | ||
text-align: right; | ||
background: #edebe9; | ||
user-select: none; | ||
} |
This file contains 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,100 @@ | ||
/* | ||
Copyright (c) Microsoft Corporation. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import { Story, Meta } from '@storybook/react/types-6-0'; | ||
import React from 'react'; | ||
import { Source, SourceProps } from './source'; | ||
|
||
export default { | ||
title: 'Components/Source', | ||
component: Source, | ||
} as Meta; | ||
|
||
const Template: Story<SourceProps> = args => <Source {...args} />; | ||
|
||
export const Primary = Template.bind({}); | ||
Primary.args = { | ||
text: `const { chromium, devices } = require('.'); | ||
(async () => { | ||
const browser = await chromium.launch({ | ||
headless: false | ||
}); | ||
const context = await browser.newContext({ | ||
// ...devices['iPhone 11'] | ||
}); | ||
// Open new page | ||
const page = await context.newPage(); | ||
// Go to https://github.com/microsoft | ||
await page.goto('https://github.com/microsoft'); | ||
await page._pause(); | ||
// Click input[aria-label="Find a repository…"] | ||
await page.click('input[aria-label="Find a repository…"]'); | ||
// Fill input[aria-label="Find a repository…"] | ||
await Promise.all([ | ||
page.waitForNavigation(/*{ url: 'https://github.com/microsoft?q=playwright&type=&language=' }*/), | ||
page.fill('input[aria-label="Find a repository…"]', 'playwright') | ||
]); | ||
// Click //a[normalize-space(.)='playwright'] | ||
await page.click('//a[normalize-space(.)=\'playwright\']'); | ||
// assert.equal(page.url(), 'https://github.com/microsoft/playwright'); | ||
// Click text="Issues" | ||
await Promise.all([ | ||
page.waitForNavigation(/*{ url: 'https://github.com/microsoft/playwright/issues' }*/), | ||
page.click('text="Issues"') | ||
]); | ||
// Click text="triaging" | ||
await Promise.all([ | ||
page.waitForNavigation(/*{ url: 'https://github.com/microsoft/playwright/issues?q=is:issue+is:open+label:triaging' }*/), | ||
page.click('text="triaging"') | ||
]); | ||
// Click text=/.*\[BUG\]\[Electron\] page\.waitForSe.*/ | ||
await Promise.all([ | ||
page.waitForNavigation(/*{ url: 'https://github.com/microsoft/playwright/issues/4961' }*/), | ||
page.click('text=/.*\\\[BUG\\\]\\\[Electron\\\] page\.waitForSe.*/') | ||
]); | ||
await page._pause(); | ||
// Click div[id="partial-users-participants"] img[alt="@pavelfeldman"] | ||
await page.click('div[id="partial-users-participants"] img[alt="@pavelfeldman"]'); | ||
// assert.equal(page.url(), 'https://github.com/pavelfeldman'); | ||
await page._pause(); | ||
// Click text=/.*Repositories.*/ | ||
await Promise.all([ | ||
page.waitForNavigation(/*{ url: 'https://github.com/pavelfeldman?tab=repositories' }*/), | ||
page.click('text=/.*Repositories.*/') | ||
]); | ||
await page._pause(); | ||
// Click text=/.*playwright.*/ | ||
await page.click('text=/.*playwright.*/'); | ||
// assert.equal(page.url(), 'https://github.com/pavelfeldman/playwright'); | ||
await page._pause(); | ||
// --------------------- | ||
await context.close(); | ||
await browser.close(); | ||
})();` | ||
}; |
This file contains 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,46 @@ | ||
/* | ||
Copyright (c) Microsoft Corporation. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import './source.css'; | ||
import * as React from 'react'; | ||
import highlightjs from '../../third_party/highlightjs/highlightjs'; | ||
import '../../third_party/highlightjs/highlightjs/tomorrow.css'; | ||
|
||
export interface SourceProps { | ||
text: string, | ||
targetLine: number | ||
} | ||
|
||
export const Source: React.FC<SourceProps> = ({ | ||
text = '', | ||
}) => { | ||
const result = []; | ||
let continuation: any; | ||
for (const line of text.split('\n')) { | ||
const highlighted = highlightjs.highlight('javascript', line, true, continuation); | ||
continuation = highlighted.top; | ||
result.push(highlighted.value); | ||
} | ||
|
||
return <div className='pw-source'>{ | ||
result.map((markup, index) => { | ||
return <div key={index} className='pw-source-line'> | ||
<div className='pw-source-line-number'>{index + 1}</div> | ||
<div className='pw-source-code' dangerouslySetInnerHTML={{ __html: markup }}></div> | ||
</div>; | ||
}) | ||
}</div> | ||
}; |
This file contains 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,23 @@ | ||
/* | ||
Copyright (c) Microsoft Corporation. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
.pw-toolbar { | ||
box-shadow: rgba(0, 0, 0, 0.1) 0px -1px 0px 0px inset; | ||
background: rgb(255, 255, 255); | ||
height: 40px; | ||
align-items: center; | ||
padding-right: 10px; | ||
} |
Oops, something went wrong.