Skip to content

Commit 1cdf7a7

Browse files
committed
Merge branch 'allstate' into mike/allstate
2 parents e150262 + 36d1aaa commit 1cdf7a7

File tree

8 files changed

+57
-20
lines changed

8 files changed

+57
-20
lines changed

app/src/Dashboard/NavbarDash.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const StyledMenu = withStyles({
5050
})(props => (
5151
<Menu
5252
elevation={0}
53-
getContentAnchorEl={null}
53+
// getContentAnchorEl={null}
5454
anchorOrigin={{
5555
vertical: 'bottom',
5656
horizontal: 'center'

app/src/components/App.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export const App = (): JSX.Element => {
1818
// const [state, dispatch] = useReducer(reducer, initialState);
1919
const state = useSelector(store => store.appState);
2020
const dispatch = useDispatch();
21-
console.log("loaded right away")
2221
// checks if user is signed in as guest or actual user and changes loggedIn boolean accordingly
2322
useEffect(()=>{
2423
if (window.localStorage.getItem('ssid') !== 'guest') {
@@ -42,7 +41,7 @@ export const App = (): JSX.Element => {
4241
// type: 'SET INITIAL STATE',
4342
// payload: project
4443
// });
45-
dispatch(setInitialState({project}))
44+
dispatch(setInitialState(project))
4645
}
4746
});
4847
} else {
@@ -60,7 +59,7 @@ export const App = (): JSX.Element => {
6059
// type: 'SET INITIAL STATE',
6160
// payload: project
6261
// });
63-
dispatch(setInitialState({project}))
62+
dispatch(setInitialState(project))
6463
} else {
6564
console.log(
6665
'No user project found in localforage, setting initial state blank'

app/src/components/left/HTMLPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const HTMLPanel = (props): JSX.Element => {
111111
// type: 'ADD ELEMENT',
112112
// payload: newElement
113113
// });
114-
dispatch(addElement({newElement}))
114+
dispatch(addElement(newElement))
115115
setCurrentID(currentID + 1);
116116
setTag('');
117117
setName('');

app/src/components/main/Canvas.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Arrow from './Arrow';
1010
import { getRowsStateFromCache } from '@mui/x-data-grid/hooks/features/rows/gridRowsUtils';
1111
// Redux Toolkit test
1212
import { useDispatch, useSelector } from 'react-redux';
13-
import { changeFocus, addChild } from '../../redux/reducers/slice/appStateSlice';
13+
import { changeFocus, addChild,snapShotAction } from '../../redux/reducers/slice/appStateSlice';
1414

1515
function Canvas(props): JSX.Element {
1616
// const [state, dispatch] = useContext(StateContext);
@@ -89,24 +89,34 @@ function Canvas(props): JSX.Element {
8989
// stores a snapshot of state into the past array for UNDO. snapShotFunc is also invoked for nestable elements in DirectChildHTMLNestable.tsx
9090
const snapShotFunc = () => {
9191
// make a deep clone of state
92+
9293
const deepCopiedState = JSON.parse(JSON.stringify(state));
94+
9395
const focusIndex = state.canvasFocus.componentId - 1;
96+
console.log('about to dispatch snapshot')
9497
//pushes the last user action on the canvas into the past array of Component
95-
state.components[focusIndex].past.push(deepCopiedState.components[focusIndex].children);
98+
// state.components[focusIndex].past.push(deepCopiedState.components[focusIndex].children);
99+
100+
dispatch(snapShotAction({focusIndex: focusIndex, deepCopiedState: deepCopiedState}))
101+
console.log('left snapshot dispatch moving on ')
96102
};
97103

98104
// This hook will allow the user to drag items from the left panel on to the canvas
99105
const [{ isOver }, drop] = useDrop({
100106
accept: ItemTypes.INSTANCE,
101107
drop: (item: DragItem, monitor: DropTargetMonitor) => {
102108
const didDrop = monitor.didDrop();
109+
103110
// takes a snapshot of state to be used in UNDO and REDO cases
111+
console.log('about to snapshot')
104112
snapShotFunc();
113+
console.log('achieved snopshopt')
105114
// returns false for direct drop target
115+
console.log('diddrop', didDrop)
106116
if (didDrop) {
107117
return;
108118
}
109-
console.log(currentComponent)
119+
110120
// if item dropped is going to be a new instance (i.e. it came from the left panel), then create a new child component
111121
if (item.newInstance && item.instanceType !== "Component") {
112122
dispatch(addChild({

app/src/components/main/DeleteButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { DeleteButtons } from '../../interfaces/Interfaces';
33
import Modal from '@mui/material/Modal';
44
import StateContext from '../../context/context';
55
import { useDispatch } from 'react-redux';
6-
import { changeFocus, addChild, deleteChild } from '../../redux/reducers/slice/appStateSlice';
6+
import { deleteChild } from '../../redux/reducers/slice/appStateSlice';
77

88
function DeleteButton({ id, name }: DeleteButtons) {
99
// const [state, dispatch] = useContext(StateContext);

app/src/components/top/NavBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const StyledMenu = withStyles({
6262
})(props => (
6363
<Menu
6464
elevation={0}
65-
getContentAnchorEl={null}
65+
// getContentAnchorEl={null}
6666
anchorOrigin={{
6767
vertical: 'bottom',
6868
horizontal: 'center'

app/src/redux/reducers/slice/appStateSlice.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -398,14 +398,14 @@ const appStateSlice = createSlice({
398398
);
399399
components[canvasFocus.componentId - 1].children = addChildArray;
400400

401-
parentComponent.code = generateCode(
402-
components,
403-
parentComponentId,
404-
[...state.rootComponents],
405-
state.projectType,
406-
state.HTMLTypes,
407-
state.tailwind
408-
);
401+
// parentComponent.code = generateCode(
402+
// components,
403+
// parentComponentId,
404+
// [...state.rootComponents],
405+
// state.projectType,
406+
// state.HTMLTypes,
407+
// state.tailwind
408+
// );
409409

410410
return {
411411
...state,
@@ -1204,13 +1204,16 @@ const appStateSlice = createSlice({
12041204
saveTimer: !state.config.saveTimer
12051205
};
12061206
},
1207+
snapShotAction: (state,action) => {
1208+
state.components[action.payload.focusIndex].past.push(action.payload.deepCopiedState.components[action.payload.focusIndex].children);
1209+
}
12071210
}
12081211
});
12091212

12101213
// Exports the action creator function to be used with useDispatch
12111214

12121215

1213-
export const { addComponent, addChild, changeFocus, changeTailwind, changePosition, updateStateUsed, resetAllState, updateUseContext, updateCss, updateEvents, deleteEventAction, deletePage, deleteReusableComponent, setProjectName, changeProjectType, resetState, updateProjectName, deleteElement, updateAttributes, deleteChild, setInitialState, openProject, addElement, undo, redo, addState, addPassedInProps, deletePassedInProps, deleteState, toggleLoggedIn, configToggle } = appStateSlice.actions;
1216+
export const { addComponent, addChild, changeFocus, changeTailwind, changePosition, updateStateUsed, resetAllState, updateUseContext, updateCss, updateEvents, deleteEventAction, deletePage, deleteReusableComponent, setProjectName, changeProjectType, resetState, updateProjectName, deleteElement, updateAttributes, deleteChild, setInitialState, openProject, addElement, undo, redo, addState, addPassedInProps, deletePassedInProps, deleteState, toggleLoggedIn, configToggle, snapShotAction } = appStateSlice.actions;
12141217

12151218

12161219
// Exports so we can combine in rootReducer

app/src/redux/store.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,32 @@ import { configureStore } from '@reduxjs/toolkit';
44
import rootReducer from './reducers/rootReducer';
55

66
const store = configureStore({
7-
reducer: rootReducer
7+
reducer: rootReducer,
8+
middleware: getDefaultMiddleware => {
9+
const ignoredPaths = [];
10+
11+
for (let i = 0; i < 21; i++) {
12+
ignoredPaths.push(`appState.HTMLTypes.${i}.icon`);
13+
ignoredPaths.push(`appState.HTMLTypes.${i}.icon.$$typeof`);
14+
}
15+
16+
return getDefaultMiddleware({
17+
serializableCheck: {
18+
// Ignore the `configToggle` action type
19+
// ignoredActions: ['configToggle'],
20+
// Ignore these field paths in all actions
21+
// ignoredActionPaths: ['meta.arg', 'payload.timestamp'],
22+
// Ignore these paths in the state
23+
ignoredPaths: ignoredPaths,
24+
},
25+
});
26+
},
827
});
928

29+
30+
31+
32+
33+
34+
1035
export default store;

0 commit comments

Comments
 (0)