diff --git a/packages/app/src/components/ApiTree/ApiTree.tsx b/packages/app/src/components/ApiTree/ApiTree.tsx index 190f0a5..aa33940 100644 --- a/packages/app/src/components/ApiTree/ApiTree.tsx +++ b/packages/app/src/components/ApiTree/ApiTree.tsx @@ -92,6 +92,7 @@ export default function ApiTree(props: { position: { x: 0, y: 0 }, // Initial position, will be updated by Dagre data: { path: child.path, + isBeingDragged: false, }, type: "groupNode", }; @@ -142,6 +143,7 @@ export default function ApiTree(props: { onChangeGroup: (group: string) => props.onChangeEndpointGroup(group, endpoint), groupColor: color, + isBeingDragged: false, }, type: "endpointNode", }; @@ -197,6 +199,26 @@ export default function ApiTree(props: { } }, []); + function onNodeDragStart(_event: React.MouseEvent, node: Node) { + setNodes((nds) => + nds.map((n) => + n.id === node.id + ? { ...n, data: { ...n.data, isBeingDragged: true } } + : n, + ), + ); + } + + function onNodeDragStop(_event: React.MouseEvent, node: Node) { + setNodes((nds) => + nds.map((n) => + n.id === node.id + ? { ...n, data: { ...n.data, isBeingDragged: false } } + : n, + ), + ); + } + return (
diff --git a/packages/app/src/components/ApiTree/EndpointNode.tsx b/packages/app/src/components/ApiTree/EndpointNode.tsx index 75cce26..28eedb6 100644 --- a/packages/app/src/components/ApiTree/EndpointNode.tsx +++ b/packages/app/src/components/ApiTree/EndpointNode.tsx @@ -12,11 +12,14 @@ export default function EndpointNode( endpoint: Endpoint; onChangeGroup: (group: string) => void; groupColor?: string; + isBeingDragged: boolean; }> >, ) { return ( -
+
void; }) { + const [open, setOpen] = useState(false); const [group, setGroup] = useState(""); async function handleApply(e: FormEvent) { e.preventDefault(); - if (group === props.endpoint.group) return; - props.onChangeGroup(group); + if (group !== props.endpoint.group) { + props.onChangeGroup(group); + } + setOpen(false); } - useEffect(() => { + function handleOpenChange(open: boolean) { setGroup(props.endpoint.group || ""); - }, [props.endpoint]); + setOpen(open); + } return ( - + - {group === (props.endpoint.group || "") && ( - - - - )} - - - - + + + + + - + + + + Source: + + +
{props.endpoint.filePath}
+
+
- - - - Source: - - -
{props.endpoint.filePath}
-
-
+ + + Dependants: + + +
    + {props.endpoint.parentFilePaths.length > 0 ? ( + props.endpoint.parentFilePaths.map((parent, index) => ( +
  • {parent}
  • + )) + ) : ( +
  • No dependants
  • + )} +
+
+
- - - Dependants: - - -
    - {props.endpoint.parentFilePaths.length > 0 ? ( - props.endpoint.parentFilePaths.map((parent, index) => ( -
  • {parent}
  • - )) - ) : ( -
  • No dependants
  • - )} -
-
-
+ + + Dependencies: + + +
    + {props.endpoint.childrenFilePaths.length > 0 ? ( + props.endpoint.childrenFilePaths.map((child, index) => ( +
  • {child}
  • + )) + ) : ( +
  • No dependencies
  • + )} +
+
+
+
- - - Dependencies: - - -
    - {props.endpoint.childrenFilePaths.length > 0 ? ( - props.endpoint.childrenFilePaths.map((child, index) => ( -
  • {child}
  • - )) - ) : ( -
  • No dependencies
  • - )} -
-
-
-
+
+ + + + +
+
); diff --git a/packages/app/src/components/ApiTree/GroupNode.tsx b/packages/app/src/components/ApiTree/GroupNode.tsx index f86a30a..8a9ef6d 100644 --- a/packages/app/src/components/ApiTree/GroupNode.tsx +++ b/packages/app/src/components/ApiTree/GroupNode.tsx @@ -1,8 +1,12 @@ import { Handle, Node, NodeProps, Position } from "@xyflow/react"; -export default function GroupNode(props: NodeProps>) { +export default function GroupNode( + props: NodeProps>, +) { return ( -
+
-
+
- logo - NanoAPI + logo + NanoAPI
{chartLoading ? (
diff --git a/packages/app/src/service/dagree.ts b/packages/app/src/service/dagree.ts index 8488f03..9f63466 100644 --- a/packages/app/src/service/dagree.ts +++ b/packages/app/src/service/dagree.ts @@ -4,12 +4,19 @@ import dagre from "@dagrejs/dagre"; function getNodeHeight(node: Node, isHorizontal: boolean) { if (isHorizontal) { if (node.type === "groupNode") { - return 100; + return 80; } if (node.type === "endpointNode") { - return 200; + return 150; } } + + if (node.type === "groupNode") { + return 80; + } else if (node.type === "endpointNode") { + return 150; + } + return 100; } diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index 177907f..05b801d 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -3,6 +3,7 @@ ## [Unreleased] Use indexes when editing file instead of search/replace +Some UX changes ## [0.0.16] - 2024-10-30