1414 limitations under the License.
1515*/
1616
17- import type { ActionTraceEvent , AfterActionTraceEventAttachment } from '@trace/trace' ;
17+ import type { ActionTraceEvent } from '@trace/trace' ;
1818import { clsx , msToString } from '@web/uiUtils' ;
1919import * as React from 'react' ;
2020import './actionList.css' ;
@@ -34,11 +34,13 @@ export interface ActionListProps {
3434 selectedAction : ActionTraceEventInContext | undefined ,
3535 selectedTime : Boundaries | undefined ,
3636 setSelectedTime : ( time : Boundaries | undefined ) => void ,
37+ treeState : TreeState ,
38+ setTreeState : ( treeState : TreeState ) => void ,
3739 sdkLanguage : Language | undefined ;
3840 onSelected ?: ( action : ActionTraceEventInContext ) => void ,
3941 onHighlighted ?: ( action : ActionTraceEventInContext | undefined ) => void ,
4042 revealConsole ?: ( ) => void ,
41- revealAttachment ( attachment : AfterActionTraceEventAttachment ) : void ,
43+ revealActionAttachment ? ( callId : string ) : void ,
4244 isLive ?: boolean ,
4345}
4446
@@ -49,14 +51,15 @@ export const ActionList: React.FC<ActionListProps> = ({
4951 selectedAction,
5052 selectedTime,
5153 setSelectedTime,
54+ treeState,
55+ setTreeState,
5256 sdkLanguage,
5357 onSelected,
5458 onHighlighted,
5559 revealConsole,
56- revealAttachment ,
60+ revealActionAttachment ,
5761 isLive,
5862} ) => {
59- const [ treeState , setTreeState ] = React . useState < TreeState > ( { expandedItems : new Map ( ) } ) ;
6063 const { rootItem, itemMap } = React . useMemo ( ( ) => modelUtil . buildActionTree ( actions ) , [ actions ] ) ;
6164
6265 const { selectedItem } = React . useMemo ( ( ) => {
@@ -73,8 +76,9 @@ export const ActionList: React.FC<ActionListProps> = ({
7376 } , [ setSelectedTime ] ) ;
7477
7578 const render = React . useCallback ( ( item : ActionTreeItem ) => {
76- return renderAction ( item . action ! , { sdkLanguage, revealConsole, revealAttachment, isLive, showDuration : true , showBadges : true } ) ;
77- } , [ isLive , revealConsole , revealAttachment , sdkLanguage ] ) ;
79+ const showAttachments = ! ! revealActionAttachment && ! ! item . action ?. attachments ?. length ;
80+ return renderAction ( item . action ! , { sdkLanguage, revealConsole, revealActionAttachment : ( ) => revealActionAttachment ?.( item . action ! . callId ) , isLive, showDuration : true , showBadges : true , showAttachments } ) ;
81+ } , [ isLive , revealConsole , revealActionAttachment , sdkLanguage ] ) ;
7882
7983 const isVisible = React . useCallback ( ( item : ActionTreeItem ) => {
8084 return ! selectedTime || ! item . action || ( item . action ! . startTime <= selectedTime . maximum && item . action ! . endTime >= selectedTime . minimum ) ;
@@ -111,14 +115,14 @@ export const renderAction = (
111115 options : {
112116 sdkLanguage ?: Language ,
113117 revealConsole ?: ( ) => void ,
114- revealAttachment ? ( attachment : AfterActionTraceEventAttachment ) : void ,
118+ revealActionAttachment ? ( ) : void ,
115119 isLive ?: boolean ,
116120 showDuration ?: boolean ,
117121 showBadges ?: boolean ,
122+ showAttachments ?: boolean ,
118123 } ) => {
119- const { sdkLanguage, revealConsole, revealAttachment , isLive, showDuration, showBadges } = options ;
124+ const { sdkLanguage, revealConsole, revealActionAttachment , isLive, showDuration, showBadges, showAttachments } = options ;
120125 const { errors, warnings } = modelUtil . stats ( action ) ;
121- const showAttachments = ! ! action . attachments ?. length && ! ! revealAttachment ;
122126
123127 const locator = action . params . selector ? asLocatorDescription ( sdkLanguage || 'javascript' , action . params . selector ) : undefined ;
124128
@@ -135,7 +139,7 @@ export const renderAction = (
135139 < div className = 'hbox' >
136140 < span className = 'action-title-method' title = { title } > { elements } </ span >
137141 { ( showDuration || showBadges || showAttachments || isSkipped ) && < div className = 'spacer' > </ div > }
138- { showAttachments && < ToolbarButton icon = 'attach' title = 'Open Attachment' onClick = { ( ) => revealAttachment ( action . attachments ! [ 0 ] ) } /> }
142+ { showAttachments && < ToolbarButton icon = 'attach' title = 'Open Attachment' onClick = { ( ) => revealActionAttachment ?. ( ) } /> }
139143 { showDuration && ! isSkipped && < div className = 'action-duration' > { time || < span className = 'codicon codicon-loading' > </ span > } </ div > }
140144 { isSkipped && < span className = { clsx ( 'action-skipped' , 'codicon' , testStatusIcon ( 'skipped' ) ) } title = 'skipped' > </ span > }
141145 { showBadges && < div className = 'action-icons' onClick = { ( ) => revealConsole ?.( ) } >
0 commit comments