Apply Prettier formatting
This commit is contained in:
parent
73c43ee529
commit
8e0b6cdf68
10 changed files with 142 additions and 82 deletions
|
|
@ -3,6 +3,7 @@ import { ErrorBoundary } from "react-error-boundary";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import "reactflow/dist/style.css";
|
import "reactflow/dist/style.css";
|
||||||
import "./App.css";
|
import "./App.css";
|
||||||
|
import AlertDisplayArea from "./alerts/displayArea";
|
||||||
import ErrorAlert from "./alerts/error";
|
import ErrorAlert from "./alerts/error";
|
||||||
import NoticeAlert from "./alerts/notice";
|
import NoticeAlert from "./alerts/notice";
|
||||||
import SuccessAlert from "./alerts/success";
|
import SuccessAlert from "./alerts/success";
|
||||||
|
|
@ -25,14 +26,12 @@ import useFlowsManagerStore from "./stores/flowsManagerStore";
|
||||||
import { useFolderStore } from "./stores/foldersStore";
|
import { useFolderStore } from "./stores/foldersStore";
|
||||||
import { useGlobalVariablesStore } from "./stores/globalVariablesStore/globalVariables";
|
import { useGlobalVariablesStore } from "./stores/globalVariablesStore/globalVariables";
|
||||||
import { useStoreStore } from "./stores/storeStore";
|
import { useStoreStore } from "./stores/storeStore";
|
||||||
import AlertDisplayArea from "./alerts/displayArea";
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
useTrackLastVisitedPath();
|
useTrackLastVisitedPath();
|
||||||
|
|
||||||
const [fetchError, setFetchError] = useState(false);
|
const [fetchError, setFetchError] = useState(false);
|
||||||
const isLoading = useFlowsManagerStore((state) => state.isLoading);
|
const isLoading = useFlowsManagerStore((state) => state.isLoading);
|
||||||
|
|
||||||
|
|
||||||
const { isAuthenticated, login, setUserData, setAutoLogin, getUser } =
|
const { isAuthenticated, login, setUserData, setAutoLogin, getUser } =
|
||||||
useContext(AuthContext);
|
useContext(AuthContext);
|
||||||
const setLoading = useAlertStore((state) => state.setLoading);
|
const setLoading = useAlertStore((state) => state.setLoading);
|
||||||
|
|
@ -200,7 +199,7 @@ export default function App() {
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
<div></div>
|
<div></div>
|
||||||
<div className="app-div">
|
<div className="app-div">
|
||||||
<AlertDisplayArea/>
|
<AlertDisplayArea />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -3,51 +3,49 @@ import ErrorAlert from "../error";
|
||||||
import NoticeAlert from "../notice";
|
import NoticeAlert from "../notice";
|
||||||
import SuccessAlert from "../success";
|
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(
|
return (
|
||||||
(state) => state.removeFromTempNotificationList,
|
<div className="flex flex-col-reverse" style={{ zIndex: 999 }}>
|
||||||
);
|
{tempNotificationList.map((alert) => (
|
||||||
const tempNotificationList = useAlertStore(
|
<div key={alert.id}>
|
||||||
(state) => state.tempNotificationList,
|
{alert.type === "error" ? (
|
||||||
);
|
<ErrorAlert
|
||||||
const removeAlert = (id: string) => {
|
key={alert.id}
|
||||||
removeFromTempNotificationList(id);
|
title={alert.title}
|
||||||
};
|
list={alert.list}
|
||||||
|
id={alert.id}
|
||||||
|
removeAlert={removeAlert}
|
||||||
return (
|
/>
|
||||||
<div className="flex flex-col-reverse" style={{ zIndex: 999 }}>
|
) : alert.type === "notice" ? (
|
||||||
{tempNotificationList.map((alert) => (
|
<NoticeAlert
|
||||||
<div key={alert.id}>
|
key={alert.id}
|
||||||
{alert.type === "error" ? (
|
title={alert.title}
|
||||||
<ErrorAlert
|
link={alert.link}
|
||||||
|
id={alert.id}
|
||||||
|
removeAlert={removeAlert}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
alert.type === "success" && (
|
||||||
|
<SuccessAlert
|
||||||
key={alert.id}
|
key={alert.id}
|
||||||
title={alert.title}
|
title={alert.title}
|
||||||
list={alert.list}
|
|
||||||
id={alert.id}
|
id={alert.id}
|
||||||
removeAlert={removeAlert}
|
removeAlert={removeAlert}
|
||||||
/>
|
/>
|
||||||
) : alert.type === "notice" ? (
|
)
|
||||||
<NoticeAlert
|
)}
|
||||||
key={alert.id}
|
</div>
|
||||||
title={alert.title}
|
))}
|
||||||
link={alert.link}
|
</div>
|
||||||
id={alert.id}
|
);
|
||||||
removeAlert={removeAlert}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
alert.type === "success" && (
|
|
||||||
<SuccessAlert
|
|
||||||
key={alert.id}
|
|
||||||
title={alert.title}
|
|
||||||
id={alert.id}
|
|
||||||
removeAlert={removeAlert}
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
@ -4,7 +4,7 @@ import TextModal from "../../modals/textModal";
|
||||||
export default function StringReader({
|
export default function StringReader({
|
||||||
string,
|
string,
|
||||||
setValue,
|
setValue,
|
||||||
editable=false,
|
editable = false,
|
||||||
}: {
|
}: {
|
||||||
string: string;
|
string: string;
|
||||||
setValue: (value: string) => void;
|
setValue: (value: string) => void;
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,13 @@ export default function TableAutoCellRender({
|
||||||
</Badge>
|
</Badge>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return <StringReader editable={!!colDef?.onCellValueChanged} setValue={setValue!} string={value} />;
|
return (
|
||||||
|
<StringReader
|
||||||
|
editable={!!colDef?.onCellValueChanged}
|
||||||
|
setValue={setValue!}
|
||||||
|
string={value}
|
||||||
|
/>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
case "number":
|
case "number":
|
||||||
return <NumberReader number={value} />;
|
return <NumberReader number={value} />;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import "ag-grid-community/styles/ag-theme-quartz.css"; // Optional Theme applied
|
||||||
import { AgGridReact, AgGridReactProps } from "ag-grid-react";
|
import { AgGridReact, AgGridReactProps } from "ag-grid-react";
|
||||||
import cloneDeep from "lodash";
|
import cloneDeep from "lodash";
|
||||||
import { ElementRef, forwardRef, useRef, useState } from "react";
|
import { ElementRef, forwardRef, useRef, useState } from "react";
|
||||||
|
import { boolean } from "zod";
|
||||||
import {
|
import {
|
||||||
DEFAULT_TABLE_ALERT_MSG,
|
DEFAULT_TABLE_ALERT_MSG,
|
||||||
DEFAULT_TABLE_ALERT_TITLE,
|
DEFAULT_TABLE_ALERT_TITLE,
|
||||||
|
|
@ -14,14 +15,20 @@ import ForwardedIconComponent from "../genericIconComponent";
|
||||||
import { Alert, AlertDescription, AlertTitle } from "../ui/alert";
|
import { Alert, AlertDescription, AlertTitle } from "../ui/alert";
|
||||||
import TableOptions from "./components/TableOptions";
|
import TableOptions from "./components/TableOptions";
|
||||||
import resetGrid from "./utils/reset-grid-columns";
|
import resetGrid from "./utils/reset-grid-columns";
|
||||||
import { boolean } from "zod";
|
|
||||||
|
|
||||||
interface TableComponentProps extends AgGridReactProps {
|
interface TableComponentProps extends AgGridReactProps {
|
||||||
columnDefs: NonNullable<AgGridReactProps["columnDefs"]>;
|
columnDefs: NonNullable<AgGridReactProps["columnDefs"]>;
|
||||||
rowData: NonNullable<AgGridReactProps["rowData"]>;
|
rowData: NonNullable<AgGridReactProps["rowData"]>;
|
||||||
alertTitle?: string;
|
alertTitle?: string;
|
||||||
alertDescription?: 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;
|
pagination?: boolean;
|
||||||
onDelete?: () => void;
|
onDelete?: () => void;
|
||||||
onDuplicate?: () => void;
|
onDuplicate?: () => void;
|
||||||
|
|
@ -53,7 +60,8 @@ const TableComponent = forwardRef<
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
(typeof props.editable === "boolean" && props.editable) ||
|
(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<string>).includes(newCol.headerName ?? ""))
|
(props.editable as Array<string>).includes(newCol.headerName ?? ""))
|
||||||
) {
|
) {
|
||||||
newCol = {
|
newCol = {
|
||||||
|
|
@ -61,14 +69,23 @@ const TableComponent = forwardRef<
|
||||||
editable: true,
|
editable: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if(Array.isArray(props.editable) && props.editable.every(field=>typeof field ==="object")){
|
if (
|
||||||
const field = (props.editable as Array<{field:string, onUpdate:(value:any)=>void,editableCell:boolean}>).find(field=>field.field===newCol.headerName);
|
Array.isArray(props.editable) &&
|
||||||
if(field){
|
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 = {
|
||||||
...newCol,
|
...newCol,
|
||||||
editable: field.editableCell,
|
editable: field.editableCell,
|
||||||
onCellValueChanged: (e)=>field.onUpdate(e)
|
onCellValueChanged: (e) => field.onUpdate(e),
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return newCol;
|
return newCol;
|
||||||
|
|
|
||||||
|
|
@ -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 { useState } from "react";
|
||||||
import TableComponent from "../../../../components/tableComponent";
|
import TableComponent from "../../../../components/tableComponent";
|
||||||
import useRemoveMessages from "../../../../pages/SettingsPage/pages/messagesPage/hooks/use-remove-messages";
|
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 useAlertStore from "../../../../stores/alertStore";
|
||||||
import { useMessagesStore } from "../../../../stores/messagesStore";
|
import { useMessagesStore } from "../../../../stores/messagesStore";
|
||||||
import { messagesSorter } from "../../../../utils/utils";
|
import { messagesSorter } from "../../../../utils/utils";
|
||||||
import cloneDeep from "lodash/cloneDeep";
|
|
||||||
|
|
||||||
export default function SessionView({ rows }: { rows: Array<any> }) {
|
export default function SessionView({ rows }: { rows: Array<any> }) {
|
||||||
const columns = useMessagesStore((state) => state.columns);
|
const columns = useMessagesStore((state) => state.columns);
|
||||||
|
|
@ -43,7 +47,9 @@ export default function SessionView({ rows }: { rows: Array<any> }) {
|
||||||
key={"sessionView"}
|
key={"sessionView"}
|
||||||
onDelete={handleRemoveMessages}
|
onDelete={handleRemoveMessages}
|
||||||
readOnlyEdit
|
readOnlyEdit
|
||||||
editable={[{field:"text",onUpdate:handleUpdateMessage, editableCell:false}]}
|
editable={[
|
||||||
|
{ field: "text", onUpdate: handleUpdateMessage, editableCell: false },
|
||||||
|
]}
|
||||||
overlayNoRowsTemplate="No data available"
|
overlayNoRowsTemplate="No data available"
|
||||||
onSelectionChanged={(event: SelectionChangedEvent) => {
|
onSelectionChanged={(event: SelectionChangedEvent) => {
|
||||||
setSelectedRows(event.api.getSelectedRows().map((row) => row.index));
|
setSelectedRows(event.api.getSelectedRows().map((row) => row.index));
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,31 @@
|
||||||
import { Textarea } from "../../../../components/ui/textarea";
|
import { Textarea } from "../../../../components/ui/textarea";
|
||||||
|
|
||||||
const TextEditorArea = ({ left, value, onChange,readonly }: { left: boolean | undefined, value: any, onChange?: (string) => void; readonly:boolean}) => {
|
const TextEditorArea = ({
|
||||||
if (typeof value === "object" && Object.keys(value).includes("text")) {
|
left,
|
||||||
value = value.text;
|
value,
|
||||||
}
|
onChange,
|
||||||
return (
|
readonly,
|
||||||
<Textarea
|
}: {
|
||||||
readOnly={readonly}
|
left: boolean | undefined;
|
||||||
className={`w-full custom-scroll ${left ? "min-h-32" : "h-full"}`}
|
value: any;
|
||||||
placeholder={"Empty"}
|
onChange?: (string) => void;
|
||||||
// update to real value on flowPool
|
readonly: boolean;
|
||||||
value={value}
|
}) => {
|
||||||
onChange={(e) => { if (onChange) onChange(e.target.value) }}
|
if (typeof value === "object" && Object.keys(value).includes("text")) {
|
||||||
/>
|
value = value.text;
|
||||||
);
|
}
|
||||||
|
return (
|
||||||
|
<Textarea
|
||||||
|
readOnly={readonly}
|
||||||
|
className={`w-full custom-scroll ${left ? "min-h-32" : "h-full"}`}
|
||||||
|
placeholder={"Empty"}
|
||||||
|
// update to real value on flowPool
|
||||||
|
value={value}
|
||||||
|
onChange={(e) => {
|
||||||
|
if (onChange) onChange(e.target.value);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default TextEditorArea;
|
export default TextEditorArea;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ export default function TextModal({
|
||||||
children,
|
children,
|
||||||
value,
|
value,
|
||||||
setValue,
|
setValue,
|
||||||
editable = false
|
editable = false,
|
||||||
}: {
|
}: {
|
||||||
children: JSX.Element;
|
children: JSX.Element;
|
||||||
value: string;
|
value: string;
|
||||||
|
|
@ -48,18 +48,28 @@ export default function TextModal({
|
||||||
<BaseModal.Content>
|
<BaseModal.Content>
|
||||||
<div className="flex h-full w-full flex-col transition-all">
|
<div className="flex h-full w-full flex-col transition-all">
|
||||||
<div className="h-[370px]">
|
<div className="h-[370px]">
|
||||||
<TextEditorArea readonly={!editable} onChange={(text) => setInternalValue(text)} value={internalValue} left={false} />
|
<TextEditorArea
|
||||||
|
readonly={!editable}
|
||||||
|
onChange={(text) => setInternalValue(text)}
|
||||||
|
value={internalValue}
|
||||||
|
left={false}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</BaseModal.Content>
|
</BaseModal.Content>
|
||||||
<BaseModal.Footer>
|
<BaseModal.Footer>
|
||||||
<div className="flex w-full justify-end gap-2 pt-2">
|
<div className="flex w-full justify-end gap-2 pt-2">
|
||||||
{editable && <Button className="flex gap-2 px-3" onClick={() => {
|
{editable && (
|
||||||
setValue(internalValue);
|
<Button
|
||||||
setOpen(false);
|
className="flex gap-2 px-3"
|
||||||
}}>
|
onClick={() => {
|
||||||
Save
|
setValue(internalValue);
|
||||||
</Button>}
|
setOpen(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
<Button className="flex gap-2 px-3" onClick={() => setOpen(false)}>
|
<Button className="flex gap-2 px-3" onClick={() => setOpen(false)}>
|
||||||
Close
|
Close
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,13 @@ export default function MessagesPage() {
|
||||||
onCellEditRequest={(event) => {
|
onCellEditRequest={(event) => {
|
||||||
handleUpdateMessage(event);
|
handleUpdateMessage(event);
|
||||||
}}
|
}}
|
||||||
editable={[{field:"text",onUpdate:handleUpdateMessage, editableCell:false}]}
|
editable={[
|
||||||
|
{
|
||||||
|
field: "text",
|
||||||
|
onUpdate: handleUpdateMessage,
|
||||||
|
editableCell: false,
|
||||||
|
},
|
||||||
|
]}
|
||||||
overlayNoRowsTemplate="No data available"
|
overlayNoRowsTemplate="No data available"
|
||||||
onSelectionChanged={(event: SelectionChangedEvent) => {
|
onSelectionChanged={(event: SelectionChangedEvent) => {
|
||||||
setSelectedRows(
|
setSelectedRows(
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
import { Textarea } from "../../../components/ui/textarea";
|
import { Textarea } from "../../../components/ui/textarea";
|
||||||
|
|
||||||
const TextOutputView = ({ left, value }:{left:boolean|undefined,value:any}) => {
|
const TextOutputView = ({
|
||||||
|
left,
|
||||||
|
value,
|
||||||
|
}: {
|
||||||
|
left: boolean | undefined;
|
||||||
|
value: any;
|
||||||
|
}) => {
|
||||||
if (typeof value === "object" && Object.keys(value).includes("text")) {
|
if (typeof value === "object" && Object.keys(value).includes("text")) {
|
||||||
value = value.text;
|
value = value.text;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue