Skip to content
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

refactor: handle rendering and filtering functionality #3512

Merged
merged 57 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from 54 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
c84a744
Added handleDragging and filterType to store
lucaseduoli Aug 22, 2024
0e2cb8d
passed nodeId to handle render
lucaseduoli Aug 22, 2024
34d03af
Changed handle render to show new style of edge and to support connec…
lucaseduoli Aug 22, 2024
b95a063
Updated handletooltipcomponent to show only type
lucaseduoli Aug 22, 2024
524a13b
Added classes to ensure the handles are always centered
lucaseduoli Aug 22, 2024
77b9d89
Removed unused component
lucaseduoli Aug 22, 2024
e874ac6
Modularized conditions and centralized handle without arbitrary values
lucaseduoli Aug 22, 2024
fef4e23
Unfiltered sidebar when connecting
lucaseduoli Aug 22, 2024
a90362d
Fixed bg of white part not being transparent
lucaseduoli Aug 23, 2024
9b6f36f
Add new Filter button with tooltip explaining what is filtered
lucaseduoli Aug 23, 2024
8b2627d
Added text to instruct user to click to filter on handles
lucaseduoli Aug 23, 2024
f783916
Added custom edge and edge type
lucaseduoli Aug 23, 2024
08a2d9b
add updateEdgeStatus and updated it on start and stop build
lucaseduoli Aug 23, 2024
435312e
Deleted running edge and made styling be applied directly to edge
lucaseduoli Aug 23, 2024
8ecb5c3
Update flowstore type
lucaseduoli Aug 23, 2024
1cbc303
Add update edges on build error as well
lucaseduoli Aug 23, 2024
872a514
Added better tooltip
lucaseduoli Aug 26, 2024
b8174fd
✅ (filterSidebar.spec.ts): add tests to ensure visibility of filter i…
Cristhianzl Aug 26, 2024
38c7ad8
📝 (frontend/tests): Remove unnecessary imports and improve test descr…
Cristhianzl Aug 26, 2024
2862473
🐛 (generalBugs-shard-5.spec.ts): fix test case to correctly evaluate …
Cristhianzl Aug 26, 2024
c824ace
Fixed edge not coming from center of handle
lucaseduoli Aug 26, 2024
8d2b888
Add new filter colors
lucaseduoli Aug 28, 2024
d9c160b
Added new icons
lucaseduoli Aug 28, 2024
d1c7e76
Changed sidebar to show a filter component
lucaseduoli Aug 28, 2024
5a42eb5
Deleted old filter
lucaseduoli Aug 28, 2024
c6a177e
changed title classes
lucaseduoli Aug 28, 2024
21928a0
changed css classes
lucaseduoli Aug 28, 2024
9d5037d
changed tooltip to new iteration
lucaseduoli Aug 28, 2024
b1fb960
added required parameter to handle tooltip
lucaseduoli Aug 28, 2024
4265a0e
Modularized sidebar filter
lucaseduoli Aug 28, 2024
7a686e0
[autofix.ci] apply automated fixes
autofix-ci[bot] Aug 28, 2024
cac5fa3
Changed handle tooltip to handle isInput in the instructions
lucaseduoli Aug 28, 2024
ed7148f
Changed sidebar filter to be gray
lucaseduoli Aug 28, 2024
7f19c71
Removed icon of handle
lucaseduoli Sep 10, 2024
4427747
Update radius of connection
lucaseduoli Sep 10, 2024
85fbae0
Merge branch 'main' into feat/handle_refactor
lucaseduoli Sep 12, 2024
60d90ea
Added tests back
lucaseduoli Sep 12, 2024
ab932e5
Fixed right click problem
lucaseduoli Sep 13, 2024
f35052a
Fixed size of hover and connect
lucaseduoli Sep 13, 2024
ff0aab8
Changed color of disabled handle
lucaseduoli Sep 13, 2024
38636fa
Implemented message when connecting compatible and incompatible handles
lucaseduoli Sep 13, 2024
522525f
Changed style and added isSameNode
lucaseduoli Sep 13, 2024
a3a4758
Added check to not allow the same node to connect
lucaseduoli Sep 13, 2024
ee29742
Fixed tooltip info not appearing when the same handle is hovered
lucaseduoli Sep 13, 2024
ac0fcdc
update order of calls on reactFlowUtils
lucaseduoli Sep 13, 2024
a78826d
Implement multiple types
lucaseduoli Sep 13, 2024
371f916
Merge remote-tracking branch 'origin/main' into feat/handle_refactor
lucaseduoli Sep 13, 2024
ddccb1f
Added useMemo to improve performance and fixed same node checks
lucaseduoli Sep 13, 2024
47c497b
Fixed tooltip flashing when opening
lucaseduoli Sep 13, 2024
c61f80a
Merge branch 'main' into feat/handle_refactor
lucaseduoli Sep 13, 2024
a3e8406
Merge branch 'main' into feat/handle_refactor
Cristhianzl Sep 13, 2024
bb580a6
refactor: update handle test IDs in generalBugs-shard-5.spec.ts
Cristhianzl Sep 13, 2024
061fea3
refactor: update handle test IDs and remove unused code in filterSide…
Cristhianzl Sep 13, 2024
2aac45e
feat: Update handle test IDs and improve rendering logic
Cristhianzl Sep 13, 2024
3c00083
refactor: Add test ID to handle tooltip component
Cristhianzl Sep 13, 2024
39e9099
refactor: Update handle test IDs and improve rendering logic
Cristhianzl Sep 13, 2024
2d50e0e
refactor: Remove unused code and update handle test IDs in filterSide…
Cristhianzl Sep 13, 2024
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
4 changes: 4 additions & 0 deletions src/frontend/src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ body {
transition-duration: 150ms;
}

