Skip to content

Commit b74ea8c

Browse files
committed
splitted inside course sidebar into general and course
1 parent 8bd4c8f commit b74ea8c

File tree

8 files changed

+94
-213
lines changed

8 files changed

+94
-213
lines changed
Lines changed: 2 additions & 134 deletions
Original file line numberDiff line numberDiff line change
@@ -1,148 +1,16 @@
11
'use client'
22

33
import * as React from 'react'
4-
import {
5-
BellElectric,
6-
BookOpen,
7-
Bot,
8-
FileUser,
9-
Settings2,
10-
SquareTerminal,
11-
Users,
12-
} from 'lucide-react'
134

145
import { Sidebar } from '@/components/ui/sidebar'
15-
import { InsideCourseSidebar } from './InsideCourseSidebar'
6+
import { InsideSidebar } from './InsideSidebar/InsideSidebar'
167
import { CourseSwitchSidebar } from './CourseSwitchSidebar/CourseSwitchSidebar'
178

18-
const data = {
19-
user: {
20-
name: 'shadcn',
21-
22-
avatar: '/avatars/shadcn.jpg',
23-
},
24-
navMain: [
25-
{
26-
title: 'iPraktikum',
27-
url: '#',
28-
icon: SquareTerminal,
29-
isActive: true,
30-
items: [
31-
{
32-
title: 'Application',
33-
url: '#',
34-
icon: FileUser,
35-
items: [
36-
{
37-
title: 'Dashboard',
38-
url: '#',
39-
},
40-
{
41-
title: 'Applications',
42-
url: '#',
43-
},
44-
{
45-
title: 'Application Questions',
46-
url: '#',
47-
},
48-
],
49-
},
50-
{
51-
title: 'Intro Course',
52-
url: '#',
53-
icon: BellElectric,
54-
},
55-
{
56-
title: 'Team Phase',
57-
url: '#',
58-
icon: Users,
59-
},
60-
{
61-
title: 'Settings',
62-
url: '#',
63-
icon: Settings2,
64-
},
65-
],
66-
},
67-
{
68-
title: 'Models',
69-
url: '#',
70-
icon: Bot,
71-
items: [
72-
{
73-
title: 'Genesis',
74-
url: '#',
75-
icon: Settings2,
76-
},
77-
{
78-
title: 'Explorer',
79-
url: '#',
80-
icon: Settings2,
81-
},
82-
{
83-
title: 'Quantum',
84-
url: '#',
85-
icon: Settings2,
86-
},
87-
],
88-
},
89-
{
90-
title: 'Documentation',
91-
url: '#',
92-
icon: BookOpen,
93-
items: [
94-
{
95-
title: 'Introduction',
96-
url: '#',
97-
},
98-
{
99-
title: 'Get Started',
100-
url: '#',
101-
},
102-
{
103-
title: 'Tutorials',
104-
url: '#',
105-
},
106-
{
107-
title: 'Changelog',
108-
url: '#',
109-
},
110-
],
111-
},
112-
{
113-
title: 'Settings',
114-
url: '#',
115-
icon: Settings2,
116-
items: [
117-
{
118-
title: 'General',
119-
url: '#',
120-
},
121-
{
122-
title: 'Team',
123-
url: '#',
124-
},
125-
{
126-
title: 'Billing',
127-
url: '#',
128-
},
129-
{
130-
title: 'Limits',
131-
url: '#',
132-
},
133-
],
134-
},
135-
],
136-
}
137-
1389
interface AppSidebarProps extends React.ComponentProps<typeof Sidebar> {
13910
onLogout: () => void
14011
}
14112

14213
export function AppSidebar({ onLogout, ...props }: AppSidebarProps): JSX.Element {
143-
// TODO this will be replaced with router logic
144-
const [activeItem] = React.useState(data.navMain[0])
145-
14614
return (
14715
<Sidebar
14816
collapsible='icon'
@@ -151,7 +19,7 @@ export function AppSidebar({ onLogout, ...props }: AppSidebarProps): JSX.Element
15119
>
15220
{/* This is the first sidebar */}
15321
<CourseSwitchSidebar onLogout={onLogout} />
154-
<InsideCourseSidebar activeItem={activeItem} />
22+
<InsideSidebar />
15523
</Sidebar>
15624
)
15725
}

clients/core/src/Sidebar/InsideCourseSidebar.tsx

