Merge remote-tracking branch 'origin/cz/mergeAll' into fix/minor_ui_adjustments

This commit is contained in:
Lucas Oliveira 2024-06-10 18:50:46 -03:00
commit 2113e32d84
6 changed files with 50 additions and 11 deletions

View file

@ -156,3 +156,8 @@ body {
.react-flow__edge .react-flow__edge-path { .react-flow__edge .react-flow__edge-path {
stroke: var(--connection) !important; stroke: var(--connection) !important;
} }
.ag-react-container {
width: 100%;
height: 100%;
}

View file

@ -0,0 +1,9 @@
import Loading from "../../../ui/loading";
export default function LoadingOverlay() {
return (
<div className=" flex h-full w-full items-center justify-center bg-background align-middle">
<Loading />
</div>
);
}

View file

@ -13,6 +13,7 @@ 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 Loading from "../ui/loading";
interface TableComponentProps extends AgGridReactProps { interface TableComponentProps extends AgGridReactProps {
columnDefs: NonNullable<AgGridReactProps["columnDefs"]>; columnDefs: NonNullable<AgGridReactProps["columnDefs"]>;
@ -76,7 +77,7 @@ const TableComponent = forwardRef<
const dark = useDarkStore((state) => state.dark); const dark = useDarkStore((state) => state.dark);
const initialColumnDefs = useRef(colDef); const initialColumnDefs = useRef(colDef);
const [columnStateChange, setColumnStateChange] = useState(false); const [columnStateChange, setColumnStateChange] = useState(false);
const storeReference = props.columnDefs.map((e) => e.headerName).join("_");
const makeLastColumnNonResizable = (columnDefs) => { const makeLastColumnNonResizable = (columnDefs) => {
columnDefs.forEach((colDef, index) => { columnDefs.forEach((colDef, index) => {
colDef.resizable = index !== columnDefs.length - 1; colDef.resizable = index !== columnDefs.length - 1;
@ -89,13 +90,26 @@ const TableComponent = forwardRef<
realRef.current = params; realRef.current = params;
const updatedColumnDefs = makeLastColumnNonResizable([...colDef]); const updatedColumnDefs = makeLastColumnNonResizable([...colDef]);
params.api.setGridOption("columnDefs", updatedColumnDefs); params.api.setGridOption("columnDefs", updatedColumnDefs);
const customInit = localStorage.getItem(storeReference);
initialColumnDefs.current = params.api.getColumnDefs(); initialColumnDefs.current = params.api.getColumnDefs();
if (props.onGridReady) props.onGridReady(params); if (customInit && realRef.current) {
realRef.current.api.applyColumnState({
state: JSON.parse(customInit),
applyOrder: true,
});
}
setTimeout(() => { setTimeout(() => {
if (customInit && realRef.current) {
setColumnStateChange(true);
} else {
setColumnStateChange(false); setColumnStateChange(false);
}, 200); }
}, 50);
setTimeout(() => {
realRef.current.api.hideOverlay();
}, 1000);
if (props.onGridReady) props.onGridReady(params);
}; };
const onColumnMoved = (params) => { const onColumnMoved = (params) => {
const updatedColumnDefs = makeLastColumnNonResizable( const updatedColumnDefs = makeLastColumnNonResizable(
params.columnApi.getAllGridColumns().map((col) => col.getColDef()), params.columnApi.getAllGridColumns().map((col) => col.getColDef()),
@ -103,7 +117,6 @@ const TableComponent = forwardRef<
params.api.setGridOption("columnDefs", updatedColumnDefs); params.api.setGridOption("columnDefs", updatedColumnDefs);
if (props.onColumnMoved) props.onColumnMoved(params); if (props.onColumnMoved) props.onColumnMoved(params);
}; };
if (props.rowData.length === 0) { if (props.rowData.length === 0) {
return ( return (
<div className="flex h-full w-full items-center justify-center rounded-md border"> <div className="flex h-full w-full items-center justify-center rounded-md border">
@ -138,6 +151,10 @@ const TableComponent = forwardRef<
onColumnMoved={onColumnMoved} onColumnMoved={onColumnMoved}
onStateUpdated={(e) => { onStateUpdated={(e) => {
if (e.sources.some((source) => source.includes("column"))) { if (e.sources.some((source) => source.includes("column"))) {
localStorage.setItem(
storeReference,
JSON.stringify(realRef.current?.api?.getColumnState()),
);
setColumnStateChange(true); setColumnStateChange(true);
} }
}} }}
@ -152,6 +169,7 @@ const TableComponent = forwardRef<
resetGrid(realRef, initialColumnDefs); resetGrid(realRef, initialColumnDefs);
setTimeout(() => { setTimeout(() => {
setColumnStateChange(false); setColumnStateChange(false);
localStorage.removeItem(storeReference);
}, 100); }, 100);
}} }}
/> />

View file

@ -65,10 +65,15 @@ export default function ChatView({
.filter((output) => output.data.message) .filter((output) => output.data.message)
.map((output, index) => { .map((output, index) => {
try { try {
const { sender, message, sender_name, stream_url, files } = output console.log("output:", output);
.data.message as ChatOutputType; const { sender, message, sender_name, stream_url, files } =
output.data.message.message !== "" ||
(output.data.message.files ?? []).length > 0
? output.data.message
: output.data.artifacts;
const is_ai = sender === "Machine" || sender === null; const is_ai =
sender === "Machine" || sender === null || sender === undefined;
return { return {
isSend: !is_ai, isSend: !is_ai,
message: message, message: message,

View file

@ -366,7 +366,9 @@ export default function IOModal({
size="md" size="md"
className="block truncate" className="block truncate"
> >
{session} {session === currentFlow?.id
? "Default Session"
: session}
</Badge> </Badge>
</div> </div>
</ShadTooltip> </ShadTooltip>

View file

@ -170,7 +170,7 @@ export type VertexDataTypeAPI = {
inactive?: boolean; inactive?: boolean;
timedelta?: number; timedelta?: number;
duration?: string; duration?: string;
artifacts?: any; artifacts?: any | ChatOutputType | ChatInputType;
message: ChatOutputType | ChatInputType; message: ChatOutputType | ChatInputType;
}; };