Skip to content

Commit f62ae8b

Browse files
authored
Merge pull request #3624 from illacloud/Release/4.2.2
Release/4.2.2
2 parents b81b0cb + be9476d commit f62ae8b

File tree

25 files changed

+472
-168
lines changed

25 files changed

+472
-168
lines changed

apps/builder/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"private": true,
66
"author": "ILLA Cloud <[email protected]>",
77
"license": "Apache-2.0",
8-
"version": "4.2.1",
8+
"version": "4.2.2",
99
"scripts": {
1010
"dev": "vite --strictPort --force",
1111
"build-cloud": "NODE_OPTIONS=--max-old-space-size=12288 vite build --mode cloud",

apps/builder/src/hooks/utils/fixedComponents.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ComponentTreeNode } from "@illa-public/public-types"
2+
import { isString } from "@illa-design/react"
23

34
export const fixedChartComponent = (component: ComponentTreeNode) => {
45
return {
@@ -92,6 +93,24 @@ const fixedImageComponent = (component: ComponentTreeNode) => {
9293
}
9394
}
9495

96+
const fixedContainerComponent = (component: ComponentTreeNode) => {
97+
let linkedWidget
98+
if (component.props) {
99+
linkedWidget =
100+
component.props.linkWidgetDisplayName !== undefined &&
101+
isString(component.props.linkWidgetDisplayName)
102+
? [component.props.linkWidgetDisplayName]
103+
: component.props.linkWidgetDisplayName
104+
}
105+
return {
106+
...component,
107+
props: {
108+
...component.props,
109+
linkWidgetDisplayName: linkedWidget,
110+
},
111+
}
112+
}
113+
95114
export const fixedComponentsToNewComponents = (
96115
componentsTree: ComponentTreeNode,
97116
) => {
@@ -112,6 +131,8 @@ export const fixedComponentsToNewComponents = (
112131
return fixedDataGridComponent(component)
113132
case "IMAGE_WIDGET":
114133
return fixedImageComponent(component)
134+
case "CONTAINER_WIDGET":
135+
return fixedContainerComponent(component)
115136
default: {
116137
return fixedComponentsToNewComponents(component)
117138
}

apps/builder/src/page/App/components/InspectPanel/PanelSetters/ContainerSetter/ViewsSetter/context/viewsListContext.tsx

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useDispatch, useSelector } from "react-redux"
55
import { PanelFieldConfig } from "@/page/App/components/InspectPanel/interface"
66
import { componentsActions } from "@/redux/currentApp/components/componentsSlice"
77
import { getExecutionResult } from "@/redux/currentApp/executionTree/executionSelector"
8+
import { RootState } from "@/store"
89
import { newGenerateChildrenComponentNode } from "@/utils/generators/generateComponentNode"
910
import { BasicContainerConfig } from "@/widgetLibrary/BasicContainer/BasicContainer"
1011
import { ViewItemShape } from "../interface"
@@ -21,6 +22,10 @@ interface ProviderProps {
2122
componentNode: ComponentMapNode
2223
handleUpdateDsl: (attrPath: string, value: any) => void
2324
handleUpdateMultiAttrDSL?: (updateSlice: Record<string, any>) => void
25+
handleUpdateExecutionResult?: (
26+
displayName: string,
27+
updateSlice: Record<string, any>,
28+
) => void
2429
handleUpdateOtherMultiAttrDSL?: (
2530
displayName: string,
2631
updateSlice: Record<string, any>,
@@ -44,11 +49,19 @@ export const ViewListSetterProvider: FC<ProviderProps> = (props) => {
4449
attrPath,
4550
widgetDisplayName,
4651
handleUpdateMultiAttrDSL,
52+
handleUpdateExecutionResult,
4753
componentNode,
4854
} = props
4955
const dispatch = useDispatch()
5056
const executionResult = useSelector(getExecutionResult)
5157

58+
const targetComponentProps = useSelector<RootState, Record<string, any>>(
59+
(rootState) => {
60+
const executionTree = getExecutionResult(rootState)
61+
return get(executionTree, widgetDisplayName, {})
62+
},
63+
)
64+
5265
const allViews = useMemo(() => {
5366
return get(
5467
executionResult,
@@ -57,6 +70,10 @@ export const ViewListSetterProvider: FC<ProviderProps> = (props) => {
5770
) as ViewItemShape[]
5871
}, [attrPath, executionResult, widgetDisplayName])
5972

73+
const linkWidgetDisplayName = useMemo(() => {
74+
return get(targetComponentProps, "linkWidgetDisplayName", "") as string
75+
}, [targetComponentProps])
76+
6077
const currentViewIndex = useMemo(() => {
6178
return get(executionResult, `${widgetDisplayName}.currentIndex`)
6279
}, [executionResult, widgetDisplayName])
@@ -101,13 +118,13 @@ export const ViewListSetterProvider: FC<ProviderProps> = (props) => {
101118
)
102119
},
103120
[
104-
viewsList,
105-
componentNode.childrenNode,
106-
attrPath,
107121
allViewsKeys,
122+
attrPath,
123+
componentNode.childrenNode,
108124
currentViewIndex,
109-
handleUpdateMultiAttrDSL,
110125
dispatch,
126+
handleUpdateMultiAttrDSL,
127+
viewsList,
111128
],
112129
)
113130

@@ -136,25 +153,61 @@ export const ViewListSetterProvider: FC<ProviderProps> = (props) => {
136153
dispatch(componentsActions.addComponentReducer([newChildrenNodes]))
137154
},
138155
[
139-
viewsList,
140-
componentNode.displayName,
141156
allViewsKeys,
142-
handleUpdateMultiAttrDSL,
143157
attrPath,
158+
componentNode.displayName,
144159
dispatch,
160+
handleUpdateMultiAttrDSL,
161+
viewsList,
145162
],
146163
)
147164

148165
const handleUpdateCurrentViewIndex = useCallback(
149166
(index: number) => {
150167
if (index > viewsList.length || index < 0) return
151168
const currentViewKey = allViews[index].key
152-
handleUpdateMultiAttrDSL?.({
169+
handleUpdateExecutionResult?.(widgetDisplayName, {
153170
currentIndex: index,
154171
currentKey: currentViewKey || index,
155172
})
173+
if (linkWidgetDisplayName) {
174+
if (Array.isArray(linkWidgetDisplayName)) {
175+
linkWidgetDisplayName.forEach((linkDisplayName) => {
176+
handleUpdateExecutionResult?.(linkDisplayName, {
177+
currentIndex: index,
178+
currentKey: currentViewKey || index,
179+
})
180+
})
181+
} else {
182+
handleUpdateExecutionResult?.(linkWidgetDisplayName, {
183+
currentIndex: index,
184+
currentKey: currentViewKey || index,
185+
})
186+
const linkWidgetLinkedDisplayName = get(
187+
executionResult,
188+
`${linkWidgetDisplayName}.linkWidgetDisplayName`,
189+
[],
190+
)
191+
linkWidgetLinkedDisplayName &&
192+
Array.isArray(linkWidgetLinkedDisplayName) &&
193+
linkWidgetLinkedDisplayName.forEach((name) => {
194+
name !== widgetDisplayName &&
195+
handleUpdateExecutionResult?.(name, {
196+
currentIndex: index,
197+
currentKey: currentViewKey || index,
198+
})
199+
})
200+
}
201+
}
156202
},
157-
[allViews, handleUpdateMultiAttrDSL, viewsList.length],
203+
[
204+
allViews,
205+
executionResult,
206+
handleUpdateExecutionResult,
207+
linkWidgetDisplayName,
208+
viewsList.length,
209+
widgetDisplayName,
210+
],
158211
)
159212

160213
const handleMoveOptionItem = useCallback(

apps/builder/src/page/App/components/InspectPanel/PanelSetters/ContainerSetter/ViewsSetter/index.tsx

Lines changed: 79 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ const ViewsSetter: FC<ViewSetterProps> = memo((props: ViewSetterProps) => {
3131
attrName,
3232
widgetDisplayName,
3333
childrenSetter,
34+
handleUpdateExecutionResult,
3435
handleUpdateMultiAttrDSL,
3536
handleUpdateOtherMultiAttrDSL,
3637
componentNode,
3738
} = props
3839
const { t } = useTranslation()
3940
const executionResult = useSelector(getExecutionResult)
40-
4141
const dispatch = useDispatch()
4242

4343
const targetComponentProps = useSelector<RootState, Record<string, any>>(
@@ -67,13 +67,32 @@ const ViewsSetter: FC<ViewSetterProps> = memo((props: ViewSetterProps) => {
6767
(updateSlice: Record<string, unknown>) => {
6868
handleUpdateMultiAttrDSL?.(updateSlice)
6969
if (linkWidgetDisplayName) {
70-
handleUpdateOtherMultiAttrDSL?.(linkWidgetDisplayName, updateSlice)
70+
if (Array.isArray(linkWidgetDisplayName)) {
71+
linkWidgetDisplayName.forEach((linkDisplayName) => {
72+
handleUpdateOtherMultiAttrDSL?.(linkDisplayName, updateSlice)
73+
})
74+
} else {
75+
handleUpdateOtherMultiAttrDSL?.(linkWidgetDisplayName, updateSlice)
76+
const linkWidgetLinkedDisplayName = get(
77+
executionResult,
78+
`${linkWidgetDisplayName}.linkWidgetDisplayName`,
79+
[],
80+
)
81+
linkWidgetLinkedDisplayName &&
82+
Array.isArray(linkWidgetLinkedDisplayName) &&
83+
linkWidgetLinkedDisplayName.forEach((name) => {
84+
name !== widgetDisplayName &&
85+
handleUpdateOtherMultiAttrDSL?.(name, updateSlice)
86+
})
87+
}
7188
}
7289
},
7390
[
91+
executionResult,
7492
handleUpdateMultiAttrDSL,
7593
handleUpdateOtherMultiAttrDSL,
7694
linkWidgetDisplayName,
95+
widgetDisplayName,
7796
],
7897
)
7998

@@ -83,15 +102,38 @@ const ViewsSetter: FC<ViewSetterProps> = memo((props: ViewSetterProps) => {
83102
[attrName]: value,
84103
})
85104
if (linkWidgetDisplayName) {
86-
handleUpdateOtherMultiAttrDSL?.(linkWidgetDisplayName, {
87-
[attrName]: value,
88-
})
105+
if (Array.isArray(linkWidgetDisplayName)) {
106+
linkWidgetDisplayName.forEach((linkDisplayName) => {
107+
handleUpdateOtherMultiAttrDSL?.(linkDisplayName, {
108+
[attrName]: value,
109+
})
110+
})
111+
} else {
112+
handleUpdateOtherMultiAttrDSL?.(linkWidgetDisplayName, {
113+
[attrName]: value,
114+
})
115+
const linkWidgetLinkedDisplayName = get(
116+
executionResult,
117+
`${linkWidgetDisplayName}.linkWidgetDisplayName`,
118+
[],
119+
)
120+
linkWidgetLinkedDisplayName &&
121+
Array.isArray(linkWidgetLinkedDisplayName) &&
122+
linkWidgetLinkedDisplayName.forEach((name) => {
123+
name !== widgetDisplayName &&
124+
handleUpdateOtherMultiAttrDSL?.(name, {
125+
[attrName]: value,
126+
})
127+
})
128+
}
89129
}
90130
},
91131
[
92132
handleUpdateMultiAttrDSL,
93-
handleUpdateOtherMultiAttrDSL,
94133
linkWidgetDisplayName,
134+
handleUpdateOtherMultiAttrDSL,
135+
executionResult,
136+
widgetDisplayName,
95137
],
96138
)
97139

@@ -117,20 +159,43 @@ const ViewsSetter: FC<ViewSetterProps> = memo((props: ViewSetterProps) => {
117159
[attrName]: [...value, newItem],
118160
})
119161
if (linkWidgetDisplayName) {
120-
handleUpdateOtherMultiAttrDSL?.(linkWidgetDisplayName, {
121-
[attrName]: [...value, newItem],
122-
})
162+
if (Array.isArray(linkWidgetDisplayName)) {
163+
linkWidgetDisplayName.forEach((linkDisplayName) => {
164+
handleUpdateOtherMultiAttrDSL?.(linkDisplayName, {
165+
[attrName]: [...value, newItem],
166+
})
167+
})
168+
} else {
169+
handleUpdateOtherMultiAttrDSL?.(linkWidgetDisplayName, {
170+
[attrName]: [...value, newItem],
171+
})
172+
const linkWidgetLinkedDisplayName = get(
173+
executionResult,
174+
`${linkWidgetDisplayName}.linkWidgetDisplayName`,
175+
[],
176+
)
177+
linkWidgetLinkedDisplayName &&
178+
Array.isArray(linkWidgetLinkedDisplayName) &&
179+
linkWidgetLinkedDisplayName.forEach((name) => {
180+
name !== widgetDisplayName &&
181+
handleUpdateOtherMultiAttrDSL?.(name, {
182+
[attrName]: [...value, newItem],
183+
})
184+
})
185+
}
123186
}
124187
dispatch(componentsActions.addComponentReducer([newChildrenNodes]))
125188
}, [
126-
allViewsKeys,
127189
_componentNode?.displayName,
128-
handleUpdateMultiAttrDSL,
190+
allViewsKeys,
129191
attrName,
130-
value,
131-
linkWidgetDisplayName,
132192
dispatch,
193+
executionResult,
194+
handleUpdateMultiAttrDSL,
133195
handleUpdateOtherMultiAttrDSL,
196+
linkWidgetDisplayName,
197+
value,
198+
widgetDisplayName,
134199
])
135200

136201
return (
@@ -141,6 +206,7 @@ const ViewsSetter: FC<ViewSetterProps> = memo((props: ViewSetterProps) => {
141206
attrPath={attrName}
142207
handleUpdateDsl={handleUpdateDsl}
143208
handleUpdateMultiAttrDSL={updateMultiAttrDSL}
209+
handleUpdateExecutionResult={handleUpdateExecutionResult}
144210
handleUpdateOtherMultiAttrDSL={handleUpdateOtherMultiAttrDSL}
145211
componentNode={_componentNode}
146212
>

apps/builder/src/page/App/components/InspectPanel/PanelSetters/ContainerSetter/ViewsSetter/listBody.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ export const ListBody: FC = () => {
6666
)
6767
}, [
6868
items,
69-
currentSelected,
70-
attrPath,
71-
componentNode,
7269
handleUpdateMultiAttrDSL,
70+
attrPath,
7371
dispatch,
72+
componentNode.displayName,
73+
currentSelected.key,
7474
])
7575

7676
useEffect(() => {

apps/builder/src/page/App/components/InspectPanel/PanelSetters/ContainerSetter/defaultViewKeySetter.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ const ContainerDefaultViewKeySetter: FC<ContainerDefaultViewKeySetterProps> = (
4545
currentIndex,
4646
currentKey,
4747
})
48-
if (linkWidgetDisplayName) {
49-
handleUpdateOtherMultiAttrDSL?.(linkWidgetDisplayName, {
50-
currentIndex,
51-
currentKey,
48+
if (linkWidgetDisplayName && Array.isArray(linkWidgetDisplayName)) {
49+
linkWidgetDisplayName.forEach((name) => {
50+
handleUpdateOtherMultiAttrDSL?.(name, {
51+
currentIndex,
52+
currentKey,
53+
})
5254
})
5355
}
5456
},

apps/builder/src/page/App/components/InspectPanel/PanelSetters/SwitchSetter/dynamicSwitch.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ const DynamicSwitchSetter: FC<DynamicSwitchProps> = (props) => {
1818
attrName,
1919
labelName,
2020
labelDesc,
21-
panelConfig,
2221
handleUpdateDsl,
2322
defaultValue,
2423
handleUpdateMultiAttrDSL,
2524
value,
2625
openDynamic,
2726
detailedDescription,
2827
widgetType,
28+
componentNode,
2929
} = props
3030

31-
const customSelected = get(panelConfig, `${attrName}Dynamic`, false)
31+
const customSelected = get(componentNode, `props.${attrName}Dynamic`, false)
3232

3333
const handleClickDynamicIcon = useCallback(() => {
3434
if (customSelected) {

apps/builder/src/page/App/components/InspectPanel/PanelSetters/SwitchSetter/interface.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ export interface BaseSwitchProps extends BaseSetter {
1010
}
1111

1212
export interface DynamicSwitchProps extends BaseSetter, PanelLabelProps {
13-
panelConfig: Record<string, any>
1413
openDynamic?: boolean
1514
value?: string | boolean
1615
}

0 commit comments

Comments
 (0)