From f3200a777d046368689c5bd2d3d71a41e4764065 Mon Sep 17 00:00:00 2001 From: Nikolay Angelov Date: Thu, 26 Oct 2023 02:49:23 +0300 Subject: [PATCH] Added a link to edit a module --- .../src/components/popover.tsx | 13 +++++++++++ .../lowcoder/src/components/CompName.tsx | 22 ++++++++++++++----- .../src/comps/utils/gridCompOperator.ts | 7 ++++++ 3 files changed, 36 insertions(+), 6 deletions(-) diff --git a/client/packages/lowcoder-design/src/components/popover.tsx b/client/packages/lowcoder-design/src/components/popover.tsx index 8dfb7f956..6b7c35800 100644 --- a/client/packages/lowcoder-design/src/components/popover.tsx +++ b/client/packages/lowcoder-design/src/components/popover.tsx @@ -122,6 +122,7 @@ export interface EditPopoverProps extends PopoverProps { items?: EditPopoverItemType[]; // FIXME: refactor props below into this structure addText?: string; add?: () => void; + edit?: () => void; rename?: () => void; copy?: () => void; del?: () => void; @@ -134,6 +135,7 @@ const EditPopover = (props: EditPopoverProps) => { items, addText, add, + edit, rename, copy, del, @@ -193,6 +195,17 @@ const EditPopover = (props: EditPopoverProps) => { {addText || trans("addItem")} )} + {edit && ( + { + e.stopPropagation(); + edit?.(); + hide(); + }} + > + {trans("edit")} + + )} {copy && ( { diff --git a/client/packages/lowcoder/src/components/CompName.tsx b/client/packages/lowcoder/src/components/CompName.tsx index 400d85895..cf63dbab4 100644 --- a/client/packages/lowcoder/src/components/CompName.tsx +++ b/client/packages/lowcoder/src/components/CompName.tsx @@ -143,12 +143,22 @@ export const CompName = (props: Iprops) => { style={{ color: showSearch ? "#315EFB" : "#8B8FA3" }} /> )} - GridCompOperator.deleteComp(editorState, editorState.selectedComps())} - > - - + { compType === "module" ? ( + GridCompOperator.editComp(editorState)} + del={() => GridCompOperator.deleteComp(editorState, editorState.selectedComps())} + > + + + ) : ( + GridCompOperator.deleteComp(editorState, editorState.selectedComps())} + > + + + )} ); return ( diff --git a/client/packages/lowcoder/src/comps/utils/gridCompOperator.ts b/client/packages/lowcoder/src/comps/utils/gridCompOperator.ts index 411842419..4279ed654 100644 --- a/client/packages/lowcoder/src/comps/utils/gridCompOperator.ts +++ b/client/packages/lowcoder/src/comps/utils/gridCompOperator.ts @@ -27,6 +27,7 @@ import { CustomModal, messageInstance } from "lowcoder-design"; import { pasteKey, undoKey } from "util/keyUtils"; import { genRandomKey } from "./idGenerator"; import { getLatestVersion, getRemoteCompType, parseCompType } from "./remote"; +import { APPLICATION_VIEW_URL } from "@lowcoder-ee/constants/routesURL"; export type CopyCompType = { layout: LayoutItem; @@ -186,6 +187,12 @@ export class GridCompOperator { return true; } + static editComp(editorState: EditorState) { + const selectedComp = Object.values(editorState.selectedComps())[0]; + const applicationId = selectedComp.children.comp.children.appId.value + window.open(APPLICATION_VIEW_URL(applicationId, "edit")) + } + static cutComp(editorState: EditorState, compRecords: Record) { this.copyComp(editorState, compRecords) && this.doDelete(editorState, compRecords) &&