Added pinned property on node

This commit is contained in:
Lucas Oliveira 2024-01-24 17:25:04 +01:00
commit 020f43b9f6
5 changed files with 35 additions and 5 deletions

View file

@ -107,6 +107,7 @@ export default function GenericNode({
}, [flowPool, data.id]); }, [flowPool, data.id]);
const showNode = data.showNode ?? true; const showNode = data.showNode ?? true;
const pinned = data.pinned ?? true;
const nameEditable = data.node?.flow || data.type === "CustomComponent"; const nameEditable = data.node?.flow || data.type === "CustomComponent";
@ -204,7 +205,7 @@ export default function GenericNode({
) : ( ) : (
<ShadTooltip content={data.node?.display_name}> <ShadTooltip content={data.node?.display_name}>
<div <div
className="flex" className="flex items-center gap-2"
onDoubleClick={() => { onDoubleClick={() => {
setInputName(true); setInputName(true);
takeSnapshot(); takeSnapshot();
@ -212,7 +213,7 @@ export default function GenericNode({
> >
<div <div
data-testid={"title-" + data.node?.display_name} data-testid={"title-" + data.node?.display_name}
className="generic-node-tooltip-div pr-2 text-primary" className="generic-node-tooltip-div text-primary"
> >
{data.node?.display_name} {data.node?.display_name}
</div> </div>
@ -318,7 +319,32 @@ export default function GenericNode({
</> </>
)} )}
</div> </div>
{showNode && (
<div
className="round-button-div"
onClick={() => {
setNode(data.id, (old) => ({
...old,
data: {
...old.data,
pinned: old?.data?.pinned ? false : true,
},
}));
}}
>
<div className="generic-node-status-position flex items-center">
<IconComponent
name={"Pin"}
className={cn(
"h-5 fill-transparent stroke-chat-trigger stroke-2 transition-all",
pinned ?? false
? "animate-wiggle fill-chat-trigger"
: ""
)}
/>
</div>
</div>
)}
{showNode && ( {showNode && (
<div <div
className="round-button-div" className="round-button-div"
@ -351,7 +377,7 @@ export default function GenericNode({
) )
} }
> >
<div className="generic-node-status-position"> <div className="generic-node-status-position flex items-center">
<div <div
className={classNames( className={classNames(
validationStatus && validationStatus.valid validationStatus && validationStatus.valid

View file

@ -134,6 +134,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
? change(get().nodes.find((node) => node.id === id)!) ? change(get().nodes.find((node) => node.id === id)!)
: change; : change;
console.log(newChange);
get().setNodes((oldNodes) => get().setNodes((oldNodes) =>
oldNodes.map((node) => { oldNodes.map((node) => {
if (node.id === id) { if (node.id === id) {

View file

@ -267,7 +267,7 @@
@apply relative flex flex-col justify-center bg-background; @apply relative flex flex-col justify-center bg-background;
} }
.generic-node-div-title { .generic-node-div-title {
@apply flex w-full items-center gap-8 border-b bg-muted p-4; @apply flex w-full items-center gap-4 border-b bg-muted p-4;
} }
.generic-node-title-arrangement { .generic-node-title-arrangement {
@apply flex-max-width items-center truncate; @apply flex-max-width items-center truncate;

View file

@ -21,6 +21,7 @@ export type NodeType = {
export type NodeDataType = { export type NodeDataType = {
showNode?: boolean; showNode?: boolean;
pinned?: boolean;
type: string; type: string;
node?: APIClassType; node?: APIClassType;
id: string; id: string;

View file

@ -68,6 +68,7 @@ import {
Network, Network,
Paperclip, Paperclip,
Pencil, Pencil,
Pin,
Plus, Plus,
Redo, Redo,
RefreshCcw, RefreshCcw,
@ -378,6 +379,7 @@ export const nodeIconsLucide: iconsType = {
Loader2, Loader2,
BookmarkPlus, BookmarkPlus,
Heart, Heart,
Pin,
Link, Link,
ToyBrick, ToyBrick,
RefreshCcw, RefreshCcw,