Skip to content

Commit 25b0f43

Browse files
added delete_component action
1 parent cc90557 commit 25b0f43

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import styled from "styled-components";
2121
import { trans } from "i18n";
2222
import { EditorContext, EditorState } from "@lowcoder-ee/comps/editorState";
2323
import { configureComponentAction } from "../../preLoadComp/actions/componentConfiguration";
24-
import { addComponentAction, moveComponentAction, nestComponentAction, resizeComponentAction } from "../../preLoadComp/actions/componentManagement";
24+
import { addComponentAction, deleteComponentAction, moveComponentAction, nestComponentAction, resizeComponentAction } from "../../preLoadComp/actions/componentManagement";
2525
import { applyThemeAction, configureAppMetaAction, setCanvasSettingsAction } from "../../preLoadComp/actions/appConfiguration";
2626

2727
// ============================================================================
@@ -192,6 +192,20 @@ export function ChatCoreMain({
192192
selectedCustomShortcutAction: null
193193
});
194194
break;
195+
case "delete_component":
196+
await deleteComponentAction.execute({
197+
actionKey: action,
198+
actionValue: component,
199+
actionPayload: action_payload,
200+
selectedComponent: component,
201+
selectedEditorComponent: null,
202+
selectedNestComponent: null,
203+
editorState: editorStateRef.current,
204+
selectedDynamicLayoutIndex: null,
205+
selectedTheme: null,
206+
selectedCustomShortcutAction: null
207+
});
208+
break;
195209
case "set_theme":
196210
await applyThemeAction.execute({
197211
actionKey: action,
@@ -237,7 +251,7 @@ export function ChatCoreMain({
237251
default:
238252
break;
239253
}
240-
await new Promise(resolve => setTimeout(resolve, 1000));
254+
await new Promise(resolve => setTimeout(resolve, 1500));
241255
}
242256
};
243257

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ export const deleteComponentAction: ActionConfig = {
305305
requiresEditorComponentSelection: true,
306306
requiresInput: false,
307307
execute: async (params: ActionExecuteParams) => {
308-
const { selectedEditorComponent, editorState } = params;
308+
const { actionPayload: { component_name: selectedEditorComponent }, editorState } = params;
309309

310310
if (!selectedEditorComponent || !editorState) {
311311
message.error('Component and editor state are required');
@@ -322,11 +322,6 @@ export const deleteComponentAction: ActionConfig = {
322322

323323
const { allAppComponents } = componentInfo;
324324
const targetComponent = allAppComponents.find(comp => comp.name === selectedEditorComponent);
325-
326-
if (!targetComponent) {
327-
message.error(`Component "${selectedEditorComponent}" not found in application`);
328-
return;
329-
}
330325

331326
const targetInfo = findTargetComponent(editorState, selectedEditorComponent);
332327

0 commit comments

Comments
 (0)