mirror of
				https://github.com/microsoft/playwright.git
				synced 2025-06-26 21:40:17 +00:00 
			
		
		
		
	chore: render sidebar tab selector as drop down (#27844)
This commit is contained in:
		
							parent
							
								
									4d82d6801f
								
							
						
					
					
						commit
						462e70ab82
					
				| @ -129,8 +129,13 @@ const NetworkResource: React.FunctionComponent<{ | |||||||
| }> = ({ resource, boundaries }) => { | }> = ({ resource, boundaries }) => { | ||||||
|   const { routeStatus, resourceName, contentType } = React.useMemo(() => { |   const { routeStatus, resourceName, contentType } = React.useMemo(() => { | ||||||
|     const routeStatus = formatRouteStatus(resource); |     const routeStatus = formatRouteStatus(resource); | ||||||
|  |     let resourceName: string; | ||||||
|  |     try { | ||||||
|       const url = new URL(resource.request.url); |       const url = new URL(resource.request.url); | ||||||
|     const resourceName = url.pathname; |       resourceName = url.pathname; | ||||||
|  |     } catch { | ||||||
|  |       resourceName = resource.request.url; | ||||||
|  |     } | ||||||
|     let contentType = resource.response.content.mimeType; |     let contentType = resource.response.content.mimeType; | ||||||
|     const charset = contentType.match(/^(.*);\s*charset=.*$/); |     const charset = contentType.match(/^(.*);\s*charset=.*$/); | ||||||
|     if (charset) |     if (charset) | ||||||
|  | |||||||
| @ -278,6 +278,7 @@ export const Workbench: React.FunctionComponent<{ | |||||||
|               setSidebarLocation('bottom'); |               setSidebarLocation('bottom'); | ||||||
|             }} /> |             }} /> | ||||||
|         ]} |         ]} | ||||||
|  |         mode={sidebarLocation === 'bottom' ? 'default' : 'select'} | ||||||
|       /> |       /> | ||||||
|     </SplitView> |     </SplitView> | ||||||
|   </div>; |   </div>; | ||||||
|  | |||||||
| @ -34,14 +34,17 @@ export const TabbedPane: React.FunctionComponent<{ | |||||||
|   selectedTab: string, |   selectedTab: string, | ||||||
|   setSelectedTab: (tab: string) => void, |   setSelectedTab: (tab: string) => void, | ||||||
|   dataTestId?: string, |   dataTestId?: string, | ||||||
| }> = ({ tabs, selectedTab, setSelectedTab, leftToolbar, rightToolbar, dataTestId }) => { |   mode?: 'default' | 'select', | ||||||
|  | }> = ({ tabs, selectedTab, setSelectedTab, leftToolbar, rightToolbar, dataTestId, mode }) => { | ||||||
|  |   if (!mode) | ||||||
|  |     mode = 'default'; | ||||||
|   return <div className='tabbed-pane' data-testid={dataTestId}> |   return <div className='tabbed-pane' data-testid={dataTestId}> | ||||||
|     <div className='vbox'> |     <div className='vbox'> | ||||||
|       <Toolbar> |       <Toolbar> | ||||||
|         { leftToolbar && <div style={{ flex: 'none', display: 'flex', margin: '0 4px', alignItems: 'center' }}> |         { leftToolbar && <div style={{ flex: 'none', display: 'flex', margin: '0 4px', alignItems: 'center' }}> | ||||||
|           {...leftToolbar} |           {...leftToolbar} | ||||||
|         </div>} |         </div>} | ||||||
|         <div style={{ flex: 'auto', display: 'flex', height: '100%', overflow: 'hidden' }}> |         {mode === 'default' && <div style={{ flex: 'auto', display: 'flex', height: '100%', overflow: 'hidden' }}> | ||||||
|           {[...tabs.map(tab => ( |           {[...tabs.map(tab => ( | ||||||
|             <TabbedPaneTab |             <TabbedPaneTab | ||||||
|               id={tab.id} |               id={tab.id} | ||||||
| @ -52,7 +55,25 @@ export const TabbedPane: React.FunctionComponent<{ | |||||||
|               onSelect={setSelectedTab} |               onSelect={setSelectedTab} | ||||||
|             ></TabbedPaneTab>)), |             ></TabbedPaneTab>)), | ||||||
|           ]} |           ]} | ||||||
|         </div> |         </div>} | ||||||
|  |         {mode === 'select' && <div style={{ flex: 'auto', display: 'flex', height: '100%', overflow: 'hidden' }}> | ||||||
|  |           <select style={{width: '100%', background: 'none', cursor: 'pointer'}} onChange={e => { | ||||||
|  |             setSelectedTab(tabs[e.currentTarget.selectedIndex].id); | ||||||
|  |           }}> | ||||||
|  |             {tabs.map(tab => { | ||||||
|  |               let suffix = ''; | ||||||
|  |               if (tab.count === 1) | ||||||
|  |                 suffix = ' 🔵'; | ||||||
|  |               else if (tab.count) | ||||||
|  |                 suffix = ` 🔵✖️${tab.count}`; | ||||||
|  |               if (tab.errorCount === 1) | ||||||
|  |                 suffix = ` 🔴`; | ||||||
|  |               else if (tab.errorCount) | ||||||
|  |                 suffix = ` 🔴✖️${tab.errorCount}`; | ||||||
|  |               return <option value={tab.id} selected={tab.id === selectedTab}>{tab.title}{suffix}</option>; | ||||||
|  |             })} | ||||||
|  |           </select> | ||||||
|  |         </div>} | ||||||
|         {rightToolbar && <div style={{ flex: 'none', display: 'flex', alignItems: 'center' }}> |         {rightToolbar && <div style={{ flex: 'none', display: 'flex', alignItems: 'center' }}> | ||||||
|           {...rightToolbar} |           {...rightToolbar} | ||||||
|         </div>} |         </div>} | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Pavel Feldman
						Pavel Feldman