Skip to content

Commit a01084b

Browse files
committed
working on adding button for ax functions
1 parent f90ad7f commit a01084b

File tree

2 files changed

+45
-15
lines changed

2 files changed

+45
-15
lines changed

src/app/components/StateRoute/Ax.tsx

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect } from 'react';
22
import { JSONTree } from 'react-json-tree'; // React JSON Viewer Component;
3-
import { setCurrentTabInApp } from '../../slices/mainSlice';
3+
import { setCurrentTabInApp, toggleAxTree } from '../../slices/mainSlice';
44
import { useDispatch } from 'react-redux';
55

66
const theme = {
@@ -34,22 +34,40 @@ const AxTree = (props) => {
3434

3535
const dispatch = useDispatch();
3636

37-
useEffect(() => {
38-
dispatch(setCurrentTabInApp('AxTree')); // dispatch sent at initial page load allowing changing "immer's" draft.currentTabInApp to 'tree' to facilitate render.
39-
}, []);
37+
let AccessibilityHasBeenDisabled = true;
38+
const enableAxTreeButton = () => {
39+
dispatch(toggleAxTree('toggleAxRecord'));
40+
dispatch(setCurrentTabInApp('AxTree'));
41+
AccessibilityHasBeenDisabled = false;
42+
}
43+
4044

41-
//removing/adding snapshot at beginning of return statement didn't change anything
4245
return (
43-
<>
44-
{' '}
45-
{snapshot && (
46+
<div>
47+
{
48+
AccessibilityHasBeenDisabled ? <button onClick={enableAxTreeButton}>Click Here to Enable Accessibility</button> :
4649
<JSONTree
47-
data={axSnapshots[currLocation.index]}
48-
shouldExpandNodeInitially={() => true}
49-
theme={theme}
50-
/>
51-
)}
52-
</>
53-
);
50+
data={axSnapshots[currLocation.index]}
51+
// shouldExpandNodeInitially={() => false}
52+
theme={theme}
53+
/>
54+
}
55+
</div>
56+
)
57+
58+
// return (
59+
// <div>
60+
61+
// <p>A Note to Developers: Reactime is using the Chrome Debugging API in order to grab the Accessibility Tree. Enabling this option will allow you to record AxSnapshots, but will result in the Chrome browser notifying you that the Chrome Debugger has started.</p>
62+
// {<button onClick={enableAxTreeButton}>Click Here to Enable Accessibility</button>
63+
// // <JSONTree
64+
// // data={axSnapshots[currLocation.index]}
65+
// // // shouldExpandNodeInitially={() => false}
66+
// // theme={theme}
67+
// // /> : null
68+
// }
69+
70+
// </div>
71+
// );
5472
};
5573
export default AxTree;

src/app/slices/mainSlice.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createSlice } from '@reduxjs/toolkit';
22
import { InitialState } from '../FrontendTypes';
33
import _ from 'lodash';
4+
import Action from '../components/Actions/Action';
45

56
const initialState: InitialState = {
67
// we initialize what our initialState is here
@@ -489,6 +490,16 @@ export const mainSlice = createSlice({
489490
state.connectRequested = false;
490491
state.connectionStatus = true;
491492
},
493+
494+
toggleAxTree: (state, action) => {
495+
const { port, payload, tabs, currentTab } = state;
496+
497+
port.postMessage({
498+
action: 'toggleAxRecord',
499+
payload: action.payload,
500+
tabId: currentTab,
501+
})
502+
}
492503
},
493504
});
494505

@@ -523,4 +534,5 @@ export const {
523534
disconnected,
524535
startReconnect,
525536
endConnect,
537+
toggleAxTree,
526538
} = mainSlice.actions;

0 commit comments

Comments
 (0)