Skip to content

Commit

Permalink
Merge pull request #3614 from illacloud/beta
Browse files Browse the repository at this point in the history
Beta
  • Loading branch information
AruSeito authored Dec 27, 2023
2 parents 7263e8e + 30f7452 commit fcc4e0b
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 7 deletions.
6 changes: 1 addition & 5 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
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.

## Enforcement

Expand Down
55 changes: 54 additions & 1 deletion apps/builder/src/middleware/undoRedo/method/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { REDUX_ACTION_FROM } from "@/middleware/undoRedo/interface"
import { UpdateComponentContainerPayload } from "@/redux/currentApp/components/componentsPayload"
import {
getComponentMap,
getOriginalGlobalData,
searchDSLByDisplayName,
searchDSLFromTree,
} from "@/redux/currentApp/components/componentsSelector"
Expand Down Expand Up @@ -47,7 +48,7 @@ export const componentsSnapShot = (
case "deleteComponentNodeReducer": {
const originActionComponentNode = action.payload.displayNames
.map((displayName: string) => {
return searchDSLByDisplayName(displayName, prevRootState)
return buildTreeByMapNode(displayName, prevComponents)
})
.filter((item: ComponentTreeNode | null) => item != undefined)
const newAction = {
Expand Down Expand Up @@ -585,5 +586,57 @@ export const componentsSnapShot = (
}
break
}
case "setGlobalStateReducer": {
const { key, oldKey, value } = action.payload
let newAction
if (!oldKey) {
newAction = {
type: "components/deleteGlobalStateByKeyReducer",
payload: { key },
from: action.from,
}
} else {
newAction = {
type: "components/setGlobalStateReducer",
payload: { key: oldKey, oldKey: key, value },
from: action.from,
}
}

if (action.from === REDUX_ACTION_FROM.UNDO) {
IllaUndoRedoManager.pushToRedoStack([
JSON.parse(JSON.stringify(newAction)),
])
} else {
IllaUndoRedoManager.pushToUndoStack([
JSON.parse(JSON.stringify(newAction)),
])
}
break
}
case "deleteGlobalStateByKeyReducer": {
const prevGlobalState = getOriginalGlobalData(prevRootState)
const { key } = action.payload
const targetGlobalState = prevGlobalState[key]
const newAction = {
type: "components/setGlobalStateReducer",
payload: {
key,
value: targetGlobalState,
oldKey: "",
},
from: action.from,
}
if (action.from === REDUX_ACTION_FROM.UNDO) {
IllaUndoRedoManager.pushToRedoStack([
JSON.parse(JSON.stringify(newAction)),
])
} else {
IllaUndoRedoManager.pushToUndoStack([
JSON.parse(JSON.stringify(newAction)),
])
}
break
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,13 @@ export const getOriginalGlobalData = createSelector(
},
)

export const getOriginalGlobalDataNames = createSelector(
[getRootComponentNode],
(rootNode) => {
return Object.keys(rootNode?.props?.globalData ?? {})
},
)

export const getGlobalDataToActionList = createSelector(
[getRootComponentNode],
(rootNode) => {
Expand Down
12 changes: 12 additions & 0 deletions apps/builder/src/utils/shortcut/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { configActions } from "@/redux/config/configSlice"
import { getActionItemByDisplayName } from "@/redux/currentApp/action/actionSelector"
import {
getComponentMap,
getOriginalGlobalDataNames,
searchComponentFromMap,
} from "@/redux/currentApp/components/componentsSelector"
import { componentsActions } from "@/redux/currentApp/components/componentsSlice"
Expand Down Expand Up @@ -128,10 +129,21 @@ export const Shortcut: FC<{ children: ReactNode }> = ({ children }) => {
store.getState(),
displayName[i],
)
const globalDataNames = getOriginalGlobalDataNames(
store.getState(),
)
if (action) {
// fail to await @chenlongbo
onDeleteActionItem(action)
}
if (globalDataNames.includes(displayName[i])) {
dispatch(
componentsActions.deleteGlobalStateByKeyReducer({
key: displayName[i],
}),
)
DisplayNameGenerator.removeDisplayName(displayName[i])
}
}
trackInEditor(ILLA_MIXPANEL_EVENT_TYPE.CLICK, {
element: "action_delete_modal_delete",
Expand Down
18 changes: 18 additions & 0 deletions apps/builder/src/utils/undoRedo/antonymyRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { REDUX_ACTION_FROM } from "@/middleware/undoRedo/interface"
import { configActions } from "@/redux/config/configSlice"
import store from "@/store"
import { changeDisplayNameHelperWhenUndoRedo } from "../componentNode/changeDisplayNameHelper"
import { DisplayNameGenerator } from "../generators/generateDisplayName"
import {
addActionItemWhenUndoRedo,
removeActionItemWhenUndoRedo,
Expand Down Expand Up @@ -169,6 +170,23 @@ export const reduxActionDependOnRestAPI = async (
})
break
}
case "components/setGlobalStateReducer": {
if (action.payload.key) {
const newName = DisplayNameGenerator.updateOrGenerateDisplayName(
action.payload.key,
)
store.dispatch({
...action,
from,
payload: {
...action.payload,
key: newName,
},
})
}
break
}

default: {
store.dispatch({
...action,
Expand Down
1 change: 0 additions & 1 deletion apps/builder/src/utils/undoRedo/undo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export class ILLA_UNDO_REDO {
})
} else {
const info = this.undoStack.pop() as AnyAction[]

reduxActionDependOnRestAPI(info, REDUX_ACTION_FROM.UNDO)
}
}
Expand Down

0 comments on commit fcc4e0b

Please sign in to comment.