22 * License, v. 2.0. If a copy of the MPL was not distributed with this
33 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44
5+ import * as React from 'react' ;
6+
7+ import explicitConnect from 'firefox-profiler/utils/connect' ;
58import { FunctionList } from './FunctionList' ;
69import { SelfWing } from './SelfWing' ;
710import { UpperWing } from './UpperWing' ;
@@ -10,37 +13,93 @@ import { DisclosureBox } from 'firefox-profiler/components/shared/DisclosureBox'
1013import { StackSettings } from 'firefox-profiler/components/shared/StackSettings' ;
1114import { TransformNavigator } from 'firefox-profiler/components/shared/TransformNavigator' ;
1215import { ResizableWithSplitter } from '../shared/ResizableWithSplitter' ;
16+ import { getFunctionListSectionsOpen } from 'firefox-profiler/selectors/url-state' ;
17+ import { changeFunctionListSectionOpen } from 'firefox-profiler/actions/profile-view' ;
18+
19+ import type { FunctionListSectionsOpenState } from 'firefox-profiler/types' ;
20+ import type { ConnectedProps } from 'firefox-profiler/utils/connect' ;
1321
1422import './Butterfly.css' ;
1523
16- export const ProfileFunctionListView = ( ) => (
17- < div
18- className = "treeAndSidebarWrapper"
19- id = "function-list-tab"
20- role = "tabpanel"
21- aria-labelledby = "function-list-tab-button"
22- >
23- < StackSettings hideInvertCallstack />
24- < TransformNavigator />
25- < div className = "butterflyWrapper" >
26- < FunctionList />
27- < ResizableWithSplitter
28- className = "butterflyWings"
29- splitterPosition = "start"
30- controlledProperty = "width"
31- percent = { true }
32- initialSize = "50%"
24+ type StateProps = {
25+ readonly sectionsOpen : FunctionListSectionsOpenState ;
26+ } ;
27+
28+ type DispatchProps = {
29+ readonly changeFunctionListSectionOpen : typeof changeFunctionListSectionOpen ;
30+ } ;
31+
32+ type Props = ConnectedProps < { } , StateProps , DispatchProps > ;
33+
34+ class ProfileFunctionListViewImpl extends React . PureComponent < Props > {
35+ _onDescendantsToggle = ( isOpen : boolean ) => {
36+ this . props . changeFunctionListSectionOpen ( 'descendants' , isOpen ) ;
37+ } ;
38+ _onAncestorsToggle = ( isOpen : boolean ) => {
39+ this . props . changeFunctionListSectionOpen ( 'ancestors' , isOpen ) ;
40+ } ;
41+ _onSelfToggle = ( isOpen : boolean ) => {
42+ this . props . changeFunctionListSectionOpen ( 'self' , isOpen ) ;
43+ } ;
44+
45+ override render ( ) {
46+ const { sectionsOpen } = this . props ;
47+ return (
48+ < div
49+ className = "treeAndSidebarWrapper"
50+ id = "function-list-tab"
51+ role = "tabpanel"
52+ aria-labelledby = "function-list-tab-button"
3353 >
34- < DisclosureBox label = "Descendants" >
35- < UpperWing />
36- </ DisclosureBox >
37- < DisclosureBox label = "Ancestors" initialOpen = { false } >
38- < LowerWing />
39- </ DisclosureBox >
40- < DisclosureBox label = "Self" initialOpen = { false } >
41- < SelfWing />
42- </ DisclosureBox >
43- </ ResizableWithSplitter >
44- </ div >
45- </ div >
46- ) ;
54+ < StackSettings hideInvertCallstack />
55+ < TransformNavigator />
56+ < div className = "butterflyWrapper" >
57+ < FunctionList />
58+ < ResizableWithSplitter
59+ className = "butterflyWings"
60+ splitterPosition = "start"
61+ controlledProperty = "width"
62+ percent = { true }
63+ initialSize = "50%"
64+ >
65+ < DisclosureBox
66+ label = "Descendants"
67+ isOpen = { sectionsOpen . descendants }
68+ onToggle = { this . _onDescendantsToggle }
69+ >
70+ < UpperWing />
71+ </ DisclosureBox >
72+ < DisclosureBox
73+ label = "Ancestors"
74+ isOpen = { sectionsOpen . ancestors }
75+ onToggle = { this . _onAncestorsToggle }
76+ >
77+ < LowerWing />
78+ </ DisclosureBox >
79+ < DisclosureBox
80+ label = "Self"
81+ isOpen = { sectionsOpen . self }
82+ onToggle = { this . _onSelfToggle }
83+ >
84+ < SelfWing />
85+ </ DisclosureBox >
86+ </ ResizableWithSplitter >
87+ </ div >
88+ </ div >
89+ ) ;
90+ }
91+ }
92+
93+ export const ProfileFunctionListView = explicitConnect <
94+ { } ,
95+ StateProps ,
96+ DispatchProps
97+ > ( {
98+ mapStateToProps : ( state ) => ( {
99+ sectionsOpen : getFunctionListSectionsOpen ( state ) ,
100+ } ) ,
101+ mapDispatchToProps : {
102+ changeFunctionListSectionOpen,
103+ } ,
104+ component : ProfileFunctionListViewImpl ,
105+ } ) ;
0 commit comments