From b32c02671d3932e52f1ec0c2e246930c2e796d23 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Wed, 5 Jun 2024 15:46:52 -0300 Subject: [PATCH 1/9] add hsitory tab section to playground --- src/frontend/src/modals/IOModal/index.tsx | 337 +++++++++++----------- 1 file changed, 173 insertions(+), 164 deletions(-) diff --git a/src/frontend/src/modals/IOModal/index.tsx b/src/frontend/src/modals/IOModal/index.tsx index 001ea4b9e..2bac1f2cb 100644 --- a/src/frontend/src/modals/IOModal/index.tsx +++ b/src/frontend/src/modals/IOModal/index.tsx @@ -19,7 +19,7 @@ import { InputOutput } from "../../constants/enums"; import useFlowStore from "../../stores/flowStore"; import useFlowsManagerStore from "../../stores/flowsManagerStore"; import { IOModalPropsType } from "../../types/components"; -import { NodeType } from "../../types/flow"; +import { NodeDataType, NodeType } from "../../types/flow"; import { updateVerticesOrder } from "../../utils/buildUtils"; import { cn } from "../../utils/utils"; import BaseModal from "../baseModal"; @@ -113,13 +113,17 @@ export default function IOModal({ setSelectedTab(inputs.length > 0 ? 1 : outputs.length > 0 ? 2 : 0); }, [allNodes.length]); + const flow_sessions = allNodes + .map((node) => (node.data as NodeDataType).node?.template["session_id"]) + .filter((session) => session !== undefined); + useEffect(() => { setSelectedViewField(startView()); - // if (haveChat) { - // getSessions().then((sessions) => { - // setSessions(sessions); - // }); - // } + if (haveChat) { + getSessions().then((sessions) => { + setSessions(sessions); + }); + } }, [open]); return ( @@ -144,175 +148,180 @@ export default function IOModal({
- {selectedTab !== 0 && ( -
+ { + setSelectedTab(Number(value)); + }} > - { - setSelectedTab(Number(value)); - }} - > -
- - {inputs.length > 0 && ( - Inputs - )} - {outputs.length > 0 && ( - Outputs - )} - {/* {haveChat && ( - History - )} */} - -
+
+ + {inputs.length > 0 && ( + Inputs + )} + {outputs.length > 0 && ( + Outputs + )} + {haveChat && History} + +
- -
- - {TEXT_INPUT_MODAL_TITLE} -
- {nodes - .filter((node) => - inputs.some((input) => input.id === node.id), - ) - .map((node, index) => { - const input = inputs.find( - (input) => input.id === node.id, - )!; - return ( -
- - -
- - {node.data.node.display_name} - -
-
-
{ - event.stopPropagation(); - setSelectedViewField(input); - }} - > - + + {nodes + .filter((node) => + inputs.some((input) => input.id === node.id), + ) + .map((node, index) => { + const input = inputs.find( + (input) => input.id === node.id, + )!; + return ( +
+ + +
+ + {node.data.node.display_name} +
-
- } - key={index} - keyValue={input.id} - > -
-
- {input && ( - - )} + +
{ + event.stopPropagation(); + setSelectedViewField(input); + }} + > +
- -
- ); - })} -
- -
- - {OUTPUTS_MODAL_TITLE} -
- {nodes - .filter((node) => - outputs.some((output) => output.id === node.id), - ) - .map((node, index) => { - const output = outputs.find( - (output) => output.id === node.id, - )!; - return ( -
- - -
- - {node.data.node.display_name} - -
-
-
{ - event.stopPropagation(); - setSelectedViewField(output); - }} - > - +
+
+ {input && ( + + )} +
+
+ +
+ ); + })} + + + {nodes + .filter((node) => + outputs.some((output) => output.id === node.id), + ) + .map((node, index) => { + const output = outputs.find( + (output) => output.id === node.id, + )!; + return ( +
+ + +
+ + {node.data.node.display_name} +
-
- } - key={index} - keyValue={output.id} - > -
-
- {output && ( - - )} + +
{ + event.stopPropagation(); + setSelectedViewField(output); + }} + > +
- + } + key={index} + keyValue={output.id} + > +
+
+ {output && ( + + )} +
+
+ +
+ ); + })} +
+ + {sessions.map((session, index) => { + return ( +
+ {session} +
+ +
+ +
+
- ); - })} - - -
- )} - +
+
+ ); + })} +
+ +
{selectedViewField && (
Date: Wed, 5 Jun 2024 18:36:17 -0300 Subject: [PATCH 2/9] Refactor: Update IOModal to handle missing session IDs in flow_sessions --- src/frontend/src/modals/IOModal/index.tsx | 26 ++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/frontend/src/modals/IOModal/index.tsx b/src/frontend/src/modals/IOModal/index.tsx index 2bac1f2cb..cbb8cb0de 100644 --- a/src/frontend/src/modals/IOModal/index.tsx +++ b/src/frontend/src/modals/IOModal/index.tsx @@ -113,9 +113,15 @@ export default function IOModal({ setSelectedTab(inputs.length > 0 ? 1 : outputs.length > 0 ? 2 : 0); }, [allNodes.length]); - const flow_sessions = allNodes - .map((node) => (node.data as NodeDataType).node?.template["session_id"]) - .filter((session) => session !== undefined); + const flow_sessions = allNodes.map((node) => { + if ((node.data as NodeDataType).node?.template["session_id"]) { + return { + id: node.id, + session_id: (node.data as NodeDataType).node?.template["session_id"] + .value, + }; + } + }); useEffect(() => { setSelectedViewField(startView()); @@ -311,8 +317,18 @@ export default function IOModal({
- -
+ +
+ f_session?.session_id === session, + ) + ? "bg-status-green" + : "bg-slate-500", + )} + >
From cca64780403f09e174975729d8c5f644330e1007 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Wed, 5 Jun 2024 22:26:09 -0300 Subject: [PATCH 3/9] Refactor IOModal to improve session display and functionality --- src/frontend/src/modals/IOModal/index.tsx | 61 +++++++++++------------ 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/src/frontend/src/modals/IOModal/index.tsx b/src/frontend/src/modals/IOModal/index.tsx index cbb8cb0de..36d495d95 100644 --- a/src/frontend/src/modals/IOModal/index.tsx +++ b/src/frontend/src/modals/IOModal/index.tsx @@ -133,12 +133,7 @@ export default function IOModal({ }, [open]); return ( - + {children} {/* TODO ADAPT TO ALL TYPES OF INPUTS AND OUTPUTS */} @@ -305,31 +300,35 @@ export default function IOModal({ {sessions.map((session, index) => { return ( -
- {session} -
- -
- -
- f_session?.session_id === session, - ) - ? "bg-status-green" - : "bg-slate-500", - )} - >
-
+
+
+ + {session} + +
+ +
+ +
+ f_session?.session_id === session, + ) + ? "bg-status-green" + : "bg-slate-500", + )} + >
+
+
From 2888c2c30bdf70b3edc6459088755cf461e96c8c Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 6 Jun 2024 16:54:41 -0300 Subject: [PATCH 4/9] almost fixing, miss delte session and delete session message --- src/frontend/src/controllers/API/index.ts | 17 ++--- .../IOModal/components/SessionView/index.tsx | 68 +++++++++++++++++++ src/frontend/src/modals/IOModal/index.tsx | 37 ++++++++-- 3 files changed, 106 insertions(+), 16 deletions(-) create mode 100644 src/frontend/src/modals/IOModal/components/SessionView/index.tsx diff --git a/src/frontend/src/controllers/API/index.ts b/src/frontend/src/controllers/API/index.ts index 8f01d1908..62cf63381 100644 --- a/src/frontend/src/controllers/API/index.ts +++ b/src/frontend/src/controllers/API/index.ts @@ -1027,7 +1027,11 @@ export async function getMessagesTable( id?: string, excludedFields?: string[], params = {}, -): Promise<{ rows: Array; columns: Array }> { +): Promise<{ + rows: Array; + columns: Array; + sessions: Array; +}> { const config = {}; if (id) { config["params"] = { flow_id: id }; @@ -1037,20 +1041,11 @@ export async function getMessagesTable( } const rows = await api.get(`${BASE_URL_API}monitor/messages`, config); const columns = extractColumnsFromRows(rows.data, mode, excludedFields); - return { rows: rows.data, columns }; -} - -export async function getSessions(id?: string): Promise> { - const config = {}; - if (id) { - config["params"] = { flow_id: id }; - } - const rows = await api.get(`${BASE_URL_API}monitor/messages`, config); const sessions = new Set(); rows.data.forEach((row) => { sessions.add(row.session_id); }); - return Array.from(sessions); + return { rows: rows.data, columns, sessions: Array.from(sessions) }; } export async function deleteMessagesFn(ids: number[]) { diff --git a/src/frontend/src/modals/IOModal/components/SessionView/index.tsx b/src/frontend/src/modals/IOModal/components/SessionView/index.tsx new file mode 100644 index 000000000..273766889 --- /dev/null +++ b/src/frontend/src/modals/IOModal/components/SessionView/index.tsx @@ -0,0 +1,68 @@ +import { + CellEditRequestEvent, + ColDef, + ColGroupDef, + SelectionChangedEvent, +} from "ag-grid-community"; +import { useState } from "react"; +import TableComponent from "../../../../components/tableComponent"; +import { Card, CardContent } from "../../../../components/ui/card"; +import useAlertStore from "../../../../stores/alertStore"; +import { useMessagesStore } from "../../../../stores/messagesStore"; +import useUpdateMessage from "../../../../pages/SettingsPage/pages/messagesPage/hooks/use-updateMessage"; +import useRemoveMessages from "../../../../pages/SettingsPage/pages/messagesPage/hooks/use-remove-messages"; +import useMessagesTable from "../../../../pages/SettingsPage/pages/messagesPage/hooks/use-messages-table"; +import HeaderMessagesComponent from "../../../../pages/SettingsPage/pages/messagesPage/components/headerMessages"; + +export default function SessionView({ + session, + columns, +}: { + session: string; + columns: Array; +}) { + const messages = useMessagesStore((state) => state.messages); + const setErrorData = useAlertStore((state) => state.setErrorData); + const setSuccessData = useAlertStore((state) => state.setSuccessData); + + const [selectedRows, setSelectedRows] = useState([]); + + const { handleRemoveMessages } = useRemoveMessages( + setSelectedRows, + setSuccessData, + setErrorData, + selectedRows, + ); + + const { handleUpdate } = useUpdateMessage(setSuccessData, setErrorData); + + function handleUpdateMessage(event: CellEditRequestEvent) { + const newValue = event.newValue; + const field = event.column.getColId(); + const row = event.data; + const data = { + ...row, + [field]: newValue, + }; + handleUpdate(data); + } + + return ( + { + handleUpdateMessage(event); + }} + editable={["Sender Name", "Message"]} + overlayNoRowsTemplate="No data available" + onSelectionChanged={(event: SelectionChangedEvent) => { + setSelectedRows(event.api.getSelectedRows().map((row) => row.index)); + }} + rowSelection="multiple" + suppressRowClickSelection={true} + pagination={true} + columnDefs={columns} + rowData={messages.filter((message) => message.session_id === session)} + /> + ); +} diff --git a/src/frontend/src/modals/IOModal/index.tsx b/src/frontend/src/modals/IOModal/index.tsx index 36d495d95..bf60384d2 100644 --- a/src/frontend/src/modals/IOModal/index.tsx +++ b/src/frontend/src/modals/IOModal/index.tsx @@ -25,7 +25,10 @@ import { cn } from "../../utils/utils"; import BaseModal from "../baseModal"; import IOFieldView from "./components/IOFieldView"; import ChatView from "./components/chatView"; -import { getSessions } from "../../controllers/API"; +import { getMessagesTable } from "../../controllers/API"; +import { useMessagesStore } from "../../stores/messagesStore"; +import { ColDef, ColGroupDef } from "ag-grid-community"; +import SessionView from "./components/SessionView"; export default function IOModal({ children, @@ -34,6 +37,7 @@ export default function IOModal({ disable, }: IOModalPropsType): JSX.Element { const allNodes = useFlowStore((state) => state.nodes); + const setMessages = useMessagesStore((state) => state.setMessages); const inputs = useFlowStore((state) => state.inputs).filter( (input) => input.type !== "ChatInput", ); @@ -80,6 +84,7 @@ export default function IOModal({ const currentFlow = useFlowsManagerStore((state) => state.currentFlow); const setNode = useFlowStore((state) => state.setNode); const [sessions, setSessions] = useState([]); + const [columns, setColumns] = useState>([]); async function updateVertices() { return updateVerticesOrder(currentFlow!.id, null); @@ -126,8 +131,10 @@ export default function IOModal({ useEffect(() => { setSelectedViewField(startView()); if (haveChat) { - getSessions().then((sessions) => { + getMessagesTable("union").then(({ sessions, rows, columns }) => { setSessions(sessions); + setMessages(rows); + setColumns(columns); }); } }, [open]); @@ -300,7 +307,16 @@ export default function IOModal({ {sessions.map((session, index) => { return ( -
+
{ + event.stopPropagation(); + setSelectedViewField({ + id: session, + type: "Session", + }); + }} + >
{session} @@ -362,14 +378,17 @@ export default function IOModal({
{inputs.some( (input) => input.id === selectedViewField.id, - ) ? ( + ) && ( - ) : ( + )} + {outputs.some( + (output) => output.id === selectedViewField.id, + ) && ( )} + {sessions.some( + (session) => session === selectedViewField.id, + ) && ( + + )}
)} From 6fcf99aed9ca2dfacf40812314a93064246b9bbe Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 6 Jun 2024 18:54:00 -0300 Subject: [PATCH 5/9] workin session managment in playground, need to add tooltips --- src/frontend/src/controllers/API/index.ts | 3 +- .../components/SessionView/hooks/index.tsx | 29 ++++++++ .../IOModal/components/SessionView/index.tsx | 68 ++++++++++++------- src/frontend/src/modals/IOModal/index.tsx | 43 +++++++++--- src/frontend/src/stores/messagesStore.ts | 12 ++++ .../src/types/zustand/messages/index.ts | 4 ++ 6 files changed, 124 insertions(+), 35 deletions(-) create mode 100644 src/frontend/src/modals/IOModal/components/SessionView/hooks/index.tsx diff --git a/src/frontend/src/controllers/API/index.ts b/src/frontend/src/controllers/API/index.ts index 62cf63381..96cfaef12 100644 --- a/src/frontend/src/controllers/API/index.ts +++ b/src/frontend/src/controllers/API/index.ts @@ -1030,7 +1030,6 @@ export async function getMessagesTable( ): Promise<{ rows: Array; columns: Array; - sessions: Array; }> { const config = {}; if (id) { @@ -1045,7 +1044,7 @@ export async function getMessagesTable( rows.data.forEach((row) => { sessions.add(row.session_id); }); - return { rows: rows.data, columns, sessions: Array.from(sessions) }; + return { rows: rows.data, columns }; } export async function deleteMessagesFn(ids: number[]) { diff --git a/src/frontend/src/modals/IOModal/components/SessionView/hooks/index.tsx b/src/frontend/src/modals/IOModal/components/SessionView/hooks/index.tsx new file mode 100644 index 000000000..e8e638def --- /dev/null +++ b/src/frontend/src/modals/IOModal/components/SessionView/hooks/index.tsx @@ -0,0 +1,29 @@ +import { deleteMessagesFn } from "../../../../../controllers/API"; +import { useMessagesStore } from "../../../../../stores/messagesStore"; + +const useRemoveSession = (setSuccessData, setErrorData) => { + const deleteSession = useMessagesStore((state) => state.deleteSession); + const messages = useMessagesStore((state) => state.messages); + + const handleRemoveSession = async (session_id: string) => { + try { + await deleteMessagesFn( + messages + .filter((msg) => msg.session_id === session_id) + .map((msg) => msg.index), + ); + deleteSession(session_id); + setSuccessData({ + title: "Session deleted successfully.", + }); + } catch (error) { + setErrorData({ + title: "Error deleting Session.", + }); + } + }; + + return { handleRemoveSession }; +}; + +export default useRemoveSession; diff --git a/src/frontend/src/modals/IOModal/components/SessionView/index.tsx b/src/frontend/src/modals/IOModal/components/SessionView/index.tsx index 273766889..b21a786a1 100644 --- a/src/frontend/src/modals/IOModal/components/SessionView/index.tsx +++ b/src/frontend/src/modals/IOModal/components/SessionView/index.tsx @@ -11,17 +11,13 @@ import useAlertStore from "../../../../stores/alertStore"; import { useMessagesStore } from "../../../../stores/messagesStore"; import useUpdateMessage from "../../../../pages/SettingsPage/pages/messagesPage/hooks/use-updateMessage"; import useRemoveMessages from "../../../../pages/SettingsPage/pages/messagesPage/hooks/use-remove-messages"; -import useMessagesTable from "../../../../pages/SettingsPage/pages/messagesPage/hooks/use-messages-table"; import HeaderMessagesComponent from "../../../../pages/SettingsPage/pages/messagesPage/components/headerMessages"; +import { Button } from "../../../../components/ui/button"; +import ForwardedIconComponent from "../../../../components/genericIconComponent"; +import { cn } from "../../../../utils/utils"; -export default function SessionView({ - session, - columns, -}: { - session: string; - columns: Array; -}) { - const messages = useMessagesStore((state) => state.messages); +export default function SessionView({ rows }: { rows: Array }) { + const columns = useMessagesStore((state) => state.columns); const setErrorData = useAlertStore((state) => state.setErrorData); const setSuccessData = useAlertStore((state) => state.setSuccessData); @@ -48,21 +44,43 @@ export default function SessionView({ } return ( - { - handleUpdateMessage(event); - }} - editable={["Sender Name", "Message"]} - overlayNoRowsTemplate="No data available" - onSelectionChanged={(event: SelectionChangedEvent) => { - setSelectedRows(event.api.getSelectedRows().map((row) => row.index)); - }} - rowSelection="multiple" - suppressRowClickSelection={true} - pagination={true} - columnDefs={columns} - rowData={messages.filter((message) => message.session_id === session)} - /> +
+ <> +
+
+ +
+
+ + { + handleUpdateMessage(event); + }} + editable={["Sender Name", "Message"]} + overlayNoRowsTemplate="No data available" + onSelectionChanged={(event: SelectionChangedEvent) => { + setSelectedRows(event.api.getSelectedRows().map((row) => row.index)); + }} + rowSelection="multiple" + suppressRowClickSelection={true} + pagination={true} + columnDefs={columns} + rowData={rows} + /> +
); } diff --git a/src/frontend/src/modals/IOModal/index.tsx b/src/frontend/src/modals/IOModal/index.tsx index bf60384d2..725c5be72 100644 --- a/src/frontend/src/modals/IOModal/index.tsx +++ b/src/frontend/src/modals/IOModal/index.tsx @@ -27,8 +27,9 @@ import IOFieldView from "./components/IOFieldView"; import ChatView from "./components/chatView"; import { getMessagesTable } from "../../controllers/API"; import { useMessagesStore } from "../../stores/messagesStore"; -import { ColDef, ColGroupDef } from "ag-grid-community"; import SessionView from "./components/SessionView"; +import useRemoveSession from "./components/SessionView/hooks"; +import useAlertStore from "../../stores/alertStore"; export default function IOModal({ children, @@ -59,6 +60,8 @@ export default function IOModal({ const [selectedTab, setSelectedTab] = useState( inputs.length > 0 ? 1 : outputs.length > 0 ? 2 : 0, ); + const setErrorData = useAlertStore((state) => state.setErrorData); + const setSuccessData = useAlertStore((state) => state.setSuccessData); function startView() { if (!chatInput && !chatOutput) { @@ -84,8 +87,8 @@ export default function IOModal({ const currentFlow = useFlowsManagerStore((state) => state.currentFlow); const setNode = useFlowStore((state) => state.setNode); const [sessions, setSessions] = useState([]); - const [columns, setColumns] = useState>([]); - + const messages = useMessagesStore((state) => state.messages); + const setColumns = useMessagesStore((state) => state.setColumns); async function updateVertices() { return updateVerticesOrder(currentFlow!.id, null); } @@ -114,6 +117,11 @@ export default function IOModal({ } } + const { handleRemoveSession } = useRemoveSession( + setSuccessData, + setErrorData, + ); + useEffect(() => { setSelectedTab(inputs.length > 0 ? 1 : outputs.length > 0 ? 2 : 0); }, [allNodes.length]); @@ -131,14 +139,22 @@ export default function IOModal({ useEffect(() => { setSelectedViewField(startView()); if (haveChat) { - getMessagesTable("union").then(({ sessions, rows, columns }) => { - setSessions(sessions); + getMessagesTable("union").then(({ rows, columns }) => { setMessages(rows); setColumns(columns); }); } }, [open]); + useEffect(() => { + const sessions = new Set(); + messages.forEach((row) => { + sessions.add(row.session_id); + }); + setSessions(Array.from(sessions)); + sessions; + }, [messages]); + return ( {children} @@ -322,7 +338,16 @@ export default function IOModal({ {session}
-
diff --git a/src/frontend/src/stores/messagesStore.ts b/src/frontend/src/stores/messagesStore.ts index df1a3c15c..349a1c447 100644 --- a/src/frontend/src/stores/messagesStore.ts +++ b/src/frontend/src/stores/messagesStore.ts @@ -2,6 +2,18 @@ import { create } from "zustand"; import { MessagesStoreType } from "../types/zustand/messages"; export const useMessagesStore = create((set, get) => ({ + deleteSession: (id) => { + set((state) => { + const updatedMessages = state.messages.filter( + (msg) => msg.session_id !== id, + ); + return { messages: updatedMessages }; + }); + }, + columns: [], + setColumns: (columns) => { + set(() => ({ columns: columns })); + }, messages: [], setMessages: (messages) => { set(() => ({ messages: messages })); diff --git a/src/frontend/src/types/zustand/messages/index.ts b/src/frontend/src/types/zustand/messages/index.ts index 44915d2c3..b3ebd50d1 100644 --- a/src/frontend/src/types/zustand/messages/index.ts +++ b/src/frontend/src/types/zustand/messages/index.ts @@ -1,3 +1,4 @@ +import { ColDef, ColGroupDef } from "ag-grid-community"; import { Message } from "../../messages"; export type MessagesStoreType = { @@ -8,4 +9,7 @@ export type MessagesStoreType = { updateMessage: (message: Message) => void; clearMessages: () => void; removeMessages: (ids: number[]) => void; + columns: Array; + setColumns: (columns: Array) => void; + deleteSession: (id: string) => void; }; From 8063fd9a97139461eee23a23dd0d4c875116b510 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 6 Jun 2024 18:59:52 -0300 Subject: [PATCH 6/9] Refactor IOModal to improve session management and functionality --- src/frontend/src/modals/IOModal/index.tsx | 27 ++++++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/frontend/src/modals/IOModal/index.tsx b/src/frontend/src/modals/IOModal/index.tsx index 725c5be72..5f6d455be 100644 --- a/src/frontend/src/modals/IOModal/index.tsx +++ b/src/frontend/src/modals/IOModal/index.tsx @@ -348,15 +348,30 @@ export default function IOModal({ setSelectedViewField(undefined); }} > - - + +
+ +
- + + f_session?.session_id === session, + ) + ? "Active Session" + : "Inactive Session" + } + >
Date: Thu, 6 Jun 2024 19:04:26 -0300 Subject: [PATCH 7/9] filter using flow Id --- src/frontend/src/modals/IOModal/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/src/modals/IOModal/index.tsx b/src/frontend/src/modals/IOModal/index.tsx index 5f6d455be..3e28552d5 100644 --- a/src/frontend/src/modals/IOModal/index.tsx +++ b/src/frontend/src/modals/IOModal/index.tsx @@ -139,7 +139,7 @@ export default function IOModal({ useEffect(() => { setSelectedViewField(startView()); if (haveChat) { - getMessagesTable("union").then(({ rows, columns }) => { + getMessagesTable("union", currentFlow!.id).then(({ rows, columns }) => { setMessages(rows); setColumns(columns); }); From a38a0d7eebbae268449cb51a299f98f2d9dfef12 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Fri, 7 Jun 2024 10:51:17 -0300 Subject: [PATCH 8/9] add fixex to IO modal --- src/frontend/src/modals/IOModal/index.tsx | 25 ++++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/frontend/src/modals/IOModal/index.tsx b/src/frontend/src/modals/IOModal/index.tsx index 9b4a8556c..8eab95a30 100644 --- a/src/frontend/src/modals/IOModal/index.tsx +++ b/src/frontend/src/modals/IOModal/index.tsx @@ -29,6 +29,7 @@ import { useMessagesStore } from "../../stores/messagesStore"; import SessionView from "./components/SessionView"; import useRemoveSession from "./components/SessionView/hooks"; import useAlertStore from "../../stores/alertStore"; +import { Button } from "../../components/ui/button"; export default function IOModal({ children, @@ -39,25 +40,25 @@ export default function IOModal({ const allNodes = useFlowStore((state) => state.nodes); const setMessages = useMessagesStore((state) => state.setMessages); const inputs = useFlowStore((state) => state.inputs).filter( - (input) => input.type !== "ChatInput" + (input) => input.type !== "ChatInput", ); const chatInput = useFlowStore((state) => state.inputs).find( - (input) => input.type === "ChatInput" + (input) => input.type === "ChatInput", ); const outputs = useFlowStore((state) => state.outputs).filter( - (output) => output.type !== "ChatOutput" + (output) => output.type !== "ChatOutput", ); const chatOutput = useFlowStore((state) => state.outputs).find( - (output) => output.type === "ChatOutput" + (output) => output.type === "ChatOutput", ); const nodes = useFlowStore((state) => state.nodes).filter( (node) => inputs.some((input) => input.id === node.id) || - outputs.some((output) => output.id === node.id) + outputs.some((output) => output.id === node.id), ); const haveChat = chatInput || chatOutput; const [selectedTab, setSelectedTab] = useState( - inputs.length > 0 ? 1 : outputs.length > 0 ? 2 : 0 + inputs.length > 0 ? 1 : outputs.length > 0 ? 2 : 0, ); const setErrorData = useAlertStore((state) => state.setErrorData); const setSuccessData = useAlertStore((state) => state.setSuccessData); @@ -170,7 +171,7 @@ export default function IOModal({ return (
@@ -471,7 +476,7 @@ export default function IOModal({
{haveChat ? ( @@ -503,7 +508,7 @@ export default function IOModal({ "h-4 w-4", isBuilding ? "animate-spin" - : "fill-current text-medium-indigo" + : "fill-current text-medium-indigo", )} /> ), From d309c2bd85e5e6f133bca36e127764795cfd7350 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Fri, 7 Jun 2024 11:08:57 -0300 Subject: [PATCH 9/9] chore: Add onDelete and onDuplicate props to TableComponent --- src/frontend/src/components/tableComponent/index.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/frontend/src/components/tableComponent/index.tsx b/src/frontend/src/components/tableComponent/index.tsx index 3b0b6a824..139392922 100644 --- a/src/frontend/src/components/tableComponent/index.tsx +++ b/src/frontend/src/components/tableComponent/index.tsx @@ -20,6 +20,8 @@ interface TableComponentProps extends AgGridReactProps { alertTitle?: string; alertDescription?: string; editable?: boolean | string[]; + onDelete?: (selectedRows: any) => void; + onDuplicate?: (selectedRows: any) => void; } const TableComponent = forwardRef<