update api to display on node play button hover
This commit is contained in:
parent
6df98d45e1
commit
7cf2c0b438
3 changed files with 19 additions and 17 deletions
|
|
@ -22,7 +22,7 @@ import { useDarkStore } from "../../stores/darkStore";
|
||||||
import useFlowStore from "../../stores/flowStore";
|
import useFlowStore from "../../stores/flowStore";
|
||||||
import useFlowsManagerStore from "../../stores/flowsManagerStore";
|
import useFlowsManagerStore from "../../stores/flowsManagerStore";
|
||||||
import { useTypesStore } from "../../stores/typesStore";
|
import { useTypesStore } from "../../stores/typesStore";
|
||||||
import { APIClassType } from "../../types/api";
|
import { APIClassType, VertexBuildTypeAPI } from "../../types/api";
|
||||||
import { validationStatusType } from "../../types/components";
|
import { validationStatusType } from "../../types/components";
|
||||||
import { NodeDataType } from "../../types/flow";
|
import { NodeDataType } from "../../types/flow";
|
||||||
import { handleKeyDown, scapedJSONStringfy } from "../../utils/reactflowUtils";
|
import { handleKeyDown, scapedJSONStringfy } from "../../utils/reactflowUtils";
|
||||||
|
|
@ -64,7 +64,7 @@ export default function GenericNode({
|
||||||
(state) => state.flowBuildStatus[data.id]?.timestamp
|
(state) => state.flowBuildStatus[data.id]?.timestamp
|
||||||
);
|
);
|
||||||
const [validationStatus, setValidationStatus] =
|
const [validationStatus, setValidationStatus] =
|
||||||
useState<validationStatusType | null>(null);
|
useState<VertexBuildTypeAPI | null>(null);
|
||||||
const [handles, setHandles] = useState<number>(0);
|
const [handles, setHandles] = useState<number>(0);
|
||||||
|
|
||||||
const [validationString, setValidationString] = useState<string>("");
|
const [validationString, setValidationString] = useState<string>("");
|
||||||
|
|
@ -173,7 +173,7 @@ export default function GenericNode({
|
||||||
|
|
||||||
// should be empty string if no duration
|
// should be empty string if no duration
|
||||||
// else should be `Duration: ${duration}`
|
// else should be `Duration: ${duration}`
|
||||||
const getDurationString = (duration: number | undefined): string => {
|
const getDurationString = (duration: number | undefined|string): string => {
|
||||||
if (duration === undefined) {
|
if (duration === undefined) {
|
||||||
return "";
|
return "";
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -196,6 +196,7 @@ export default function GenericNode({
|
||||||
? flowPool[data.id][flowPool[data.id].length - 1]
|
? flowPool[data.id][flowPool[data.id].length - 1]
|
||||||
: null;
|
: null;
|
||||||
if (relevantData) {
|
if (relevantData) {
|
||||||
|
console.log(relevantData)
|
||||||
// Extract validation information from relevantData and update the validationStatus state
|
// Extract validation information from relevantData and update the validationStatus state
|
||||||
setValidationStatus(relevantData);
|
setValidationStatus(relevantData);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -204,21 +205,21 @@ export default function GenericNode({
|
||||||
}, [flowPool[data.id], data.id]);
|
}, [flowPool[data.id], data.id]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (validationStatus?.logs) {
|
if (validationStatus?.data.logs) {
|
||||||
// if it is not a string turn it into a string
|
// if it is not a string turn it into a string
|
||||||
let newValidationString = "";
|
let newValidationString = "";
|
||||||
if (validationStatus?.logs && Array.isArray(validationStatus.logs)) {
|
if (Array.isArray(validationStatus.data.logs)) {
|
||||||
newValidationString = validationStatus.logs
|
newValidationString = validationStatus.data.logs
|
||||||
.map((log) => log.message)
|
.map((log) => log.message)
|
||||||
.join("\n");
|
.join("\n");
|
||||||
}
|
}
|
||||||
if (typeof newValidationString !== "string") {
|
if (typeof newValidationString !== "string") {
|
||||||
newValidationString = JSON.stringify(validationStatus.logs);
|
newValidationString = JSON.stringify(validationStatus.data.logs);
|
||||||
}
|
}
|
||||||
|
|
||||||
setValidationString(newValidationString);
|
setValidationString(newValidationString);
|
||||||
}
|
}
|
||||||
}, [validationStatus, validationStatus?.logs]);
|
}, [validationStatus, validationStatus?.data.logs]);
|
||||||
|
|
||||||
const [showNode, setShowNode] = useState(data.showNode ?? true);
|
const [showNode, setShowNode] = useState(data.showNode ?? true);
|
||||||
|
|
||||||
|
|
@ -263,7 +264,7 @@ export default function GenericNode({
|
||||||
const isDark = useDarkStore((state) => state.dark);
|
const isDark = useDarkStore((state) => state.dark);
|
||||||
const renderIconStatus = (
|
const renderIconStatus = (
|
||||||
buildStatus: BuildStatus | undefined,
|
buildStatus: BuildStatus | undefined,
|
||||||
validationStatus: validationStatusType | null
|
validationStatus: VertexBuildTypeAPI | null
|
||||||
) => {
|
) => {
|
||||||
if (buildStatus === BuildStatus.BUILDING) {
|
if (buildStatus === BuildStatus.BUILDING) {
|
||||||
return <Loading className="text-medium-indigo" />;
|
return <Loading className="text-medium-indigo" />;
|
||||||
|
|
@ -304,7 +305,7 @@ export default function GenericNode({
|
||||||
};
|
};
|
||||||
const getSpecificClassFromBuildStatus = (
|
const getSpecificClassFromBuildStatus = (
|
||||||
buildStatus: BuildStatus | undefined,
|
buildStatus: BuildStatus | undefined,
|
||||||
validationStatus: validationStatusType | null
|
validationStatus: VertexBuildTypeAPI | null
|
||||||
) => {
|
) => {
|
||||||
let isInvalid = validationStatus && !validationStatus.valid;
|
let isInvalid = validationStatus && !validationStatus.valid;
|
||||||
|
|
||||||
|
|
@ -328,7 +329,7 @@ export default function GenericNode({
|
||||||
selected: boolean,
|
selected: boolean,
|
||||||
showNode: boolean,
|
showNode: boolean,
|
||||||
buildStatus: BuildStatus | undefined,
|
buildStatus: BuildStatus | undefined,
|
||||||
validationStatus: validationStatusType | null
|
validationStatus: VertexBuildTypeAPI | null
|
||||||
) => {
|
) => {
|
||||||
const specificClassFromBuildStatus = getSpecificClassFromBuildStatus(
|
const specificClassFromBuildStatus = getSpecificClassFromBuildStatus(
|
||||||
buildStatus,
|
buildStatus,
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
setFlowPool: (flowPool) => {
|
setFlowPool: (flowPool) => {
|
||||||
set({ flowPool });
|
set({ flowPool });
|
||||||
},
|
},
|
||||||
addDataToFlowPool: (data: FlowPoolObjectType, nodeId: string) => {
|
addDataToFlowPool: (data: VertexBuildTypeAPI, nodeId: string) => {
|
||||||
let newFlowPool = cloneDeep({ ...get().flowPool });
|
let newFlowPool = cloneDeep({ ...get().flowPool });
|
||||||
if (!newFlowPool[nodeId]) newFlowPool[nodeId] = [data];
|
if (!newFlowPool[nodeId]) newFlowPool[nodeId] = [data];
|
||||||
else {
|
else {
|
||||||
|
|
@ -76,7 +76,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
},
|
},
|
||||||
updateFlowPool: (
|
updateFlowPool: (
|
||||||
nodeId: string,
|
nodeId: string,
|
||||||
data: FlowPoolObjectType | ChatOutputType | chatInputType,
|
data: VertexBuildTypeAPI | ChatOutputType | chatInputType,
|
||||||
buildId?: string
|
buildId?: string
|
||||||
) => {
|
) => {
|
||||||
let newFlowPool = cloneDeep({ ...get().flowPool });
|
let newFlowPool = cloneDeep({ ...get().flowPool });
|
||||||
|
|
@ -506,7 +506,7 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
||||||
}
|
}
|
||||||
|
|
||||||
get().addDataToFlowPool(
|
get().addDataToFlowPool(
|
||||||
{ ...vertexBuildData, buildId: runId },
|
{ ...vertexBuildData, run_id: runId },
|
||||||
vertexBuildData.id
|
vertexBuildData.id
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import {
|
||||||
} from "reactflow";
|
} from "reactflow";
|
||||||
import { BuildStatus } from "../../../constants/enums";
|
import { BuildStatus } from "../../../constants/enums";
|
||||||
import { FlowState } from "../../tabs";
|
import { FlowState } from "../../tabs";
|
||||||
|
import { VertexBuildTypeAPI } from "../../api";
|
||||||
|
|
||||||
export type chatInputType = {
|
export type chatInputType = {
|
||||||
result: string;
|
result: string;
|
||||||
|
|
@ -60,7 +61,7 @@ export type VertexLayerElementType = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FlowPoolType = {
|
export type FlowPoolType = {
|
||||||
[key: string]: Array<FlowPoolObjectType>;
|
[key: string]: Array<VertexBuildTypeAPI>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type FlowStoreType = {
|
export type FlowStoreType = {
|
||||||
|
|
@ -69,7 +70,7 @@ export type FlowStoreType = {
|
||||||
outputs: Array<{ type: string; id: string; displayName: string }>;
|
outputs: Array<{ type: string; id: string; displayName: string }>;
|
||||||
hasIO: boolean;
|
hasIO: boolean;
|
||||||
setFlowPool: (flowPool: FlowPoolType) => void;
|
setFlowPool: (flowPool: FlowPoolType) => void;
|
||||||
addDataToFlowPool: (data: FlowPoolObjectType, nodeId: string) => void;
|
addDataToFlowPool: (data: VertexBuildTypeAPI, nodeId: string) => void;
|
||||||
CleanFlowPool: () => void;
|
CleanFlowPool: () => void;
|
||||||
isBuilding: boolean;
|
isBuilding: boolean;
|
||||||
isPending: boolean;
|
isPending: boolean;
|
||||||
|
|
@ -149,7 +150,7 @@ export type FlowStoreType = {
|
||||||
};
|
};
|
||||||
updateFlowPool: (
|
updateFlowPool: (
|
||||||
nodeId: string,
|
nodeId: string,
|
||||||
data: FlowPoolObjectType | ChatOutputType | chatInputType,
|
data: VertexBuildTypeAPI | ChatOutputType | chatInputType,
|
||||||
buildId?: string
|
buildId?: string
|
||||||
) => void;
|
) => void;
|
||||||
getNodePosition: (nodeId: string) => { x: number; y: number };
|
getNodePosition: (nodeId: string) => { x: number; y: number };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue