-
-
Notifications
You must be signed in to change notification settings - Fork 268
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #174 from n4ze3m/next
v1.5.0
- Loading branch information
Showing
65 changed files
with
1,092 additions
and
1,776 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
import { createHashRouter, RouterProvider } from "react-router-dom"; | ||
import Root from "./routes/root"; | ||
import DashboardLayout from "./Layout"; | ||
import NewRoot from "./routes/new/root"; | ||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; | ||
import BotLayout from "./Layout/BotLayout"; | ||
import BotEmbedRoot from "./routes/bot/embed"; | ||
import BotPreviewRoot from "./routes/bot/playground"; | ||
import BotDSRoot from "./routes/bot/ds"; | ||
import BotSettingsRoot from "./routes/bot/settings"; | ||
import LoginRoot from "./routes/login/root"; | ||
import { AuthProvider } from "./context/AuthContext"; | ||
import SettingsRoot from "./routes/settings/root"; | ||
import BotIntegrationRoot from "./routes/bot/integrations"; | ||
import BotAppearanceRoot from "./routes/bot/appearance"; | ||
import { ConfigProvider, theme } from "antd"; | ||
import { StyleProvider } from "@ant-design/cssinjs"; | ||
import BotPlaygroundLayout from "./Layout/BotPlaygroundLayout"; | ||
import BotConversationsRoot from "./routes/bot/conversations"; | ||
import RegisterRoot from "./routes/register"; | ||
import { QueryBoundaries } from "./components/Common/QueryBoundaries"; | ||
import SettingsApplicationRoot from "./routes/settings/application"; | ||
import SettingsTeamsRoot from "./routes/settings/teams"; | ||
import BotIntegrationAPIRoot from "./routes/bot/api"; | ||
import SettingsModelRoot from "./routes/settings/model"; | ||
import { useDarkMode } from "./hooks/useDarkmode"; | ||
|
||
const router = createHashRouter([ | ||
{ | ||
element: ( | ||
<DashboardLayout> | ||
<Root /> | ||
</DashboardLayout> | ||
), | ||
path: "/", | ||
}, | ||
{ | ||
element: ( | ||
<DashboardLayout> | ||
<NewRoot /> | ||
</DashboardLayout> | ||
), | ||
path: "/new", | ||
}, | ||
{ | ||
path: "/bot/:id/embed", | ||
element: ( | ||
<BotLayout> | ||
<BotEmbedRoot /> | ||
</BotLayout> | ||
), | ||
}, | ||
{ | ||
path: "/bot/:id", | ||
element: ( | ||
<BotLayout> | ||
<BotPreviewRoot /> | ||
</BotLayout> | ||
), | ||
}, | ||
{ | ||
path: "/bot/:id/playground/:history_id", | ||
element: ( | ||
<BotLayout> | ||
<BotPreviewRoot /> | ||
</BotLayout> | ||
), | ||
}, | ||
{ | ||
path: "/bot/:id/conversations", | ||
element: ( | ||
<BotPlaygroundLayout> | ||
<BotConversationsRoot /> | ||
</BotPlaygroundLayout> | ||
), | ||
}, | ||
{ | ||
path: "/bot/:id/conversations/:type/:conversation_id", | ||
element: ( | ||
<BotPlaygroundLayout> | ||
<BotConversationsRoot /> | ||
</BotPlaygroundLayout> | ||
), | ||
}, | ||
{ | ||
path: "/bot/:id/data-sources", | ||
element: ( | ||
<BotLayout> | ||
<BotDSRoot /> | ||
</BotLayout> | ||
), | ||
}, | ||
{ | ||
path: "/bot/:id/settings", | ||
element: ( | ||
<BotLayout> | ||
<BotSettingsRoot /> | ||
</BotLayout> | ||
), | ||
}, | ||
{ | ||
path: "/bot/:id/integrations", | ||
element: ( | ||
<BotLayout> | ||
<BotIntegrationRoot /> | ||
</BotLayout> | ||
), | ||
}, | ||
{ | ||
path: "/bot/:id/integrations/api", | ||
element: ( | ||
<BotLayout> | ||
<BotIntegrationAPIRoot /> | ||
</BotLayout> | ||
), | ||
}, | ||
{ | ||
path: "/bot/:id/appearance", | ||
element: ( | ||
<BotLayout> | ||
<BotAppearanceRoot /> | ||
</BotLayout> | ||
), | ||
}, | ||
{ | ||
path: "/login", | ||
element: <LoginRoot />, | ||
}, | ||
{ | ||
path: "/settings", | ||
element: ( | ||
<DashboardLayout> | ||
<QueryBoundaries> | ||
<SettingsRoot /> | ||
</QueryBoundaries> | ||
</DashboardLayout> | ||
), | ||
}, | ||
{ | ||
path: "/settings/application", | ||
element: ( | ||
<DashboardLayout> | ||
<QueryBoundaries> | ||
<SettingsApplicationRoot /> | ||
</QueryBoundaries> | ||
</DashboardLayout> | ||
), | ||
}, | ||
{ | ||
path: "/settings/teams", | ||
element: ( | ||
<DashboardLayout> | ||
<QueryBoundaries> | ||
<SettingsTeamsRoot /> | ||
</QueryBoundaries> | ||
</DashboardLayout> | ||
), | ||
}, | ||
{ | ||
path: "/settings/model", | ||
element: ( | ||
<DashboardLayout> | ||
<QueryBoundaries> | ||
<SettingsModelRoot /> | ||
</QueryBoundaries> | ||
</DashboardLayout> | ||
), | ||
}, | ||
{ | ||
path: "/register", | ||
element: <RegisterRoot />, | ||
}, | ||
]); | ||
const queryClient = new QueryClient({}); | ||
|
||
export default function App() { | ||
const { mode } = useDarkMode(); | ||
return ( | ||
<ConfigProvider | ||
theme={{ | ||
algorithm: | ||
mode === "dark" ? theme.darkAlgorithm : theme.defaultAlgorithm, | ||
}} | ||
> | ||
<StyleProvider hashPriority="high"> | ||
<AuthProvider> | ||
<QueryClientProvider client={queryClient}> | ||
<RouterProvider router={router} /> | ||
</QueryClientProvider> | ||
</AuthProvider> | ||
</StyleProvider> | ||
</ConfigProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { Menu } from "@headlessui/react"; | ||
import { Transition } from "@headlessui/react"; | ||
import { Fragment } from "react"; | ||
import { useAuth } from "../context/AuthContext"; | ||
import Avatar from "../components/Common/Avatar"; | ||
import { Link, useNavigate } from "react-router-dom"; | ||
import { SunIcon, MoonIcon } from "@heroicons/react/24/outline"; | ||
import { useDarkMode } from "../hooks/useDarkmode"; | ||
|
||
//@ts-ignore | ||
function classNames(...classes) { | ||
return classes.filter(Boolean).join(" "); | ||
} | ||
|
||
export const ApplicationMenu = () => { | ||
const { profile, logout } = useAuth(); | ||
const { mode, toggleDarkMode } = useDarkMode(); | ||
const navigate = useNavigate(); | ||
return ( | ||
<Menu as="div" className="relative ml-3"> | ||
<div> | ||
<Menu.Button className="flex max-w-xs items-center rounded-full bg-white text-sm dark:bg-black"> | ||
<span className="sr-only">Open user menu</span> | ||
<Avatar username={profile?.username || "admin"} /> | ||
</Menu.Button> | ||
</div> | ||
<Transition | ||
as={Fragment} | ||
enter="transition ease-out duration-200" | ||
enterFrom="transform opacity-0 scale-95" | ||
enterTo="transform opacity-100 scale-100" | ||
leave="transition ease-in duration-75" | ||
leaveFrom="transform opacity-100 scale-100" | ||
leaveTo="transform opacity-0 scale-95" | ||
> | ||
<Menu.Items className="absolute right-0 z-10 mt-2 w-48 origin-top-right rounded-md bg-white py-1 shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none dark:bg-black dark:border dark:border-gray-800 divide-y divide-gray-100 dark:divide-gray-800"> | ||
<Menu.Item> | ||
{({ active }) => ( | ||
<Link | ||
className={classNames( | ||
active ? "bg-gray-100" : "", | ||
"block px-4 py-2 text-sm text-gray-700 dark:text-white dark:hover:bg-gray-800 " | ||
)} | ||
to="/settings" | ||
> | ||
Settings | ||
</Link> | ||
)} | ||
</Menu.Item> | ||
<Menu.Item> | ||
{({ active }) => ( | ||
<div | ||
className={classNames( | ||
active ? "bg-gray-100" : "", | ||
"block px-4 py-2 text-sm text-gray-700 dark:text-white dark:hover:bg-gray-800 cursor-pointer" | ||
)} | ||
onClick={() => { | ||
toggleDarkMode(); | ||
}} | ||
> | ||
<span className="flex items-center"> | ||
{mode === "dark" ? ( | ||
<SunIcon className="w-5 h-5 mr-2" /> | ||
) : ( | ||
<MoonIcon className="w-5 h-5 mr-2" /> | ||
)} | ||
{mode === "dark" ? "Light mode" : "Dark mode"} | ||
</span> | ||
</div> | ||
)} | ||
</Menu.Item> | ||
<Menu.Item> | ||
{({ active }) => ( | ||
<span | ||
className={classNames( | ||
active ? "bg-gray-100" : "", | ||
"block px-4 py-2 text-sm text-red-700 dark:text-red-600 cursor-pointer dark:hover:bg-gray-800" | ||
)} | ||
onClick={() => { | ||
logout(); | ||
navigate("/login"); | ||
}} | ||
> | ||
Sign out | ||
</span> | ||
)} | ||
</Menu.Item> | ||
</Menu.Items> | ||
</Transition> | ||
</Menu> | ||
); | ||
}; |
Oops, something went wrong.