5
5
/* eslint-disable @typescript-eslint/no-var-requires */
6
6
/* eslint-disable max-len */
7
7
/* eslint-disable object-curly-newline */
8
- import React from 'react' ;
8
+ import React , { useState } from 'react' ;
9
9
import { MemoryRouter as Router , Route , NavLink , Routes , Outlet , Link } from 'react-router-dom' ;
10
10
import { ParentSize } from '@visx/responsive' ;
11
11
import Tree from './Tree' ;
12
12
import ComponentMap from './ComponentMap/ComponentMap' ;
13
- import { changeView , changeSlider } from '../../slices/mainSlice' ;
14
- import { useSelector } from 'react-redux' ;
13
+ import { changeView , changeSlider , toggleAxTree , setCurrentTabInApp } from '../../slices/mainSlice' ;
14
+ import { useDispatch , useSelector } from 'react-redux' ;
15
15
import PerformanceVisx from './PerformanceVisx/PerformanceVisx' ;
16
16
import WebMetricsContainer from './WebMetrics/WebMetricsContainer' ;
17
17
import { MainState , RootState , StateRouteProps } from '../../FrontendTypes' ;
@@ -35,11 +35,33 @@ const StateRoute = (props: StateRouteProps) => {
35
35
currLocation, // from 'tabs[currentTab]' object in 'MainContainer'
36
36
} = props ;
37
37
38
+
38
39
const { tabs, currentTab } : MainState = useSelector ( ( state : RootState ) => state . main ) ;
39
40
const { hierarchy : tabsHierarchy , sliderIndex, viewIndex : tabsViewIndex } = tabs [ currentTab ] ;
40
41
const hierarchy = propsHierarchy || tabsHierarchy ;
41
42
const viewIndex = propsViewIndex || tabsViewIndex ;
42
43
44
+ const dispatch = useDispatch ( ) ;
45
+ const [ showTree , setShowTree ] = useState ( false ) ;
46
+ const [ selectedValue , setSelectedValue ] = useState ( 'disable' ) ;
47
+ const [ showParagraph , setShowParagraph ] = useState ( true ) ;
48
+
49
+ const enableAxTreeButton = ( ) => {
50
+ dispatch ( toggleAxTree ( 'toggleAxRecord' ) ) ;
51
+ dispatch ( setCurrentTabInApp ( 'AxTree' ) ) ;
52
+ setSelectedValue ( 'enable' ) ;
53
+ setShowParagraph ( false ) ;
54
+ setShowTree ( true ) ;
55
+ } ;
56
+
57
+ const disableAxTree = ( ) => {
58
+ dispatch ( toggleAxTree ( 'toggleAxRecord' ) ) ;
59
+ setSelectedValue ( 'disable' ) ;
60
+ setShowParagraph ( true ) ;
61
+ setShowTree ( false ) ;
62
+ } ;
63
+
64
+
43
65
return (
44
66
< div className = 'app-body' >
45
67
< div className = 'navbar' >
@@ -102,7 +124,7 @@ const StateRoute = (props: StateRouteProps) => {
102
124
< Route
103
125
path = '/accessibility'
104
126
element = {
105
- hierarchy ? (
127
+ showTree ? (
106
128
< ParentSize className = 'componentMapContainer' >
107
129
{ ( { width, height } ) => {
108
130
// eslint-disable-next-line react/prop-types
@@ -121,7 +143,40 @@ const StateRoute = (props: StateRouteProps) => {
121
143
) ;
122
144
} }
123
145
</ ParentSize >
124
- ) : null
146
+ ) : < div >
147
+ { showParagraph && (
148
+ < p >
149
+ A Note to Developers: Reactime is using the Chrome Debugger API in order to grab the
150
+ Accessibility Tree. Enabling this option will allow you to record Accessibility Tree
151
+ snapshots, but will result in the Chrome browser notifying you that the Chrome Debugger
152
+ has started.
153
+ </ p >
154
+ ) }
155
+ < div >
156
+ {
157
+ < input
158
+ type = 'radio'
159
+ value = 'enable'
160
+ checked = { selectedValue === 'enable' }
161
+ onChange = { ( ) => {
162
+ enableAxTreeButton ( ) ;
163
+ } }
164
+ />
165
+ }
166
+ < label htmlFor = 'enable' > Enable</ label >
167
+ {
168
+ < input
169
+ type = 'radio'
170
+ value = 'disable'
171
+ checked = { selectedValue === 'disable' }
172
+ onChange = { ( ) => {
173
+ disableAxTree ( ) ;
174
+ } }
175
+ />
176
+ }
177
+ < label htmlFor = 'disable' > Disable</ label >
178
+ </ div >
179
+ </ div >
125
180
}
126
181
> </ Route >
127
182
< Route
0 commit comments