MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / Sidebar

Function Sidebar

apps/start/src/components/sidebar.tsx:22–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

20import { cn } from '@/utils/cn';
21
22export function Sidebar() {
23 const { organizationId, projectId } = useParams({ strict: false });
24 const trpc = useTRPC();
25
26 // Get organizations data
27 const { data: organizations = [] } = useQuery(
28 trpc.organization.list.queryOptions()
29 );
30
31 // Get projects data when we have an organization
32 const { data: projects = [] } = useQuery({
33 ...trpc.project.list.queryOptions({
34 organizationId: organizationId || null,
35 }),
36 enabled: !!organizationId,
37 });
38
39 // Get dashboards data when we have a project
40 const { data: dashboards = [] } = useQuery({
41 ...trpc.dashboard.list.queryOptions({
42 projectId: projectId || '',
43 }),
44 enabled: !!projectId,
45 });
46
47 if (projectId && organizationId) {
48 return (
49 <SidebarContainer organizations={organizations} projects={projects}>
50 <ActionProjectCTAButton />
51 <SidebarProjectMenu dashboards={dashboards} />
52 </SidebarContainer>
53 );
54 }
55
56 // Otherwise show the original sidebar structure
57 return (
58 <SidebarContainer organizations={organizations} projects={projects}>
59 <ActionOrganizationCTAButton />
60 <div className="mb-2 font-medium text-muted-foreground">Organization</div>
61 <SidebarOrganizationMenu
62 organization={organizations.find((o) => o.id === organizationId)!}
63 />
64 </SidebarContainer>
65 );
66}
67
68interface SidebarContainerProps {
69 organizations: IServiceOrganization[];

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected