Skip to content

Commit f3200a7

Browse files
committed
Added a link to edit a module
1 parent 1cb9f5e commit f3200a7

File tree

3 files changed

+36
-6
lines changed

3 files changed

+36
-6
lines changed

client/packages/lowcoder-design/src/components/popover.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export interface EditPopoverProps extends PopoverProps {
122122
items?: EditPopoverItemType[]; // FIXME: refactor props below into this structure
123123
addText?: string;
124124
add?: () => void;
125+
edit?: () => void;
125126
rename?: () => void;
126127
copy?: () => void;
127128
del?: () => void;
@@ -134,6 +135,7 @@ const EditPopover = (props: EditPopoverProps) => {
134135
items,
135136
addText,
136137
add,
138+
edit,
137139
rename,
138140
copy,
139141
del,
@@ -193,6 +195,17 @@ const EditPopover = (props: EditPopoverProps) => {
193195
<HandleText>{addText || trans("addItem")}</HandleText>
194196
</Handle>
195197
)}
198+
{edit && (
199+
<Handle
200+
onClick={(e) => {
201+
e.stopPropagation();
202+
edit?.();
203+
hide();
204+
}}
205+
>
206+
<HandleText>{trans("edit")}</HandleText>
207+
</Handle>
208+
)}
196209
{copy && (
197210
<Handle
198211
onClick={(e) => {

client/packages/lowcoder/src/components/CompName.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,22 @@ export const CompName = (props: Iprops) => {
143143
style={{ color: showSearch ? "#315EFB" : "#8B8FA3" }}
144144
/>
145145
)}
146-
<EditPopover
147-
items={items}
148-
del={() => GridCompOperator.deleteComp(editorState, editorState.selectedComps())}
149-
>
150-
<Icon tabIndex={-1} />
151-
</EditPopover>
146+
{ compType === "module" ? (
147+
<EditPopover
148+
items={items}
149+
edit={() => GridCompOperator.editComp(editorState)}
150+
del={() => GridCompOperator.deleteComp(editorState, editorState.selectedComps())}
151+
>
152+
<Icon tabIndex={-1} />
153+
</EditPopover>
154+
) : (
155+
<EditPopover
156+
items={items}
157+
del={() => GridCompOperator.deleteComp(editorState, editorState.selectedComps())}
158+
>
159+
<Icon tabIndex={-1} />
160+
</EditPopover>
161+
)}
152162
</CompDiv>
153163
);
154164
return (

client/packages/lowcoder/src/comps/utils/gridCompOperator.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { CustomModal, messageInstance } from "lowcoder-design";
2727
import { pasteKey, undoKey } from "util/keyUtils";
2828
import { genRandomKey } from "./idGenerator";
2929
import { getLatestVersion, getRemoteCompType, parseCompType } from "./remote";
30+
import { APPLICATION_VIEW_URL } from "@lowcoder-ee/constants/routesURL";
3031

3132
export type CopyCompType = {
3233
layout: LayoutItem;
@@ -186,6 +187,12 @@ export class GridCompOperator {
186187
return true;
187188
}
188189

190+
static editComp(editorState: EditorState) {
191+
const selectedComp = Object.values(editorState.selectedComps())[0];
192+
const applicationId = selectedComp.children.comp.children.appId.value
193+
window.open(APPLICATION_VIEW_URL(applicationId, "edit"))
194+
}
195+
189196
static cutComp(editorState: EditorState, compRecords: Record<string, Comp>) {
190197
this.copyComp(editorState, compRecords) &&
191198
this.doDelete(editorState, compRecords) &&

0 commit comments

Comments
 (0)