Lines changed: 0 additions & 79 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { SidebarMenu } from '@/components/ui/sidebar'
2+
3+
export const InsideCourseSidebar = (): JSX.Element => {
4+
return <SidebarMenu></SidebarMenu>
5+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'
2+
import {
3+
SidebarMenu,
4+
SidebarMenuButton,
5+
SidebarMenuItem,
6+
SidebarMenuSub,
7+
SidebarMenuSubButton,
8+
SidebarMenuSubItem,
9+
} from '@/components/ui/sidebar'
10+
import { ChevronRight, Settings } from 'lucide-react'
11+
12+
export const InsideGeneralSidebar = (): JSX.Element => {
13+
return (
14+
<SidebarMenu>
15+
<SidebarMenuItem>
16+
<Collapsible key={'settings'} asChild defaultOpen={false} className='group/collapsible'>
17+
<SidebarMenuItem>
18+
<CollapsibleTrigger asChild>
19+
<SidebarMenuButton tooltip={'Settings'}>
20+
<Settings />
21+
<span>Settings</span>
22+
<ChevronRight className='ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90' />
23+
</SidebarMenuButton>
24+
</CollapsibleTrigger>
25+
<CollapsibleContent>
26+
<SidebarMenuSub>
27+
<SidebarMenuSubItem key={'Something'}>
28+
<SidebarMenuSubButton asChild>
29+
<span>Something</span>
30+
</SidebarMenuSubButton>
31+
</SidebarMenuSubItem>
32+
<SidebarMenuSubItem key={'Something else'}>
33+
<SidebarMenuSubButton asChild>
34+
<span>Something else</span>
35+
</SidebarMenuSubButton>
36+
</SidebarMenuSubItem>
37+
</SidebarMenuSub>
38+
</CollapsibleContent>
39+
</SidebarMenuItem>
40+
</Collapsible>
41+
</SidebarMenuItem>
42+
</SidebarMenu>
43+
)
44+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Label } from '@/components/ui/label'
2+
import {
3+
Sidebar,
4+
SidebarContent,
5+
SidebarGroup,
6+
SidebarGroupContent,
7+
SidebarHeader,
8+
} from '@/components/ui/sidebar'
9+
import { useCourseStore } from '@/zustand/useCourseStore'
10+
import { useLocation, useParams } from 'react-router-dom'
11+
import { InsideCourseSidebar } from './InsideCourseSidebar'
12+
import { InsideGeneralSidebar } from './InsideGeneralSidebar'
13+
14+
export const InsideSidebar = (): JSX.Element => {
15+
const { courses } = useCourseStore()
16+
const { courseId } = useParams<{ courseId: string }>()
17+
const currentCourse = courses.find((course) => course.id === courseId)
18+
19+
// set the correct header
20+
const location = useLocation()
21+
const isCourseSidebar = location.pathname.startsWith('/management/course')
22+
const headerName = isCourseSidebar ? currentCourse?.name || 'Unknown Course' : 'General'
23+
24+
return (
25+
<Sidebar collapsible='none' className='flex-1 flex'>
26+
<SidebarHeader className='gap-3.5 border-b p-4'>
27+
<div className='flex w-full items-center justify-between'>
28+
<div className='text-base font-medium text-foreground'>{headerName}</div>
29+
<Label className='flex items-center gap-2 text-sm'></Label>
30+
</div>
31+
</SidebarHeader>
32+
<SidebarContent>
33+
<SidebarGroup className='px-2 py-4'>
34+
<SidebarGroupContent>
35+
{isCourseSidebar ? <InsideCourseSidebar /> : <InsideGeneralSidebar />}
36+
</SidebarGroupContent>
37+
</SidebarGroup>
38+
</SidebarContent>
39+
</Sidebar>
40+
)
41+
}

clients/core/src/Sidebar/InsideSidebar/components/SidebarHeader.tsx

Whitespace-only changes.

clients/core/src/Sidebar/InsideSidebar/components/SidebarItemCollapsable.tsx

Whitespace-only changes.

clients/core/src/management/ManagementConsole.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ export const ManagementRoot = ({ children }: { children?: React.ReactNode }): JS
6666
return <UnauthorizedPage />
6767
}
6868

69+
// TODO: when calling /management -> check for course in local storage, else redirect to /management/general
70+
6971
// TODO do course id management here
7072
// store latest selected course in local storage
7173
// check authorization

0 commit comments

Comments
 (0)