diff --git a/ui/admin/app/components/sidebar/Sidebar.tsx b/ui/admin/app/components/sidebar/Sidebar.tsx index d00866001..f43e299fe 100644 --- a/ui/admin/app/components/sidebar/Sidebar.tsx +++ b/ui/admin/app/components/sidebar/Sidebar.tsx @@ -1,19 +1,22 @@ import { BotIcon, BoxesIcon, + InfoIcon, KeyIcon, MessageSquare, PuzzleIcon, - SettingsIcon, User, WebhookIcon, Wrench, } from "lucide-react"; import { Link, useLocation } from "react-router"; import { $path } from "safe-routes"; +import useSWR from "swr"; +import { VersionApiService } from "~/lib/service/api/versionApiService"; import { cn } from "~/lib/utils"; +import { TypographyMuted, TypographySmall } from "~/components/Typography"; import { ObotLogo } from "~/components/branding/ObotLogo"; import { Button } from "~/components/ui/button"; import { @@ -21,6 +24,7 @@ import { PopoverContent, PopoverTrigger, } from "~/components/ui/popover"; +import { Separator } from "~/components/ui/separator"; import { Sidebar, SidebarContent, @@ -131,39 +135,48 @@ export function AppSidebar() { + + + ); } -// disabling this because this will inevitably be used in the future -// eslint-disable-next-line @typescript-eslint/no-unused-vars -function AppSidebarFooter() { +function VersionInfo() { const { state } = useSidebar(); - return ( - - - - - Settings - - - - - - - Manage OAuth Apps - - - - - + const getVersion = useSWR(VersionApiService.getVersion.key(), () => + VersionApiService.getVersion() ); + + const { data: version } = getVersion; + const versionEntries = Object.entries(version ?? {}); + return version?.obot ? ( + + + } + className="text-muted-foreground" + > + {state !== "collapsed" ? version.obot : null} + + + + + {versionEntries.map(([key, value], index) => + value ? ( + + {key}: + {value} + {index !== versionEntries.length - 1 && ( + + )} + + ) : null + )} + + + + ) : null; } diff --git a/ui/admin/app/lib/model/version.ts b/ui/admin/app/lib/model/version.ts new file mode 100644 index 000000000..e513c58a8 --- /dev/null +++ b/ui/admin/app/lib/model/version.ts @@ -0,0 +1,4 @@ +export type Version = { + obot: string; + [key: string]: string; +}; diff --git a/ui/admin/app/lib/routers/apiRoutes.ts b/ui/admin/app/lib/routers/apiRoutes.ts index 0171d8fc2..ba96455d0 100644 --- a/ui/admin/app/lib/routers/apiRoutes.ts +++ b/ui/admin/app/lib/routers/apiRoutes.ts @@ -217,6 +217,7 @@ export const ApiRoutes = { buildUrl(`/webhooks/${webhookId}`), invoke: (webhookId: string) => buildUrl(`/webhooks/${webhookId}`), }, + version: () => buildUrl("/version"), }; /** revalidates the cache for all routes that match the filter callback diff --git a/ui/admin/app/lib/service/api/versionApiService.ts b/ui/admin/app/lib/service/api/versionApiService.ts new file mode 100644 index 000000000..1fd84a64e --- /dev/null +++ b/ui/admin/app/lib/service/api/versionApiService.ts @@ -0,0 +1,17 @@ +import { Version } from "~/lib/model/version"; +import { ApiRoutes } from "~/lib/routers/apiRoutes"; +import { request } from "~/lib/service/api/primitives"; + +async function getVersion() { + const res = await request({ + url: ApiRoutes.version().url, + errorMessage: "Failed to fetch app version.", + }); + + return res.data; +} +getVersion.key = () => ({ url: ApiRoutes.version().path }) as const; + +export const VersionApiService = { + getVersion, +};