From 62b33a19dc23952c51e7dba4d1f86253e7aaf17f Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Wed, 7 Jun 2023 19:44:52 -0300 Subject: [PATCH] Changes to the menu structure --- src/frontend/package-lock.json | 33 +++ src/frontend/package.json | 1 + src/frontend/src/components/ui/menubar.tsx | 236 +++++++++++++++++++++ src/frontend/src/pages/MainPage/index.tsx | 198 +++++++++-------- src/frontend/src/utils.ts | 2 +- src/frontend/tailwind.config.js | 7 + 6 files changed, 391 insertions(+), 86 deletions(-) create mode 100644 src/frontend/src/components/ui/menubar.tsx diff --git a/src/frontend/package-lock.json b/src/frontend/package-lock.json index 4f7e78ca2..59a63669d 100644 --- a/src/frontend/package-lock.json +++ b/src/frontend/package-lock.json @@ -14,6 +14,7 @@ "@heroicons/react": "^2.0.15", "@mui/material": "^5.11.9", "@radix-ui/react-dropdown-menu": "^2.0.5", + "@radix-ui/react-menubar": "^1.0.3", "@radix-ui/react-separator": "^1.0.3", "@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-tabs": "^1.0.4", @@ -1559,6 +1560,38 @@ } } }, + "node_modules/@radix-ui/react-menubar": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@radix-ui/react-menubar/-/react-menubar-1.0.3.tgz", + "integrity": "sha512-GqjdxzYCjjKhcgEODDP8SrYfbWNh/Hm3lyuFkP5Q5IbX0QfXklLF1o1AqA3oTV2kulUgN/kOZVS92hIIShEgpA==", + "dependencies": { + "@babel/runtime": "^7.13.10", + "@radix-ui/primitive": "1.0.1", + "@radix-ui/react-collection": "1.0.3", + "@radix-ui/react-compose-refs": "1.0.1", + "@radix-ui/react-context": "1.0.1", + "@radix-ui/react-direction": "1.0.1", + "@radix-ui/react-id": "1.0.1", + "@radix-ui/react-menu": "2.0.5", + "@radix-ui/react-primitive": "1.0.3", + "@radix-ui/react-roving-focus": "1.0.4", + "@radix-ui/react-use-controllable-state": "1.0.1" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0", + "react-dom": "^16.8 || ^17.0 || ^18.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, "node_modules/@radix-ui/react-popper": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@radix-ui/react-popper/-/react-popper-1.1.2.tgz", diff --git a/src/frontend/package.json b/src/frontend/package.json index 42d42adea..054fa8bd0 100644 --- a/src/frontend/package.json +++ b/src/frontend/package.json @@ -9,6 +9,7 @@ "@heroicons/react": "^2.0.15", "@mui/material": "^5.11.9", "@radix-ui/react-dropdown-menu": "^2.0.5", + "@radix-ui/react-menubar": "^1.0.3", "@radix-ui/react-separator": "^1.0.3", "@radix-ui/react-slot": "^1.0.2", "@radix-ui/react-tabs": "^1.0.4", diff --git a/src/frontend/src/components/ui/menubar.tsx b/src/frontend/src/components/ui/menubar.tsx new file mode 100644 index 000000000..2eb3a61f4 --- /dev/null +++ b/src/frontend/src/components/ui/menubar.tsx @@ -0,0 +1,236 @@ +"use client"; + +import * as React from "react"; +import * as MenubarPrimitive from "@radix-ui/react-menubar"; +import { Check, ChevronRight, Circle } from "lucide-react"; + +import { cn } from "../../utils"; + +const MenubarMenu = MenubarPrimitive.Menu; + +const MenubarGroup = MenubarPrimitive.Group; + +const MenubarPortal = MenubarPrimitive.Portal; + +const MenubarSub = MenubarPrimitive.Sub; + +const MenubarRadioGroup = MenubarPrimitive.RadioGroup; + +const Menubar = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +Menubar.displayName = MenubarPrimitive.Root.displayName; + +const MenubarTrigger = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +MenubarTrigger.displayName = MenubarPrimitive.Trigger.displayName; + +const MenubarSubTrigger = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef & { + inset?: boolean; + } +>(({ className, inset, children, ...props }, ref) => ( + + {children} + + +)); +MenubarSubTrigger.displayName = MenubarPrimitive.SubTrigger.displayName; + +const MenubarSubContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +MenubarSubContent.displayName = MenubarPrimitive.SubContent.displayName; + +const MenubarContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>( + ( + { className, align = "start", alignOffset = -4, sideOffset = 8, ...props }, + ref + ) => ( + + + + ) +); +MenubarContent.displayName = MenubarPrimitive.Content.displayName; + +const MenubarItem = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef & { + inset?: boolean; + } +>(({ className, inset, ...props }, ref) => ( + +)); +MenubarItem.displayName = MenubarPrimitive.Item.displayName; + +const MenubarCheckboxItem = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, checked, ...props }, ref) => ( + + + + + + + {children} + +)); +MenubarCheckboxItem.displayName = MenubarPrimitive.CheckboxItem.displayName; + +const MenubarRadioItem = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, children, ...props }, ref) => ( + + + + + + + {children} + +)); +MenubarRadioItem.displayName = MenubarPrimitive.RadioItem.displayName; + +const MenubarLabel = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef & { + inset?: boolean; + } +>(({ className, inset, ...props }, ref) => ( + +)); +MenubarLabel.displayName = MenubarPrimitive.Label.displayName; + +const MenubarSeparator = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + +)); +MenubarSeparator.displayName = MenubarPrimitive.Separator.displayName; + +const MenubarShortcut = ({ + className, + ...props +}: React.HTMLAttributes) => { + return ( + + ); +}; +MenubarShortcut.displayname = "MenubarShortcut"; + +export { + Menubar, + MenubarMenu, + MenubarTrigger, + MenubarContent, + MenubarItem, + MenubarSeparator, + MenubarLabel, + MenubarCheckboxItem, + MenubarRadioGroup, + MenubarRadioItem, + MenubarPortal, + MenubarSubContent, + MenubarSubTrigger, + MenubarGroup, + MenubarSub, + MenubarShortcut, +}; diff --git a/src/frontend/src/pages/MainPage/index.tsx b/src/frontend/src/pages/MainPage/index.tsx index b247253b3..36b24a17d 100644 --- a/src/frontend/src/pages/MainPage/index.tsx +++ b/src/frontend/src/pages/MainPage/index.tsx @@ -23,7 +23,9 @@ import { CodeBracketSquareIcon, GlobeAltIcon, PencilSquareIcon, + PlusCircleIcon, PlusIcon, + PlusSmallIcon, TrashIcon, } from "@heroicons/react/24/outline"; import { @@ -54,6 +56,16 @@ import RenameLabel from "../../components/ui/rename-label"; import _ from "lodash"; import { Badge } from "../../components/ui/badge"; import { OpenAiIcon } from "../../icons/OpenAi"; +import { Menu } from "@mui/material"; +import { + Menubar, + MenubarContent, + MenubarItem, + MenubarMenu, + MenubarRadioGroup, + MenubarRadioItem, + MenubarTrigger, +} from "../../components/ui/menubar"; export default function HomePage() { const { @@ -88,89 +100,101 @@ export default function HomePage() { onValueChange={setActiveTab} className="w-full h-full flex flex-col" > - +
⛓️ -
- - { - if (value !== "") { - let newFlow = _.cloneDeep(flows[tabIndex]); - newFlow.name = value; - updateFlow(newFlow); - } - }} - rename={rename} - setRename={setRename} - /> - - - - - - Current Flow - { - setRename(true); - }} - > - - Rename - - { - openPopUp(); - }} - > - - Import - - { - openPopUp(); - }} - > - - Export - - { - openPopUp(); - }} - > - - Code - - - Flows - { - setTabIndex(parseInt(value)); - }} - > - {flows.map((flow, idx) => { - return ( - - {flow.name} - - ); - })} - - { - addFlow(); - }} - > - - Add Flow - - - - -
+ {activeTab === "myflow" && ( +
+ + + + + { + if (value !== "") { + let newFlow = _.cloneDeep(flows[tabIndex]); + newFlow.name = value; + updateFlow(newFlow); + } + }} + rename={rename} + setRename={setRename} + /> + + + + { + openPopUp(); + }} + > + + Import + + { + openPopUp(); + }} + > + + Export + + { + openPopUp( + + ); + }} + > + + Code + + + + + Edit + + { + setRename(true); + }} + > + + Rename + + + + + Flows + + { + setTabIndex(parseInt(value)); + }} + > + {flows.map((flow, idx) => { + return ( + + {flow.name} + + ); + })} + + { + addFlow(); + }} + > + + Add Flow + + + + +
+ )}
Explore @@ -283,9 +307,13 @@ export default function HomePage() { - - {/* {flow.description} */} - {idx === 0 ? "This is a new agent" : "This is a new tool"} + +
+ {idx === 0 + ? "This flow creates an agent that accesses a department store database and APIs to monitor customer activity and overall storage." + : "This is a new tool"} + {/* {flow.description} */} +
@@ -314,7 +342,7 @@ export default function HomePage() { }} > - Edit Flow + Edit
diff --git a/src/frontend/src/utils.ts b/src/frontend/src/utils.ts index 0e0459c69..4d645526c 100644 --- a/src/frontend/src/utils.ts +++ b/src/frontend/src/utils.ts @@ -7,7 +7,6 @@ import { WrenchScrewdriverIcon, WrenchIcon, ComputerDesktopIcon, - Bars3CenterLeftIcon, GiftIcon, PaperClipIcon, QuestionMarkCircleIcon, @@ -15,6 +14,7 @@ import { ScissorsIcon, CircleStackIcon, Squares2X2Icon, + Bars3CenterLeftIcon, } from "@heroicons/react/24/outline"; import { Connection, Edge, Node, ReactFlowInstance, addEdge } from "reactflow"; import { FlowType, NodeType } from "./types/flow"; diff --git a/src/frontend/tailwind.config.js b/src/frontend/tailwind.config.js index e8815e399..28636cc00 100644 --- a/src/frontend/tailwind.config.js +++ b/src/frontend/tailwind.config.js @@ -111,6 +111,13 @@ module.exports = { "overflow": "hidden", "text-overflow": "ellipsis", }, + ".truncate-doubleline": { + "display": "-webkit-box", + "-webkit-line-clamp": "2", /* Change this number to the number of lines you want to show */ + "-webkit-box-orient": "vertical", + "overflow": "hidden", + "text-overflow": "ellipsis", + }, ".arrow-hide": { "&::-webkit-inner-spin-button": {