Skip to content

Commit 6d5fbfd

Browse files
update actions
1 parent 84c165b commit 6d5fbfd

File tree

3 files changed

+44
-27
lines changed

3 files changed

+44
-27
lines changed

client/packages/lowcoder/src/comps/comps/chatComp/components/ChatMain.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,27 +119,27 @@ export function ChatMain(props: ChatCompProps) {
119119
// const layout = comp.children.layout.getView();
120120
// console.log("LAYOUT", layout);
121121

122-
for (const action of actions) {
123-
const { action_name, action_parameters, action_payload } = action;
122+
for (const actionItem of actions) {
123+
const { action, component, ...action_payload } = actionItem;
124124

125-
switch (action_name) {
125+
switch (action) {
126126
case "place_component":
127127
await addComponentAction.execute({
128-
actionKey: action_name,
128+
actionKey: action,
129129
actionValue: "",
130130
actionPayload: action_payload,
131-
selectedComponent: action_parameters,
131+
selectedComponent: component,
132132
selectedEditorComponent: null,
133133
selectedNestComponent: null,
134134
editorState: editorStateRef.current
135135
});
136136
break;
137137
case "nest_component":
138138
await nestComponentAction.execute({
139-
actionKey: action_name,
139+
actionKey: action,
140140
actionValue: "",
141141
actionPayload: action_payload,
142-
selectedComponent: action_parameters,
142+
selectedComponent: component,
143143
selectedEditorComponent: null,
144144
selectedNestComponent: null,
145145
editorState: editorStateRef.current
@@ -148,8 +148,8 @@ export function ChatMain(props: ChatCompProps) {
148148
case "set_properties":
149149
debugger;
150150
await configureComponentAction.execute({
151-
actionKey: action_name,
152-
actionValue: action_parameters,
151+
actionKey: action,
152+
actionValue: component,
153153
actionPayload: action_payload,
154154
selectedEditorComponent: null,
155155
selectedComponent: null,
@@ -190,7 +190,7 @@ export function ChatMain(props: ChatCompProps) {
190190
modelType: props.modelType!,
191191
sessionId: state.currentThreadId,
192192
});
193-
const {reply, actions: editorActions} = JSON.parse(response?.output);
193+
const {explanation: reply, actions: editorActions} = JSON.parse(response?.output);
194194
performAction(editorActions);
195195

196196
const assistantMessage: MyMessage = {
@@ -252,7 +252,7 @@ export function ChatMain(props: ChatCompProps) {
252252
sessionId: state.currentThreadId,
253253
});
254254

255-
const {reply, actions: editorActions} = JSON.parse(response?.output);
255+
const {explanation: reply, actions: editorActions} = JSON.parse(response?.output);
256256
performAction(editorActions);
257257

258258
const assistantMessage: MyMessage = {

client/packages/lowcoder/src/comps/comps/preLoadComp/actions/componentManagement.ts

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
} from "lowcoder-core";
1515
import { getEditorComponentInfo } from "../utils";
1616
import { getPromiseAfterDispatch } from "@lowcoder-ee/util/promiseUtils";
17+
import { hookCompCategory, HookCompType } from "@lowcoder-ee/comps/hooks/hookCompTypes";
1718

1819
export const addComponentAction: ActionConfig = {
1920
key: 'add-components',
@@ -23,14 +24,29 @@ export const addComponentAction: ActionConfig = {
2324
requiresInput: false,
2425
execute: async (params: ActionExecuteParams) => {
2526
const { selectedComponent, editorState, actionPayload } = params;
26-
const { name, layout, ...otherProps } = actionPayload;
27+
const { component_name: name, layout, action_parameters } = actionPayload;
2728

2829
if (!selectedComponent || !editorState) {
2930
message.error('Component and editor state are required');
3031
return;
3132
}
3233

3334
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+
3450
const uiComp = editorState.getUIComp();
3551
const container = uiComp.getComp();
3652

@@ -63,7 +79,7 @@ export const addComponentAction: ActionConfig = {
6379
let compDefaultValue = defaultDataFn ? defaultDataFn(compName, nameGenerator, editorState) : undefined;
6480
const compInitialValue = {
6581
...(compDefaultValue as any || {}),
66-
...otherProps,
82+
...action_parameters,
6783
}
6884
const widgetValue: GridItemDataType = {
6985
compType: selectedComponent,
@@ -139,29 +155,30 @@ export const nestComponentAction: ActionConfig = {
139155
execute: async (params: ActionExecuteParams) => {
140156
// const { selectedEditorComponent, selectedNestComponent, editorState, actionPayload } = params;
141157
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;
143160

144161
if (!selectedEditorComponent || !selectedNestComponent || !editorState) {
145162
message.error('Parent component, child component, and editor state are required');
146163
return;
147164
}
148165

149166
const [editorComponent, ...childComponents] = selectedEditorComponent.split('.');
150-
const parentComponentInfo = getEditorComponentInfo(editorState, editorComponent);
167+
const parentItem = editorState.getUICompByName(editorComponent); //getEditorComponentInfo(editorState, editorComponent);
151168

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+
// }
156173

157-
const { componentKey: parentKey, items } = parentComponentInfo;
174+
// const { componentKey: parentKey, items } = parentComponentInfo;
158175

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+
// }
163180

164-
const parentItem = items[parentKey];
181+
// const parentItem = items[parentKey];
165182
if (!parentItem) {
166183
message.error(`Parent component "${selectedEditorComponent}" not found in items`);
167184
return;
@@ -204,7 +221,7 @@ export const nestComponentAction: ActionConfig = {
204221
let compDefaultValue = defaultDataFn ? defaultDataFn(compName, nameGenerator, editorState) : undefined;
205222
const compInitialValue = {
206223
...(compDefaultValue as any || {}),
207-
...otherProps,
224+
...action_parameters,
208225
}
209226

210227
const widgetValue: GridItemDataType = {

client/packages/lowcoder/src/pages/editor/bottom/BottomPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function Bottom(props: any) {
125125
// systemPrompt="You are a helpful assistant."
126126
// agent={true}
127127
// maxInteractions={10}
128-
modelHost="http://192.168.100.49:5678/webhook/9a363e76-d3a5-46d1-98c3-4359f7106d33"
128+
modelHost="http://192.168.100.59:5678/webhook/9a363e76-d3a5-46d1-98c3-4359f7106d33"
129129
/>
130130
</Flex>
131131
)}

0 commit comments

Comments
 (0)