diff --git a/eventmesh-dashboard/.gitignore b/eventmesh-dashboard/.gitignore index d423e860ee..8453b69998 100644 --- a/eventmesh-dashboard/.gitignore +++ b/eventmesh-dashboard/.gitignore @@ -124,3 +124,9 @@ yarn-error.log* # vercel .vercel + +# VS code settings +.vscode + +# Yarn lock +yarn.lock \ No newline at end of file diff --git a/eventmesh-dashboard/components/Sidebar.tsx b/eventmesh-dashboard/components/Sidebar.tsx deleted file mode 100644 index dd75092763..0000000000 --- a/eventmesh-dashboard/components/Sidebar.tsx +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/* eslint-disable react/jsx-props-no-spreading */ -import React, { ReactNode } from 'react'; -import { - IconButton, - Box, - CloseButton, - Flex, - Icon, - useColorModeValue, - Link, - Drawer, - DrawerContent, - Text, - useDisclosure, - BoxProps, - FlexProps, -} from '@chakra-ui/react'; -import { - FiList, - FiGrid, - FiServer, - FiDatabase, - FiMenu, -} from 'react-icons/fi'; -import { IconType } from 'react-icons'; - -interface LinkItemProps { - name: string; - icon: IconType; - href: string; -} - -const LinkItems: Array = [ - { name: 'Overview', icon: FiList, href: '/' }, - { name: 'Metrics', icon: FiMenu, href: '/metrics' }, - { name: 'Registry', icon: FiDatabase, href: '/registry' }, - { name: 'TCP Client', icon: FiServer, href: '/tcp' }, - { name: 'HTTP Client', icon: FiServer, href: '/http' }, - { name: 'gRPC Client', icon: FiServer, href: '/grpc' }, - { name: 'Topic', icon: FiGrid, href: '/topic' }, - { name: 'Event', icon: FiDatabase, href: '/event' }, -]; - -interface NavItemProps extends FlexProps { - icon: IconType; - href: string; - children: string | number; -} - -const NavItem = ({ - icon, href, children, ...rest -}: NavItemProps) => ( - - - {icon && ( - - )} - {children} - - -); - -interface SidebarProps extends BoxProps { - onClose: () => void; -} - -const SidebarContent = ({ onClose, ...rest }: SidebarProps) => ( - - - - EventMesh - - - - {LinkItems.map((link) => ( - - {link.name} - - ))} - -); - -interface MobileProps extends FlexProps { - onOpen: () => void; -} - -const MobileNav = ({ onOpen }: MobileProps) => ( - - } - /> - - - EventMesh - - -); - -const Sidebar = ({ children }: { children: ReactNode }) => { - const { isOpen, onOpen, onClose } = useDisclosure(); - return ( - - onClose} - display={{ base: 'none', md: 'block' }} - /> - - - - - - - - - {children} - - - ); -}; - -export default Sidebar; diff --git a/eventmesh-dashboard/components/navigation/MenuItem.tsx b/eventmesh-dashboard/components/navigation/MenuItem.tsx new file mode 100644 index 0000000000..1ed3f9b554 --- /dev/null +++ b/eventmesh-dashboard/components/navigation/MenuItem.tsx @@ -0,0 +1,98 @@ +import React, { FC, ReactNode } from 'react'; +import { + Flex, FlexProps, Link, Text, +} from '@chakra-ui/react'; + +interface MenuItemProps extends FlexProps { + key: string; + selected: boolean; + active: boolean; + href: string; + children: string | number; + setActiveName: (name: string) => void; +} + +export const MenuItem = ({ + selected, + active, + href, + children, + setActiveName, +}: MenuItemProps) => ( + setActiveName(children.toString())} + onMouseOut={() => setActiveName('')} + > + + {children} + + {/* */} + +); + +export const MenuGroupItem: FC<{ name: string; children: ReactNode }> = ( + props, +) => { + const { name, children } = props; + return ( + + {name && ( + + {name.toUpperCase()} + + )} + {children} + + ); +}; diff --git a/eventmesh-dashboard/components/navigation/Menus.tsx b/eventmesh-dashboard/components/navigation/Menus.tsx new file mode 100644 index 0000000000..4df43c0118 --- /dev/null +++ b/eventmesh-dashboard/components/navigation/Menus.tsx @@ -0,0 +1,160 @@ +import React, { FC, ReactNode, useState } from 'react'; +import { + Box, + BoxProps, + Button, + Flex, + useColorModeValue, + Image, +} from '@chakra-ui/react'; +import { IconType } from 'react-icons'; +import { ArrowBackIcon } from '@chakra-ui/icons'; + +import { useRouter } from 'next/router'; + +import { + FiList, FiGrid, FiServer, FiDatabase, FiMenu, +} from 'react-icons/fi'; +import LogoImg from '../../static/images/logo.png'; +import { MenuItem, MenuGroupItem } from './MenuItem'; + +const Menus: Array<{ + group?: string; + name: string; + icon: IconType; + href: string; + subPath?:string[] +}> = [ + { name: 'Overview', icon: FiList, href: '/' }, + { name: 'Metrics', icon: FiMenu, href: '/metrics' }, + { name: 'Registry', icon: FiDatabase, href: '/registry' }, + { name: 'Topic', icon: FiGrid, href: '/topic' }, + { name: 'Event', icon: FiDatabase, href: '/event' }, + { + group: 'Workflow', + name: 'Workflows', + icon: FiServer, + href: '/workflows', + subPath: ['/workflows/create'], + }, + { + group: 'Workflow', + name: 'Event Catalogs', + icon: FiServer, + href: '/eventCatalogs', + }, + { + group: 'Clients', + name: 'TCP', + icon: FiServer, + href: '/tcp', + }, + { + group: 'Clients', + name: 'HTTP', + icon: FiServer, + href: '/http', + }, + { + group: 'Clients', + name: 'gRPC', + icon: FiServer, + href: '/grpc', + }, +]; + +interface MenuProps extends BoxProps { + onClose: () => void; +} +interface IGroupItem { + name?: string; + children: ReactNode[]; +} + +const NavMenu: FC = ({ display = {}, onClose }) => { + const router = useRouter(); + const [curMenu, setCurMenu] = useState(''); + const curRoute = router.pathname; + + const MenuByGroup = Menus.reduce<{ + [groupName: string]: IGroupItem; + }>( + (groupItems, item) => { + const { + group, name, href, subPath, + } = item; + const menuItem = ( + setCurMenu(selectedName)} + > + {name} + + ); + + if (!group) { + groupItems.topMenu.children.push(menuItem); + return groupItems; + } + + if (!groupItems[group]) { + groupItems[group] = { name: group, children: [] }; + } + groupItems[group].children.push(menuItem); + + return groupItems; + }, + { topMenu: { children: [] } }, + ); + + return ( + + + Dan Abramov + + + + + {Object.entries(MenuByGroup).map((groupItem) => ( + + {groupItem[1].children} + + ))} + + + ); +}; + +export default NavMenu; diff --git a/eventmesh-dashboard/components/navigation/MenusMobile.tsx b/eventmesh-dashboard/components/navigation/MenusMobile.tsx new file mode 100644 index 0000000000..be083b9804 --- /dev/null +++ b/eventmesh-dashboard/components/navigation/MenusMobile.tsx @@ -0,0 +1,39 @@ +import { + IconButton, + Flex, + useColorModeValue, + Text, + FlexProps, +} from '@chakra-ui/react'; +import { FiMenu } from 'react-icons/fi'; + +interface MobileProps extends FlexProps { + onOpen: () => void; +} + +const MobileNav = ({ onOpen }: MobileProps) => ( + + } + /> + + + EventMesh + + +); + +export default MobileNav; diff --git a/eventmesh-dashboard/components/navigation/Sidebar.tsx b/eventmesh-dashboard/components/navigation/Sidebar.tsx new file mode 100644 index 0000000000..e8e349b23b --- /dev/null +++ b/eventmesh-dashboard/components/navigation/Sidebar.tsx @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* eslint-disable react/jsx-props-no-spreading */ +import React, { FC, ReactNode } from 'react'; +import { + Box, + useColorModeValue, + Drawer, + DrawerContent, + useDisclosure, +} from '@chakra-ui/react'; +import Menus from './Menus'; +import MenusMobile from './MenusMobile'; + +const Sidebar: FC<{ children: ReactNode }> = ({ children }) => { + const { isOpen, onOpen, onClose } = useDisclosure(); + return ( + <> + + onClose} + /> + + + {children} + + + + + + + + + ); +}; + +export default Sidebar; diff --git a/eventmesh-dashboard/package.json b/eventmesh-dashboard/package.json index 8617a49e93..6d8ae58caa 100644 --- a/eventmesh-dashboard/package.json +++ b/eventmesh-dashboard/package.json @@ -9,10 +9,12 @@ "lint": "eslint . --cache --fix --ext .ts,.tsx" }, "dependencies": { + "@chakra-ui/icons": "^2.0.15", "@chakra-ui/react": "^2.1.2", "@emotion/react": "^11.9.0", "@emotion/styled": "^11.8.1", "@fontsource/inter": "^4.5.10", + "@monaco-editor/react": "^4.4.6", "axios": "^0.27.2", "cloudevents": "^6.0.2", "framer-motion": "^6.3.6", diff --git a/eventmesh-dashboard/pages/_app.tsx b/eventmesh-dashboard/pages/_app.tsx index a8dda2f86f..6095173752 100644 --- a/eventmesh-dashboard/pages/_app.tsx +++ b/eventmesh-dashboard/pages/_app.tsx @@ -21,7 +21,7 @@ import '@fontsource/inter'; import { ChakraProvider, extendTheme } from '@chakra-ui/react'; import type { AppProps } from 'next/app'; -import Sidebar from '../components/Sidebar'; +import Sidebar from '../components/navigation/Sidebar'; import { AppProvider } from '../context/context'; const theme = extendTheme({ diff --git a/eventmesh-dashboard/pages/workflows/create.tsx b/eventmesh-dashboard/pages/workflows/create.tsx new file mode 100644 index 0000000000..41ed21bf7b --- /dev/null +++ b/eventmesh-dashboard/pages/workflows/create.tsx @@ -0,0 +1,93 @@ +import React, { useRef } from 'react'; +import Head from 'next/head'; +import type { NextPage } from 'next'; + +import { + Stack, + Breadcrumb, + BreadcrumbItem, + BreadcrumbLink, + Grid, + GridItem, + FormControl, + FormLabel, + Input, + Button, + Textarea, +} from '@chakra-ui/react'; + +import Editor from '@monaco-editor/react'; +import { useRouter } from 'next/router'; + +const Workflows: NextPage = () => { + const editorRef = useRef(null); + const router = useRouter(); + + const handleEditorDidMount = (editor: any) => { + // here is the editor instance + // you can store it in `useRef` for further usage + console.log('hhh'); + editorRef.current = editor; + }; + + return ( + <> + + Create Workflow | Apache EventMesh Dashboard + + + + Workflows + + + + Create + + + + + + + Workflow name + + + + + Description +