Skip to content

Commit

Permalink
chore: nicer network grid header (microsoft#27102)
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman authored and Germandrummer92 committed Oct 27, 2023
1 parent 2391722 commit dcfd2d6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
19 changes: 17 additions & 2 deletions packages/trace-viewer/src/ui/networkResourceDetails.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
limitations under the License.
*/

.network-request-details {
.network-request-details-tab {
width: 100%;
user-select: text;
line-height: 24px;
Expand All @@ -39,6 +39,21 @@
font-weight: bold;
}

.network-request-details .cm-wrapper {
.network-request-details-tab .cm-wrapper {
overflow: hidden;
}

.tab-network .toolbar {
margin-top: 3px !important;
min-height: 30px !important;
background-color: initial !important;
border-bottom: 1px solid var(--vscode-panel-border);
}

.tab-network .toolbar::after {
box-shadow: none !important;
}

.tab-network .tabbed-pane-tab.selected {
font-weight: bold;
}
11 changes: 7 additions & 4 deletions packages/trace-viewer/src/ui/networkResourceDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ export const NetworkResourceDetails: React.FunctionComponent<{

return <TabbedPane
dataTestId='network-request-details'
leftToolbar={[<ToolbarButton icon='arrow-left' title='Back' onClick={onClose}></ToolbarButton>]}
leftToolbar={[
<ToolbarButton icon='arrow-left' title='Back' onClick={onClose}></ToolbarButton>,
<div style={{ width: 30 }}></div>
]}
rightToolbar={[<ToolbarButton icon='close' title='Close' onClick={onClose}></ToolbarButton>]}
tabs={[
{
Expand Down Expand Up @@ -75,7 +78,7 @@ const RequestTab: React.FunctionComponent<{
readResources();
}, [resource]);

return <div className='network-request-details'>
return <div className='network-request-details-tab'>
<div className='network-request-details-header'>URL</div>
<div className='network-request-details-url'>{resource.request.url}</div>
<div className='network-request-details-header'>Request Headers</div>
Expand All @@ -88,7 +91,7 @@ const RequestTab: React.FunctionComponent<{
const ResponseTab: React.FunctionComponent<{
resource: ResourceSnapshot;
}> = ({ resource }) => {
return <div className='network-request-details'>
return <div className='network-request-details-tab'>
<div className='network-request-details-header'>Response Headers</div>
<div className='network-request-details-headers'>{resource.response.headers.map(pair => `${pair.name}: ${pair.value}`).join('\n')}</div>
</div>;
Expand Down Expand Up @@ -121,7 +124,7 @@ const BodyTab: React.FunctionComponent<{
readResources();
}, [resource]);

return <div className='network-request-details'>
return <div className='network-request-details-tab'>
{!resource.response.content._sha1 && <div>Response body is not available for this request.</div>}
{responseBody && responseBody.dataUrl && <img draggable='false' src={responseBody.dataUrl} />}
{responseBody && responseBody.text && <CodeMirrorWrapper text={responseBody.text} language={responseBody.language} readOnly lineNumbers={true}/>}
Expand Down
3 changes: 2 additions & 1 deletion packages/trace-viewer/src/ui/networkTab.css
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
}

.network-request-header {
height: 28px;
margin-top: 3px;
height: 30px;
border-bottom: 1px solid var(--vscode-panel-border);
flex: none;
align-items: center;
Expand Down
5 changes: 3 additions & 2 deletions packages/web/src/components/tabbedPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ export const TabbedPane: React.FunctionComponent<{
</Toolbar>
{
tabs.map(tab => {
const className = 'tab-content tab-' + tab.id;
if (tab.component)
return <div key={tab.id} className='tab-content' style={{ display: selectedTab === tab.id ? 'inherit' : 'none' }}>{tab.component}</div>;
return <div key={tab.id} className={className} style={{ display: selectedTab === tab.id ? 'inherit' : 'none' }}>{tab.component}</div>;
if (selectedTab === tab.id)
return <div key={tab.id} className='tab-content'>{tab.render!()}</div>;
return <div key={tab.id} className={className}>{tab.render!()}</div>;
})
}
</div>
Expand Down

0 comments on commit dcfd2d6

Please sign in to comment.