From 8e0b6cdf68cc974f032aaf297b3d4b2bfc4f9080 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Fri, 21 Jun 2024 21:17:28 +0000 Subject: [PATCH] Apply Prettier formatting --- src/frontend/src/App.tsx | 5 +- src/frontend/src/alerts/displayArea/index.tsx | 82 +++++++++---------- .../stringReaderComponent/index.tsx | 2 +- .../components/tableAutoCellRender/index.tsx | 8 +- .../src/components/tableComponent/index.tsx | 33 ++++++-- .../IOModal/components/SessionView/index.tsx | 12 ++- .../components/textEditorArea/index.tsx | 40 +++++---- src/frontend/src/modals/textModal/index.tsx | 26 ++++-- .../SettingsPage/pages/messagesPage/index.tsx | 8 +- .../components/textOutputView/index.tsx | 8 +- 10 files changed, 142 insertions(+), 82 deletions(-) diff --git a/src/frontend/src/App.tsx b/src/frontend/src/App.tsx index a30f50426..1c8274e63 100644 --- a/src/frontend/src/App.tsx +++ b/src/frontend/src/App.tsx @@ -3,6 +3,7 @@ import { ErrorBoundary } from "react-error-boundary"; import { useNavigate } from "react-router-dom"; import "reactflow/dist/style.css"; import "./App.css"; +import AlertDisplayArea from "./alerts/displayArea"; import ErrorAlert from "./alerts/error"; import NoticeAlert from "./alerts/notice"; import SuccessAlert from "./alerts/success"; @@ -25,14 +26,12 @@ import useFlowsManagerStore from "./stores/flowsManagerStore"; import { useFolderStore } from "./stores/foldersStore"; import { useGlobalVariablesStore } from "./stores/globalVariablesStore/globalVariables"; import { useStoreStore } from "./stores/storeStore"; -import AlertDisplayArea from "./alerts/displayArea"; export default function App() { useTrackLastVisitedPath(); const [fetchError, setFetchError] = useState(false); const isLoading = useFlowsManagerStore((state) => state.isLoading); - const { isAuthenticated, login, setUserData, setAutoLogin, getUser } = useContext(AuthContext); const setLoading = useAlertStore((state) => state.setLoading); @@ -200,7 +199,7 @@ export default function App() {
- +
); diff --git a/src/frontend/src/alerts/displayArea/index.tsx b/src/frontend/src/alerts/displayArea/index.tsx index 9f39ee6dd..1d59d9a24 100644 --- a/src/frontend/src/alerts/displayArea/index.tsx +++ b/src/frontend/src/alerts/displayArea/index.tsx @@ -3,51 +3,49 @@ import ErrorAlert from "../error"; import NoticeAlert from "../notice"; import SuccessAlert from "../success"; -export default function AlertDisplayArea(){ +export default function AlertDisplayArea() { + const removeFromTempNotificationList = useAlertStore( + (state) => state.removeFromTempNotificationList, + ); + const tempNotificationList = useAlertStore( + (state) => state.tempNotificationList, + ); + const removeAlert = (id: string) => { + removeFromTempNotificationList(id); + }; - const removeFromTempNotificationList = useAlertStore( - (state) => state.removeFromTempNotificationList, - ); - const tempNotificationList = useAlertStore( - (state) => state.tempNotificationList, - ); - const removeAlert = (id: string) => { - removeFromTempNotificationList(id); - }; - - - return ( -
- {tempNotificationList.map((alert) => ( -
- {alert.type === "error" ? ( - + {tempNotificationList.map((alert) => ( +
+ {alert.type === "error" ? ( + + ) : alert.type === "notice" ? ( + + ) : ( + alert.type === "success" && ( + - ) : alert.type === "notice" ? ( - - ) : ( - alert.type === "success" && ( - - ) - )} -
- ))} -
- ) -} \ No newline at end of file + ) + )} +
+ ))} + + ); +} diff --git a/src/frontend/src/components/stringReaderComponent/index.tsx b/src/frontend/src/components/stringReaderComponent/index.tsx index 3045db34f..dfcb15b54 100644 --- a/src/frontend/src/components/stringReaderComponent/index.tsx +++ b/src/frontend/src/components/stringReaderComponent/index.tsx @@ -4,7 +4,7 @@ import TextModal from "../../modals/textModal"; export default function StringReader({ string, setValue, - editable=false, + editable = false, }: { string: string; setValue: (value: string) => void; diff --git a/src/frontend/src/components/tableComponent/components/tableAutoCellRender/index.tsx b/src/frontend/src/components/tableComponent/components/tableAutoCellRender/index.tsx index 82d5d67cd..a4bad2c4c 100644 --- a/src/frontend/src/components/tableComponent/components/tableAutoCellRender/index.tsx +++ b/src/frontend/src/components/tableComponent/components/tableAutoCellRender/index.tsx @@ -51,7 +51,13 @@ export default function TableAutoCellRender({ ); } else { - return ; + return ( + + ); } case "number": return ; diff --git a/src/frontend/src/components/tableComponent/index.tsx b/src/frontend/src/components/tableComponent/index.tsx index 7eb52dd77..a75238258 100644 --- a/src/frontend/src/components/tableComponent/index.tsx +++ b/src/frontend/src/components/tableComponent/index.tsx @@ -3,6 +3,7 @@ import "ag-grid-community/styles/ag-theme-quartz.css"; // Optional Theme applied import { AgGridReact, AgGridReactProps } from "ag-grid-react"; import cloneDeep from "lodash"; import { ElementRef, forwardRef, useRef, useState } from "react"; +import { boolean } from "zod"; import { DEFAULT_TABLE_ALERT_MSG, DEFAULT_TABLE_ALERT_TITLE, @@ -14,14 +15,20 @@ import ForwardedIconComponent from "../genericIconComponent"; import { Alert, AlertDescription, AlertTitle } from "../ui/alert"; import TableOptions from "./components/TableOptions"; import resetGrid from "./utils/reset-grid-columns"; -import { boolean } from "zod"; interface TableComponentProps extends AgGridReactProps { columnDefs: NonNullable; rowData: NonNullable; alertTitle?: string; alertDescription?: string; - editable?: boolean | string[] | {field: string, onUpdate: (value:any)=>void,editableCell:boolean}[]; + editable?: + | boolean + | string[] + | { + field: string; + onUpdate: (value: any) => void; + editableCell: boolean; + }[]; pagination?: boolean; onDelete?: () => void; onDuplicate?: () => void; @@ -53,7 +60,8 @@ const TableComponent = forwardRef< } if ( (typeof props.editable === "boolean" && props.editable) || - (Array.isArray(props.editable) && props.editable.every(field=>typeof field ==="string") && + (Array.isArray(props.editable) && + props.editable.every((field) => typeof field === "string") && (props.editable as Array).includes(newCol.headerName ?? "")) ) { newCol = { @@ -61,14 +69,23 @@ const TableComponent = forwardRef< editable: true, }; } - if(Array.isArray(props.editable) && props.editable.every(field=>typeof field ==="object")){ - const field = (props.editable as Array<{field:string, onUpdate:(value:any)=>void,editableCell:boolean}>).find(field=>field.field===newCol.headerName); - if(field){ + if ( + Array.isArray(props.editable) && + props.editable.every((field) => typeof field === "object") + ) { + const field = ( + props.editable as Array<{ + field: string; + onUpdate: (value: any) => void; + editableCell: boolean; + }> + ).find((field) => field.field === newCol.headerName); + if (field) { newCol = { ...newCol, editable: field.editableCell, - onCellValueChanged: (e)=>field.onUpdate(e) - } + onCellValueChanged: (e) => field.onUpdate(e), + }; } } return newCol; diff --git a/src/frontend/src/modals/IOModal/components/SessionView/index.tsx b/src/frontend/src/modals/IOModal/components/SessionView/index.tsx index 1f3ab7adb..2ea6ef606 100644 --- a/src/frontend/src/modals/IOModal/components/SessionView/index.tsx +++ b/src/frontend/src/modals/IOModal/components/SessionView/index.tsx @@ -1,4 +1,9 @@ -import { CellEditRequestEvent, NewValueParams, SelectionChangedEvent } from "ag-grid-community"; +import { + CellEditRequestEvent, + NewValueParams, + SelectionChangedEvent, +} from "ag-grid-community"; +import cloneDeep from "lodash/cloneDeep"; import { useState } from "react"; import TableComponent from "../../../../components/tableComponent"; import useRemoveMessages from "../../../../pages/SettingsPage/pages/messagesPage/hooks/use-remove-messages"; @@ -6,7 +11,6 @@ import useUpdateMessage from "../../../../pages/SettingsPage/pages/messagesPage/ import useAlertStore from "../../../../stores/alertStore"; import { useMessagesStore } from "../../../../stores/messagesStore"; import { messagesSorter } from "../../../../utils/utils"; -import cloneDeep from "lodash/cloneDeep"; export default function SessionView({ rows }: { rows: Array }) { const columns = useMessagesStore((state) => state.columns); @@ -43,7 +47,9 @@ export default function SessionView({ rows }: { rows: Array }) { key={"sessionView"} onDelete={handleRemoveMessages} readOnlyEdit - editable={[{field:"text",onUpdate:handleUpdateMessage, editableCell:false}]} + editable={[ + { field: "text", onUpdate: handleUpdateMessage, editableCell: false }, + ]} overlayNoRowsTemplate="No data available" onSelectionChanged={(event: SelectionChangedEvent) => { setSelectedRows(event.api.getSelectedRows().map((row) => row.index)); diff --git a/src/frontend/src/modals/textModal/components/textEditorArea/index.tsx b/src/frontend/src/modals/textModal/components/textEditorArea/index.tsx index ab0a4b155..64e5b7030 100644 --- a/src/frontend/src/modals/textModal/components/textEditorArea/index.tsx +++ b/src/frontend/src/modals/textModal/components/textEditorArea/index.tsx @@ -1,19 +1,31 @@ import { Textarea } from "../../../../components/ui/textarea"; -const TextEditorArea = ({ left, value, onChange,readonly }: { left: boolean | undefined, value: any, onChange?: (string) => void; readonly:boolean}) => { - if (typeof value === "object" && Object.keys(value).includes("text")) { - value = value.text; - } - return ( -