Skip to content

Commit 76402ed

Browse files
committed
added warnings for the state and class toggles
1 parent 394754f commit 76402ed

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/reducers/leftReducers.ts

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,16 @@ export const toggleComponentClass = (
507507
//creates a deep copy of the components array
508508
const componentCopy = cloneDeep(state.components);
509509

510+
if (!state.codeReadOnly) {
511+
const check = window.confirm(
512+
`Are you sure you want to change the Class toggle for the ${state.focusComponent.title} component while the program is in the "Edit Mode"? \n\nAll of the changes to the "Code Preview" for the ${state.focusComponent.title} component will be overridden!`
513+
);
514+
if (!check) {
515+
return {
516+
...state
517+
};
518+
}
519+
}
510520
//iterate array, and invert statefulness for targeted component based on id prop
511521
componentCopy.forEach((element: ComponentInt) => {
512522
if (element.id === id) {
@@ -522,7 +532,8 @@ export const toggleComponentClass = (
522532
components: componentCopy,
523533
history,
524534
historyIndex,
525-
future
535+
future,
536+
codeReadOnly: true
526537
};
527538
};
528539

@@ -534,6 +545,16 @@ export const toggleComponentState = (
534545
//creates a deep copy of the components array
535546
const componentsCopy = cloneDeep(state.components);
536547

548+
if (!state.codeReadOnly) {
549+
const check = window.confirm(
550+
`Are you sure you want to change the State toggle for the ${state.focusComponent.title} component while the program is in the "Edit Mode"? \n\nAll of the changes to the "Code Preview" for the ${state.focusComponent.title} component will be overridden!`
551+
);
552+
if (!check) {
553+
return {
554+
...state
555+
};
556+
}
557+
}
537558
//iterate array, and invert statefulness for targeted component based on id prop
538559
componentsCopy.forEach((element: ComponentInt) => {
539560
if (element.id === id) {
@@ -550,7 +571,8 @@ export const toggleComponentState = (
550571
components: componentsCopy,
551572
history,
552573
historyIndex,
553-
future
574+
future,
575+
codeReadOnly: true
554576
};
555577
};
556578
//a reducer function to see if component name editing mode should be entered

0 commit comments

Comments
 (0)