@@ -14,6 +14,7 @@ import {
14
14
} from "lowcoder-core" ;
15
15
import { getEditorComponentInfo } from "../utils" ;
16
16
import { getPromiseAfterDispatch } from "@lowcoder-ee/util/promiseUtils" ;
17
+ import { hookCompCategory , HookCompType } from "@lowcoder-ee/comps/hooks/hookCompTypes" ;
17
18
18
19
export const addComponentAction : ActionConfig = {
19
20
key : 'add-components' ,
@@ -23,14 +24,29 @@ export const addComponentAction: ActionConfig = {
23
24
requiresInput : false ,
24
25
execute : async ( params : ActionExecuteParams ) => {
25
26
const { selectedComponent, editorState, actionPayload } = params ;
26
- const { name, layout, ... otherProps } = actionPayload ;
27
+ const { component_name : name , layout, action_parameters } = actionPayload ;
27
28
28
29
if ( ! selectedComponent || ! editorState ) {
29
30
message . error ( 'Component and editor state are required' ) ;
30
31
return ;
31
32
}
32
33
33
34
try {
35
+ if ( hookCompCategory ( selectedComponent ) === "ui" ) {
36
+ const compName = Boolean ( name ) ? name : editorState . getNameGenerator ( ) . genItemName ( selectedComponent ) ;
37
+ editorState
38
+ . getHooksComp ( )
39
+ . dispatch (
40
+ wrapActionExtraInfo (
41
+ editorState
42
+ . getHooksComp ( )
43
+ . pushAction ( { name : compName , compType : selectedComponent as HookCompType } ) ,
44
+ { compInfos : [ { compName : compName , compType : selectedComponent , type : "add" } ] }
45
+ )
46
+ ) ;
47
+ return ;
48
+ }
49
+
34
50
const uiComp = editorState . getUIComp ( ) ;
35
51
const container = uiComp . getComp ( ) ;
36
52
@@ -63,7 +79,7 @@ export const addComponentAction: ActionConfig = {
63
79
let compDefaultValue = defaultDataFn ? defaultDataFn ( compName , nameGenerator , editorState ) : undefined ;
64
80
const compInitialValue = {
65
81
...( compDefaultValue as any || { } ) ,
66
- ...otherProps ,
82
+ ...action_parameters ,
67
83
}
68
84
const widgetValue : GridItemDataType = {
69
85
compType : selectedComponent ,
@@ -139,29 +155,30 @@ export const nestComponentAction: ActionConfig = {
139
155
execute : async ( params : ActionExecuteParams ) => {
140
156
// const { selectedEditorComponent, selectedNestComponent, editorState, actionPayload } = params;
141
157
const { editorState, actionPayload, selectedComponent : selectedNestComponent } = params ;
142
- const { name, layout, target : selectedEditorComponent , ...otherProps } = actionPayload ;
158
+ const { component_name : name , layout, parent_component_name : selectedEditorComponent , action_parameters } = actionPayload ;
159
+ // const { name, layout, target: selectedEditorComponent, ...otherProps } = actionPayload;
143
160
144
161
if ( ! selectedEditorComponent || ! selectedNestComponent || ! editorState ) {
145
162
message . error ( 'Parent component, child component, and editor state are required' ) ;
146
163
return ;
147
164
}
148
165
149
166
const [ editorComponent , ...childComponents ] = selectedEditorComponent . split ( '.' ) ;
150
- const parentComponentInfo = getEditorComponentInfo ( editorState , editorComponent ) ;
167
+ const parentItem = editorState . getUICompByName ( editorComponent ) ; // getEditorComponentInfo(editorState, editorComponent);
151
168
152
- if ( ! parentComponentInfo ) {
153
- message . error ( `Parent component "${ selectedEditorComponent } " not found` ) ;
154
- return ;
155
- }
169
+ // if (!parentComponentInfo) {
170
+ // message.error(`Parent component "${selectedEditorComponent}" not found`);
171
+ // return;
172
+ // }
156
173
157
- const { componentKey : parentKey , items } = parentComponentInfo ;
174
+ // const { componentKey: parentKey, items } = parentComponentInfo;
158
175
159
- if ( ! parentKey ) {
160
- message . error ( `Parent component "${ selectedEditorComponent } " not found in layout` ) ;
161
- return ;
162
- }
176
+ // if (!parentKey) {
177
+ // message.error(`Parent component "${selectedEditorComponent}" not found in layout`);
178
+ // return;
179
+ // }
163
180
164
- const parentItem = items [ parentKey ] ;
181
+ // const parentItem = items[parentKey];
165
182
if ( ! parentItem ) {
166
183
message . error ( `Parent component "${ selectedEditorComponent } " not found in items` ) ;
167
184
return ;
@@ -204,7 +221,7 @@ export const nestComponentAction: ActionConfig = {
204
221
let compDefaultValue = defaultDataFn ? defaultDataFn ( compName , nameGenerator , editorState ) : undefined ;
205
222
const compInitialValue = {
206
223
...( compDefaultValue as any || { } ) ,
207
- ...otherProps ,
224
+ ...action_parameters ,
208
225
}
209
226
210
227
const widgetValue : GridItemDataType = {
0 commit comments