Skip to content

Commit 63136eb

Browse files
Christopher StamperChristopher Stamper
authored andcommitted
Migrated ComponentMap, PerformanceVisx, and Tree to RTK
2 parents b80ac93 + 3b67c24 commit 63136eb

File tree

5 files changed

+51
-15
lines changed

5 files changed

+51
-15
lines changed

src/app/RTKslices.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,23 @@ export const mainSlice = createSlice({
448448
checkChildren(tabs[currentTab].currLocation.stateSnapshot);
449449
},
450450

451+
deleteSeries: (state) => {
452+
const { tabs, currentTab } = state;
453+
const allStorage = () => {
454+
const keys = Object.keys(localStorage);
455+
let i = keys.length;
456+
while (i--) {
457+
localStorage.removeItem(keys[i]);
458+
}
459+
};
460+
allStorage();
461+
Object.keys(tabs).forEach((tab) => {
462+
tabs[tab] = {
463+
...tabs[tab],
464+
};
465+
});
466+
tabs[currentTab] = { ...tabs[currentTab], seriesSavedStatus: false };
467+
}
451468
},
452469
})
453470

@@ -474,6 +491,7 @@ export const {
474491
importSnapshots,
475492
tutorialSaveSeriesToggle,
476493
toggleExpanded,
494+
deleteSeries
477495
} = mainSlice.actions
478496

479497

src/app/components/StateRoute/PerformanceVisx/BarGraphComparison.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ import MenuItem from '@mui/material/MenuItem';
1515
import FormControl from '@mui/material/FormControl';
1616
import { useTheme } from '@mui/material/styles';
1717
import { Button, InputLabel } from '@mui/material';
18-
import { onHover, onHoverExit, deleteSeries, setCurrentTabInApp } from '../../../actions/actions';
19-
import { useStoreContext } from '../../../store';
18+
import { onHover, onHoverExit, deleteSeries, setCurrentTabInApp } from '../../../RTKslices';
19+
// import { useStoreContext } from '../../../store';
20+
//importing useSelector and useDispatch for rtk conversion
21+
import { useSelector, useDispatch } from 'react-redux';
2022
import {
2123
snapshot,
2224
TooltipData,
@@ -46,7 +48,12 @@ const tooltipStyles = {
4648
};
4749

4850
const BarGraphComparison = (props: BarGraphComparisonProps): JSX.Element => {
49-
const [{ tabs, currentTab }, dispatch] = useStoreContext();
51+
//commented out line 51 to add hooks for RTK transition
52+
// const [{ tabs, currentTab }, dispatch] = useStoreContext();
53+
const dispatch = useDispatch();
54+
const tabs = useSelector(state => state.main.tabs);
55+
const currentTab = useSelector(state => state.main.currentTab);
56+
5057
const {
5158
width, // from ParentSize provided in StateRoute
5259
height, // from ParentSize provided in StateRoute

src/app/components/StateRoute/PerformanceVisx/BarGraphComparisonActions.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ import MenuItem from '@mui/material/MenuItem';
1414
import FormControl from '@mui/material/FormControl';
1515
import { useTheme } from '@mui/material/styles';
1616
import { Button } from '@mui/material';
17-
import { deleteSeries, setCurrentTabInApp } from '../../../actions/actions';
18-
import { useStoreContext } from '../../../store';
17+
import { deleteSeries, setCurrentTabInApp } from '../../../RTKslices';
18+
// import { useStoreContext } from '../../../store';
19+
//importing useSelector and useDispatch for rtk conversion
20+
import { useDispatch } from 'react-redux';
1921
import { TooltipData, Margin, BarGraphComparisonAction, ActionObj } from '../../../FrontendTypes';
2022

2123
/* DEFAULTS */
@@ -38,7 +40,9 @@ const tooltipStyles = {
3840
};
3941

4042
const BarGraphComparisonActions = (props: BarGraphComparisonAction) => {
41-
const [dispatch] = useStoreContext(); // used to get the dispatch function from our storeContext
43+
//commented out line 44 to add hooks for RTK transition
44+
// const [dispatch] = useStoreContext(); // used to get the dispatch function from our storeContext
45+
const dispatch = useDispatch();
4246
const {
4347
width, // from ParentSize provided in StateRoute
4448
height, // from ParentSize provided in StateRoute

src/app/components/StateRoute/PerformanceVisx/RenderingFrequency.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
/* eslint-disable jsx-a11y/no-static-element-interactions */
33
/* eslint-disable react/prop-types */
44
import React, { useState, useEffect } from 'react';
5-
import { onHover, onHoverExit, setCurrentTabInApp } from '../../../actions/actions';
6-
import { useStoreContext } from '../../../store';
5+
// import { onHover, onHoverExit, setCurrentTabInApp } from '../../../actions/actions';
6+
import { setCurrentTabInApp } from '../../../RTKslices';
7+
// import { useStoreContext } from '../../../store';
8+
import { useDispatch, useSelector } from 'react-redux';
79

810
/*
911
1012
*/
1113

1214
const RenderingFrequency = (props) => {
1315
const perfData = props.data;
14-
const [store, dispatch] = useStoreContext();
15-
16+
// const [store, dispatch] = useStoreContext();
17+
const dispatch = useDispatch();
1618
useEffect(() => {
1719
dispatch(setCurrentTabInApp('performance-comparison')); // dispatch sent at initial page load allowing changing "immer's" draft.currentTabInApp to 'performance-comparison' to facilitate render.
1820
}, []);
@@ -41,7 +43,9 @@ const RenderingFrequency = (props) => {
4143

4244
const ComponentCard = (props): JSX.Element => {
4345
const { componentName, stateType, averageRenderTime, renderFrequency, information } = props;
44-
const [{ tabs, currentTab }, dispatch] = useStoreContext();
46+
// const [{ tabs, currentTab }, dispatch] = useStoreContext();
47+
// const tabs = useSelector((state:any)=>state.main.tabs)
48+
// const currentTab = useSelector((state:any)=>state.main.currentTab);
4549
const [expand, setExpand] = useState(false);
4650

4751
// render time for each component from each snapshot

src/app/components/WebMetrics.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ import React, { useEffect } from 'react';
22
import Charts from 'react-apexcharts';
33
import ReactHover, { Trigger, Hover } from 'react-hover';
44
import { OptionsCursorTrueWithMargin } from '../FrontendTypes';
5-
import { setCurrentTabInApp } from '../actions/actions';
6-
import { useStoreContext } from '../store';
7-
5+
// import { setCurrentTabInApp } from '../actions/actions';
6+
import { setCurrentTabInApp } from '../RTKslices'
7+
// import { useStoreContext } from '../store';
8+
import { useDispatch } from 'react-redux';
89
/*
910
Used to render a single radial graph on the 'Web Metrics' tab
1011
*/
1112

1213
const radialGraph = (props) => {
14+
const dispatch = useDispatch();
1315
const state = {
1416
series: [props.series], // series appears to be the scale at which data is displayed based on the type of webMetrics measured.
1517
options: {
@@ -92,7 +94,8 @@ const radialGraph = (props) => {
9294
},
9395
};
9496

95-
const [store, dispatch] = useStoreContext(); // used to get the dispatch function from our storeContext
97+
// const [store, dispatch] = useStoreContext(); // used to get the dispatch function from our storeContext
98+
9699
useEffect(() => {
97100
dispatch(setCurrentTabInApp('webmetrics')); // dispatch sent at initial page load allowing changing "immer's" draft.currentTabInApp to 'webmetrics' to facilitate render.
98101
}, []);

0 commit comments

Comments
 (0)