Skip to content

Add link to edit module #444

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions client/packages/lowcoder-design/src/components/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -134,6 +135,7 @@ const EditPopover = (props: EditPopoverProps) => {
items,
addText,
add,
edit,
rename,
copy,
del,
Expand Down Expand Up @@ -193,6 +195,17 @@ const EditPopover = (props: EditPopoverProps) => {
<HandleText>{addText || trans("addItem")}</HandleText>
</Handle>
)}
{edit && (
<Handle
onClick={(e) => {
e.stopPropagation();
edit?.();
hide();
}}
>
<HandleText>{trans("edit")}</HandleText>
</Handle>
)}
{copy && (
<Handle
onClick={(e) => {
Expand Down
22 changes: 16 additions & 6 deletions client/packages/lowcoder/src/components/CompName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,22 @@ export const CompName = (props: Iprops) => {
style={{ color: showSearch ? "#315EFB" : "#8B8FA3" }}
/>
)}
<EditPopover
items={items}
del={() => GridCompOperator.deleteComp(editorState, editorState.selectedComps())}
>
<Icon tabIndex={-1} />
</EditPopover>
{ compType === "module" ? (
<EditPopover
items={items}
edit={() => GridCompOperator.editComp(editorState)}
del={() => GridCompOperator.deleteComp(editorState, editorState.selectedComps())}
>
<Icon tabIndex={-1} />
</EditPopover>
) : (
<EditPopover
items={items}
del={() => GridCompOperator.deleteComp(editorState, editorState.selectedComps())}
>
<Icon tabIndex={-1} />
</EditPopover>
)}
</CompDiv>
);
return (
Expand Down
7 changes: 7 additions & 0 deletions client/packages/lowcoder/src/comps/utils/gridCompOperator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<string, Comp>) {
this.copyComp(editorState, compRecords) &&
this.doDelete(editorState, compRecords) &&
Expand Down