Feat: Add support to another input types on IO
This commit is contained in:
parent
fccf3eeb25
commit
61ecc66e1f
4 changed files with 44 additions and 16 deletions
23
src/frontend/src/components/IOInputField/index.tsx
Normal file
23
src/frontend/src/components/IOInputField/index.tsx
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { Textarea } from "../ui/textarea";
|
||||||
|
import InputFileComponent from "../inputFileComponent";
|
||||||
|
import { IOInputProps } from "../../types/components";
|
||||||
|
|
||||||
|
export default function IOInputField({
|
||||||
|
inputType,
|
||||||
|
value,
|
||||||
|
onChange,
|
||||||
|
styleClasses,
|
||||||
|
placeholder,
|
||||||
|
}: IOInputProps): JSX.Element | undefined {
|
||||||
|
switch (inputType) {
|
||||||
|
case "TextInput":
|
||||||
|
return (
|
||||||
|
<Textarea
|
||||||
|
className={styleClasses}
|
||||||
|
placeholder={placeholder}
|
||||||
|
value={value}
|
||||||
|
onChange={onChange}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -8,6 +8,7 @@ import IconComponent from "../genericIconComponent";
|
||||||
import NewChatView from "../newChatView";
|
import NewChatView from "../newChatView";
|
||||||
import { Badge } from "../ui/badge";
|
import { Badge } from "../ui/badge";
|
||||||
import { Textarea } from "../ui/textarea";
|
import { Textarea } from "../ui/textarea";
|
||||||
|
import IOInputField from "../IOInputField";
|
||||||
|
|
||||||
export default function IOView(): JSX.Element {
|
export default function IOView(): JSX.Element {
|
||||||
const inputs = useFlowStore((state) => state.inputs);
|
const inputs = useFlowStore((state) => state.inputs);
|
||||||
|
|
@ -17,7 +18,6 @@ export default function IOView(): JSX.Element {
|
||||||
const nodes = useFlowStore((state) => state.nodes);
|
const nodes = useFlowStore((state) => state.nodes);
|
||||||
const setNode = useFlowStore((state) => state.setNode);
|
const setNode = useFlowStore((state) => state.setNode);
|
||||||
const options = inputIds.concat(outputIds);
|
const options = inputIds.concat(outputIds);
|
||||||
console.log(options);
|
|
||||||
const [selectedView, setSelectedView] = useState<ReactNode>(
|
const [selectedView, setSelectedView] = useState<ReactNode>(
|
||||||
handleSelectChange(options[0])
|
handleSelectChange(options[0])
|
||||||
);
|
);
|
||||||
|
|
@ -33,7 +33,7 @@ export default function IOView(): JSX.Element {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log(inputs)
|
||||||
return (
|
return (
|
||||||
<div className="form-modal-iv-box">
|
<div className="form-modal-iv-box">
|
||||||
<div className="mr-6 flex h-full w-2/6 flex-col justify-start overflow-auto scrollbar-hide">
|
<div className="mr-6 flex h-full w-2/6 flex-col justify-start overflow-auto scrollbar-hide">
|
||||||
|
|
@ -66,12 +66,11 @@ export default function IOView(): JSX.Element {
|
||||||
>
|
>
|
||||||
{/* TODO: EXTEND AND IMPROVE VIEW MODE AND ADD OTHER TYPES OF VIEWS */}
|
{/* TODO: EXTEND AND IMPROVE VIEW MODE AND ADD OTHER TYPES OF VIEWS */}
|
||||||
<div className="file-component-tab-column">
|
<div className="file-component-tab-column">
|
||||||
<Textarea
|
<IOInputField
|
||||||
value={
|
value={nodes.find((node) => node.id === inputId)?.data.node.template.value.value}
|
||||||
nodes.find((node) => node.id === inputId)?.data?.node
|
styleClasses="custom-scroll"
|
||||||
?.template?.value.value
|
placeholder="Enter text..."
|
||||||
}
|
inputType={inputs.find((input) => input.id === inputId)?.type!}
|
||||||
className="custom-scroll"
|
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
e.target.value;
|
e.target.value;
|
||||||
if (node) {
|
if (node) {
|
||||||
|
|
@ -81,8 +80,7 @@ export default function IOView(): JSX.Element {
|
||||||
setNode(node.id, newNode);
|
setNode(node.id, newNode);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
placeholder="Enter text..."
|
/>
|
||||||
></Textarea>
|
|
||||||
</div>
|
</div>
|
||||||
</AccordionComponent>
|
</AccordionComponent>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -856,7 +856,6 @@ export async function requestLogout() {
|
||||||
export async function getVerticesOrder(
|
export async function getVerticesOrder(
|
||||||
flowId: string
|
flowId: string
|
||||||
): Promise<AxiosResponse<VerticesOrderTypeAPI>> {
|
): Promise<AxiosResponse<VerticesOrderTypeAPI>> {
|
||||||
console.log;
|
|
||||||
return await api.get(`${BASE_URL_API}build/${flowId}/vertices`);
|
return await api.get(`${BASE_URL_API}build/${flowId}/vertices`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { ReactElement, ReactNode } from "react";
|
import { ChangeEvent, ReactElement, ReactNode } from "react";
|
||||||
import { ReactFlowJsonObject, XYPosition } from "reactflow";
|
import { ReactFlowJsonObject, XYPosition } from "reactflow";
|
||||||
import { APIClassType, APITemplateType, TemplateVariableType } from "../api";
|
import { APIClassType, APITemplateType, TemplateVariableType } from "../api";
|
||||||
import { ChatMessageType } from "../chat";
|
import { ChatMessageType } from "../chat";
|
||||||
|
|
@ -645,3 +645,11 @@ export type dropdownButtonPropsType = {
|
||||||
onFirstBtnClick: () => void;
|
onFirstBtnClick: () => void;
|
||||||
options: Array<{ name: string; onBtnClick: () => void }>;
|
options: Array<{ name: string; onBtnClick: () => void }>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type IOInputProps = {
|
||||||
|
inputType: string;
|
||||||
|
value: string;
|
||||||
|
onChange: (e: ChangeEvent<HTMLTextAreaElement>) => void;
|
||||||
|
styleClasses: string;
|
||||||
|
placeholder: string;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue