Changed tabs layout to existing tabs
This commit is contained in:
parent
4e8de33f75
commit
f446ce5a0b
3 changed files with 23 additions and 25 deletions
|
|
@ -2,13 +2,13 @@ import { ReactNode, useState } from "react";
|
||||||
import useFlowStore from "../../stores/flowStore";
|
import useFlowStore from "../../stores/flowStore";
|
||||||
import { NodeType } from "../../types/flow";
|
import { NodeType } from "../../types/flow";
|
||||||
import { isInputType, isOutputType } from "../../utils/reactflowUtils";
|
import { isInputType, isOutputType } from "../../utils/reactflowUtils";
|
||||||
import { classNames } from "../../utils/utils";
|
|
||||||
import AccordionComponent from "../AccordionComponent";
|
import AccordionComponent from "../AccordionComponent";
|
||||||
import IOInputField from "../IOInputField";
|
import IOInputField from "../IOInputField";
|
||||||
import IOOutputView from "../IOOutputView";
|
import IOOutputView from "../IOOutputView";
|
||||||
import IconComponent from "../genericIconComponent";
|
import IconComponent from "../genericIconComponent";
|
||||||
import NewChatView from "../newChatView";
|
import NewChatView from "../newChatView";
|
||||||
import { Badge } from "../ui/badge";
|
import { Badge } from "../ui/badge";
|
||||||
|
import { Button } from "../ui/button";
|
||||||
|
|
||||||
export default function IOView(): JSX.Element {
|
export default function IOView(): JSX.Element {
|
||||||
const inputs = useFlowStore((state) => state.inputs);
|
const inputs = useFlowStore((state) => state.inputs);
|
||||||
|
|
@ -18,15 +18,15 @@ 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 categories = getCategories();
|
const categories = getCategories();
|
||||||
const [selectedCategory, setSelectedCategory] = useState<string>(
|
const [selectedCategory, setSelectedCategory] = useState<number>(0);
|
||||||
categories[0]
|
|
||||||
);
|
|
||||||
const [showChat, setShowChat] = useState<boolean>(false);
|
const [showChat, setShowChat] = useState<boolean>(false);
|
||||||
const [selectedView, setSelectedView] = useState<{
|
const [selectedView, setSelectedView] = useState<{
|
||||||
type: string;
|
type: string;
|
||||||
id?: string;
|
id?: string;
|
||||||
}>(handleInitialView());
|
}>(handleInitialView());
|
||||||
|
|
||||||
|
type CategoriesType = { name: string; icon: string };
|
||||||
|
|
||||||
function handleInitialView() {
|
function handleInitialView() {
|
||||||
if (
|
if (
|
||||||
outputs.map((output) => output.type).includes("ChatOutput") ||
|
outputs.map((output) => output.type).includes("ChatOutput") ||
|
||||||
|
|
@ -38,10 +38,11 @@ export default function IOView(): JSX.Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCategories() {
|
function getCategories() {
|
||||||
const categories: string[] = [];
|
const categories: CategoriesType[] = [];
|
||||||
if (inputs.length > 0) categories.push("Inputs");
|
if (inputs.length > 0)
|
||||||
|
categories.push({ name: "Inputs", icon: "TextCursorInput" });
|
||||||
if (outputs.filter((output) => output.type !== "ChatOutput").length > 0)
|
if (outputs.filter((output) => output.type !== "ChatOutput").length > 0)
|
||||||
categories.push("Outputs");
|
categories.push({ name: "Outputs", icon: "TerminalSquare" });
|
||||||
return categories;
|
return categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -56,7 +57,7 @@ export default function IOView(): JSX.Element {
|
||||||
}
|
}
|
||||||
|
|
||||||
function UpdateAccordion() {
|
function UpdateAccordion() {
|
||||||
return selectedCategory === "Inputs" ? inputs : outputs;
|
return categories[selectedCategory].name === "Inputs" ? inputs : outputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -66,24 +67,19 @@ export default function IOView(): JSX.Element {
|
||||||
{categories.map((category, index) => {
|
{categories.map((category, index) => {
|
||||||
return (
|
return (
|
||||||
//hide chat button if chat is alredy on the view
|
//hide chat button if chat is alredy on the view
|
||||||
<button
|
<Button
|
||||||
onClick={() => setSelectedCategory(category)}
|
onClick={() => setSelectedCategory(index)}
|
||||||
className={classNames(
|
variant={index === selectedCategory ? "primary" : "secondary"}
|
||||||
"cursor flex items-center rounded-md rounded-b-none px-1",
|
|
||||||
category == selectedCategory
|
|
||||||
? "border border-b-0 border-muted-foreground"
|
|
||||||
: "hover:bg-muted-foreground"
|
|
||||||
)}
|
|
||||||
key={index}
|
key={index}
|
||||||
>
|
>
|
||||||
<IconComponent
|
<IconComponent
|
||||||
name="Variable"
|
name={category.icon}
|
||||||
className=" file-component-variable"
|
className=" file-component-variable"
|
||||||
/>
|
/>
|
||||||
<span className="file-component-variables-span text-md">
|
<span className="file-component-variables-span text-md">
|
||||||
{category}
|
{category.name}
|
||||||
</span>
|
</span>
|
||||||
</button>
|
</Button>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{(outputs.map((output) => output.type).includes("ChatOutput") ||
|
{(outputs.map((output) => output.type).includes("ChatOutput") ||
|
||||||
|
|
@ -137,7 +133,7 @@ export default function IOView(): JSX.Element {
|
||||||
>
|
>
|
||||||
<div className="file-component-tab-column">
|
<div className="file-component-tab-column">
|
||||||
{node &&
|
{node &&
|
||||||
(selectedCategory === "Inputs" ? (
|
(categories[selectedCategory].name === "Inputs" ? (
|
||||||
<IOInputField
|
<IOInputField
|
||||||
inputType={input.type}
|
inputType={input.type}
|
||||||
inputId={input.id}
|
inputId={input.id}
|
||||||
|
|
|
||||||
|
|
@ -681,4 +681,4 @@ export const LANGFLOW_SUPPORTED_TYPES = new Set([
|
||||||
export const priorityFields = new Set(["code", "template"]);
|
export const priorityFields = new Set(["code", "template"]);
|
||||||
|
|
||||||
export const INPUT_TYPES = new Set(["ChatInput", "TextInput"]);
|
export const INPUT_TYPES = new Set(["ChatInput", "TextInput"]);
|
||||||
export const OUTPUT_TYPES = new Set(["ChatOutput",]);
|
export const OUTPUT_TYPES = new Set(["ChatOutput", "PromptTemplate"]);
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
import {
|
import {
|
||||||
ArrowDownUp,
|
AlertCircle,
|
||||||
ArrowUpToLine,
|
ArrowUpToLine,
|
||||||
Bell,
|
Bell,
|
||||||
BookMarked,
|
BookMarked,
|
||||||
BookmarkPlus,
|
BookmarkPlus,
|
||||||
Boxes,
|
Boxes,
|
||||||
|
Cable,
|
||||||
Check,
|
Check,
|
||||||
CheckCircle2,
|
CheckCircle2,
|
||||||
ChevronDown,
|
ChevronDown,
|
||||||
|
|
@ -34,9 +35,9 @@ import {
|
||||||
FileSearch,
|
FileSearch,
|
||||||
FileSearch2,
|
FileSearch2,
|
||||||
FileText,
|
FileText,
|
||||||
Cable,
|
|
||||||
FileUp,
|
FileUp,
|
||||||
Fingerprint,
|
Fingerprint,
|
||||||
|
FlaskConical,
|
||||||
FolderPlus,
|
FolderPlus,
|
||||||
Forward,
|
Forward,
|
||||||
Gift,
|
Gift,
|
||||||
|
|
@ -92,6 +93,7 @@ import {
|
||||||
SunIcon,
|
SunIcon,
|
||||||
TerminalIcon,
|
TerminalIcon,
|
||||||
TerminalSquare,
|
TerminalSquare,
|
||||||
|
TextCursorInput,
|
||||||
ToyBrick,
|
ToyBrick,
|
||||||
Trash2,
|
Trash2,
|
||||||
Undo,
|
Undo,
|
||||||
|
|
@ -110,8 +112,6 @@ import {
|
||||||
X,
|
X,
|
||||||
XCircle,
|
XCircle,
|
||||||
Zap,
|
Zap,
|
||||||
FlaskConical,
|
|
||||||
AlertCircle,
|
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { FaApple, FaGithub } from "react-icons/fa";
|
import { FaApple, FaGithub } from "react-icons/fa";
|
||||||
import { AWSIcon } from "../icons/AWS";
|
import { AWSIcon } from "../icons/AWS";
|
||||||
|
|
@ -398,6 +398,8 @@ export const nodeIconsLucide: iconsType = {
|
||||||
RefreshCcw,
|
RefreshCcw,
|
||||||
Combine,
|
Combine,
|
||||||
TerminalIcon,
|
TerminalIcon,
|
||||||
|
TerminalSquare,
|
||||||
|
TextCursorInput,
|
||||||
Repeat,
|
Repeat,
|
||||||
io: Cable,
|
io: Cable,
|
||||||
ScreenShare,
|
ScreenShare,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue