Skip to content

Commit fcc4e0b

Browse files
author
AruSeito
authored
Merge pull request #3614 from illacloud/beta
Beta
2 parents 7263e8e + 30f7452 commit fcc4e0b

File tree

6 files changed

+92
-7
lines changed

6 files changed

+92
-7
lines changed

CODE_OF_CONDUCT.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@ decisions when appropriate.
5050

5151
## Scope
5252

53-
This Code of Conduct applies within all community spaces, and also applies when
54-
an individual is officially representing the community in public spaces.
55-
Examples of representing our community include using an official e-mail address,
56-
posting via an official social media account, or acting as an appointed
57-
representative at an online or offline event.
53+
This Code of Conduct is in effect in all community spaces and applies when someone is officially representing the community in public. Representation includes activities like using an official email, posting from an official social media account, or acting as a designated representative at online or offline events.
5854

5955
## Enforcement
6056

apps/builder/src/middleware/undoRedo/method/components.tsx

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { REDUX_ACTION_FROM } from "@/middleware/undoRedo/interface"
44
import { UpdateComponentContainerPayload } from "@/redux/currentApp/components/componentsPayload"
55
import {
66
getComponentMap,
7+
getOriginalGlobalData,
78
searchDSLByDisplayName,
89
searchDSLFromTree,
910
} from "@/redux/currentApp/components/componentsSelector"
@@ -47,7 +48,7 @@ export const componentsSnapShot = (
4748
case "deleteComponentNodeReducer": {
4849
const originActionComponentNode = action.payload.displayNames
4950
.map((displayName: string) => {
50-
return searchDSLByDisplayName(displayName, prevRootState)
51+
return buildTreeByMapNode(displayName, prevComponents)
5152
})
5253
.filter((item: ComponentTreeNode | null) => item != undefined)
5354
const newAction = {
@@ -585,5 +586,57 @@ export const componentsSnapShot = (
585586
}
586587
break
587588
}
589+
case "setGlobalStateReducer": {
590+
const { key, oldKey, value } = action.payload
591+
let newAction
592+
if (!oldKey) {
593+
newAction = {
594+
type: "components/deleteGlobalStateByKeyReducer",
595+
payload: { key },
596+
from: action.from,
597+
}
598+
} else {
599+
newAction = {
600+
type: "components/setGlobalStateReducer",
601+
payload: { key: oldKey, oldKey: key, value },
602+
from: action.from,
603+
}
604+
}
605+
606+
if (action.from === REDUX_ACTION_FROM.UNDO) {
607+
IllaUndoRedoManager.pushToRedoStack([
608+
JSON.parse(JSON.stringify(newAction)),
609+
])
610+
} else {
611+
IllaUndoRedoManager.pushToUndoStack([
612+
JSON.parse(JSON.stringify(newAction)),
613+
])
614+
}
615+
break
616+
}
617+
case "deleteGlobalStateByKeyReducer": {
618+
const prevGlobalState = getOriginalGlobalData(prevRootState)
619+
const { key } = action.payload
620+
const targetGlobalState = prevGlobalState[key]
621+
const newAction = {
622+
type: "components/setGlobalStateReducer",
623+
payload: {
624+
key,
625+
value: targetGlobalState,
626+
oldKey: "",
627+
},
628+
from: action.from,
629+
}
630+
if (action.from === REDUX_ACTION_FROM.UNDO) {
631+
IllaUndoRedoManager.pushToRedoStack([
632+
JSON.parse(JSON.stringify(newAction)),
633+
])
634+
} else {
635+
IllaUndoRedoManager.pushToUndoStack([
636+
JSON.parse(JSON.stringify(newAction)),
637+
])
638+
}
639+
break
640+
}
588641
}
589642
}

apps/builder/src/redux/currentApp/components/componentsSelector.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,13 @@ export const getOriginalGlobalData = createSelector(
409409
},
410410
)
411411

412+
export const getOriginalGlobalDataNames = createSelector(
413+
[getRootComponentNode],
414+
(rootNode) => {
415+
return Object.keys(rootNode?.props?.globalData ?? {})
416+
},
417+
)
418+
412419
export const getGlobalDataToActionList = createSelector(
413420
[getRootComponentNode],
414421
(rootNode) => {

apps/builder/src/utils/shortcut/index.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { configActions } from "@/redux/config/configSlice"
2121
import { getActionItemByDisplayName } from "@/redux/currentApp/action/actionSelector"
2222
import {
2323
getComponentMap,
24+
getOriginalGlobalDataNames,
2425
searchComponentFromMap,
2526
} from "@/redux/currentApp/components/componentsSelector"
2627
import { componentsActions } from "@/redux/currentApp/components/componentsSlice"
@@ -128,10 +129,21 @@ export const Shortcut: FC<{ children: ReactNode }> = ({ children }) => {
128129
store.getState(),
129130
displayName[i],
130131
)
132+
const globalDataNames = getOriginalGlobalDataNames(
133+
store.getState(),
134+
)
131135
if (action) {
132136
// fail to await @chenlongbo
133137
onDeleteActionItem(action)
134138
}
139+
if (globalDataNames.includes(displayName[i])) {
140+
dispatch(
141+
componentsActions.deleteGlobalStateByKeyReducer({
142+
key: displayName[i],
143+
}),
144+
)
145+
DisplayNameGenerator.removeDisplayName(displayName[i])
146+
}
135147
}
136148
trackInEditor(ILLA_MIXPANEL_EVENT_TYPE.CLICK, {
137149
element: "action_delete_modal_delete",

apps/builder/src/utils/undoRedo/antonymyRule.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { REDUX_ACTION_FROM } from "@/middleware/undoRedo/interface"
66
import { configActions } from "@/redux/config/configSlice"
77
import store from "@/store"
88
import { changeDisplayNameHelperWhenUndoRedo } from "../componentNode/changeDisplayNameHelper"
9+
import { DisplayNameGenerator } from "../generators/generateDisplayName"
910
import {
1011
addActionItemWhenUndoRedo,
1112
removeActionItemWhenUndoRedo,
@@ -169,6 +170,23 @@ export const reduxActionDependOnRestAPI = async (
169170
})
170171
break
171172
}
173+
case "components/setGlobalStateReducer": {
174+
if (action.payload.key) {
175+
const newName = DisplayNameGenerator.updateOrGenerateDisplayName(
176+
action.payload.key,
177+
)
178+
store.dispatch({
179+
...action,
180+
from,
181+
payload: {
182+
...action.payload,
183+
key: newName,
184+
},
185+
})
186+
}
187+
break
188+
}
189+
172190
default: {
173191
store.dispatch({
174192
...action,

apps/builder/src/utils/undoRedo/undo.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export class ILLA_UNDO_REDO {
3838
})
3939
} else {
4040
const info = this.undoStack.pop() as AnyAction[]
41-
4241
reduxActionDependOnRestAPI(info, REDUX_ACTION_FROM.UNDO)
4342
}
4443
}

0 commit comments

Comments
 (0)