@@ -14,69 +14,46 @@ const resetSlider = () => {
14
14
15
15
function ActionContainer ( ) {
16
16
const [ { tabs, currentTab } , dispatch ] = useStoreContext ( ) ;
17
- const { hierarchy, snapshots , sliderIndex, viewIndex } = tabs [ currentTab ] ;
17
+ const { hierarchy, sliderIndex, viewIndex } = tabs [ currentTab ] ;
18
18
console . log ( 'actionContainer tabs[currentTab];' , tabs [ currentTab ] )
19
- console . log ( 'actionContainer snapshots;' , snapshots )
20
19
21
20
let actionsArr = [ ] ;
22
- // build actions array
23
- if ( snapshots . length > 0 ) {
24
- // breadth first function - take in an delta obj
25
- function breadthFirst ( delta ) {
26
- if ( delta === undefined ) return '' ;
27
- // aux array = current and one called next
28
- let current = Object . values ( delta . children ) ; // Object.keys(delta.children);
29
- let next = [ ] ;
30
- let result = '' ;
31
- // return a string
32
- while ( current . length > 0 ) {
33
- const shifted = current . shift ( ) ;
34
- if ( shifted . state ) {
35
- // eslint-disable-next-line no-loop-func
36
- Object . keys ( shifted . state ) . forEach ( key => {
37
- result = result . concat ( key , ', ' ) ;
38
- } ) ;
39
- }
40
- if ( shifted . children ) {
41
- // eslint-disable-next-line no-loop-func
42
- Object . keys ( shifted . children ) . forEach ( el => {
43
- next . push ( shifted . children [ el ] ) ;
44
- } ) ;
45
- }
46
- if ( current . length === 0 ) {
47
- current = next ;
48
- next = [ ] ;
49
- }
50
- }
51
- return result ;
52
- }
21
+ let hierarchyArr = [ ] ;
53
22
54
- function truncate ( newDiff , num = 15 ) {
55
- if ( newDiff . length <= num ) return newDiff . replace ( ',' , '' ) ;
56
- const thisdiff = newDiff . slice ( 0 , num ) ;
57
- return thisdiff . concat ( '...' ) ;
58
- }
59
- actionsArr = snapshots . map ( ( snapshot , index ) => {
60
- const selected = index === viewIndex ;
61
- let newDiff = '' ;
62
- // if index is greater than 0
63
- if ( index > 0 ) {
64
- // calculate the diff
65
- const delta = diff ( snapshots [ index - 1 ] , snapshot ) ;
66
- newDiff = truncate ( breadthFirst ( delta ) ) ;
23
+ // gabi and nate :: delete function to traverse state from snapshots, now we are tranversing state from hiararchy and alsog getting infromation on display name and component name
24
+ const displayArray = ( obj ) => {
25
+ const newObj = {
26
+ index : obj . index ,
27
+ displayName : ` ${ obj . name } . ${ obj . branch } ` ,
28
+ state : obj . stateSnapshot . children [ 0 ] . state ,
29
+ componentName : obj . stateSnapshot . children [ 0 ] . name ,
30
+ }
31
+ hierarchyArr . push ( newObj )
32
+ if ( obj . children ) {
33
+ obj . children . forEach ( ( element ) => {
34
+ displayArray ( element )
35
+ } )
67
36
}
37
+ }
38
+ displayArray ( hierarchy )
39
+ console . log ( 'this is hierarchyArr' , hierarchyArr )
40
+
41
+ actionsArr = hierarchyArr . map ( ( snapshot , index ) => {
42
+ const selected = index === viewIndex ;
68
43
return (
69
44
< Action
70
45
key = { `action${ index } ` }
71
46
index = { index }
47
+ state = { snapshot . state }
48
+ displayName = { snapshot . displayName }
49
+ componentName = { snapshot . componentName }
72
50
selected = { selected }
73
51
dispatch = { dispatch }
74
52
sliderIndex = { sliderIndex }
75
- delta = { newDiff }
76
53
/>
77
54
) ;
78
55
} ) ;
79
- }
56
+
80
57
return (
81
58
< div className = "action-container" >
82
59
< div className = "action-component exclude" >
0 commit comments