.react-flow__edge.running .react-flow__edge-path {
stroke: var(--status-blue) !important;
}

.ag-react-container {
width: 100%;
height: 100%;
Expand Down
33 changes: 33 additions & 0 deletions src/frontend/src/CustomEdges/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import useFlowStore from "@/stores/flowStore";
import { BaseEdge, EdgeProps, getBezierPath, Position } from "reactflow";

export function DefaultEdge({
sourceHandleId,
source,
sourceX,
sourceY,
target,
targetHandleId,
targetX,
targetY,
...props
}: EdgeProps) {
const getNode = useFlowStore((state) => state.getNode);

const sourceNode = getNode(source);
const targetNode = getNode(target);

const sourceXNew = (sourceNode?.position.x ?? 0) + (sourceNode?.width ?? 0);
const targetXNew = targetNode?.position.x ?? 0;

const [edgePath] = getBezierPath({
sourceX: sourceXNew,
sourceY,
sourcePosition: Position.Right,
targetPosition: Position.Left,
targetX: targetXNew,
targetY,
});

return <BaseEdge path={edgePath} {...props} />;
}
Original file line number Diff line number Diff line change
@@ -1,30 +1,62 @@
import { TOOLTIP_EMPTY } from "../../../../constants/constants";
import useFlowStore from "../../../../stores/flowStore";
import { useTypesStore } from "../../../../stores/typesStore";
import { NodeType } from "../../../../types/flow";
import { groupByFamily } from "../../../../utils/utils";
import TooltipRenderComponent from "../tooltipRenderComponent";

export default function HandleTooltips({
left,
export default function HandleTooltipComponent({
isInput,
tooltipTitle,
colors,
isConnecting,
isCompatible,
isSameNode,
}: {
left: boolean;
nodes: NodeType[];
isInput: boolean;
colors: string[];
tooltipTitle: string;
isConnecting: boolean;
isCompatible: boolean;
isSameNode: boolean;
}) {
const myData = useTypesStore((state) => state.data);
const nodes = useFlowStore((state) => state.nodes);

let groupedObj: any = groupByFamily(myData, tooltipTitle!, left, nodes!);

if (groupedObj && groupedObj.length > 0) {
//@ts-ignore
return groupedObj.map((item, index) => {
return <TooltipRenderComponent index={index} item={item} left={left} />;
});
} else {
//@ts-ignore
return <span data-testid={`empty-tooltip-filter`}>{TOOLTIP_EMPTY}</span>;
}
const tooltips = tooltipTitle.split("\n");
const plural = tooltips.length > 1 ? "s" : "";
return (
<div className="py-1.5 font-medium text-muted-foreground">
{isSameNode ? (
"Can't connect to the same node"
) : (
<div className="flex items-start gap-1.5">
{isConnecting ? (
isCompatible ? (
<span>
<span className="font-semibold text-foreground">Connect</span>{" "}
to
</span>
) : (
<span>Incompatible with</span>
)
) : (
<span className="text-foreground">
{isInput ? `Input${plural}` : `Output${plural}`}:{" "}
</span>
)}
{tooltips.map((word, index) => (
<div
className="rounded-sm px-1.5 text-background"
style={{ backgroundColor: colors[index] }}
>
{word}
</div>
))}
{isConnecting && <span>{isInput ? `input` : `output`}</span>}
</div>
)}
{!isConnecting && (
<div className="mt-2 flex flex-col gap-0.5 text-xs">
<div>
<b>Drag</b> to connect compatible {!isInput ? "inputs" : "outputs"}
</div>
<div>
<b>Select</b> to filter compatible {!isInput ? "inputs" : "outputs"}{" "}
and components
</div>
</div>
)}
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default function NodeInputField({
setFilterEdge={setFilterEdge}
showNode={showNode}
testIdComplement={`${data?.type?.toLowerCase()}-${showNode ? "shownode" : "noshownode"}`}
nodeId={data.id}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export default function NodeOutputField({
id={id}
title={title}
edges={edges}
nodeId={data.id}
myData={myData}
colors={colors}
setFilterEdge={setFilterEdge}
Expand Down
Loading
Loading