-
Notifications
You must be signed in to change notification settings - Fork 898
feat(admin): add admin dashboard with auth spoofed #335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
9752d73
feat(admin): add admin dashboard with auth
saddlepaddle 378ed99
fix(desktop, docs): resolve build issues
saddlepaddle c0003fa
chore: move favicon.ico from public to app router
saddlepaddle ef40ab5
chore: gitignore next-env.d.ts
saddlepaddle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
177 changes: 177 additions & 0 deletions
177
apps/admin/src/app/(dashboard)/components/AppSidebar/AppSidebar.tsx
This file contains hidden or 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,177 @@ | ||
| "use client"; | ||
|
|
||
| import { | ||
| Collapsible, | ||
| CollapsibleContent, | ||
| CollapsibleTrigger, | ||
| } from "@superset/ui/collapsible"; | ||
| import { | ||
| Sidebar, | ||
| SidebarContent, | ||
| SidebarFooter, | ||
| SidebarGroup, | ||
| SidebarGroupContent, | ||
| SidebarGroupLabel, | ||
| SidebarHeader, | ||
| SidebarMenu, | ||
| SidebarMenuButton, | ||
| SidebarMenuItem, | ||
| SidebarRail, | ||
| } from "@superset/ui/sidebar"; | ||
| import { | ||
| BarChart3, | ||
| Bot, | ||
| ChevronRight, | ||
| Database, | ||
| Home, | ||
| Settings, | ||
| Shield, | ||
| Users, | ||
| Webhook, | ||
| } from "lucide-react"; | ||
|
|
||
| import type { User } from "@/lib/auth/types"; | ||
| import { AppSidebarHeader } from "./components/AppSidebarHeader"; | ||
| import { NavUser } from "./components/NavUser"; | ||
| import { SearchForm } from "./components/SearchForm"; | ||
|
|
||
| const navigation = [ | ||
| { | ||
| title: "Overview", | ||
| items: [ | ||
| { | ||
| title: "Dashboard", | ||
| url: "/", | ||
| icon: Home, | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| title: "User Management", | ||
| items: [ | ||
| { | ||
| title: "All Users", | ||
| url: "/users", | ||
| icon: Users, | ||
| }, | ||
| { | ||
| title: "Deleted Users", | ||
| url: "/users/deleted", | ||
| }, | ||
| { | ||
| title: "Permissions", | ||
| url: "/users/permissions", | ||
| icon: Shield, | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| title: "Analytics", | ||
| items: [ | ||
| { | ||
| title: "Overview", | ||
| url: "/analytics", | ||
| icon: BarChart3, | ||
| }, | ||
| { | ||
| title: "User Activity", | ||
| url: "/analytics/activity", | ||
| }, | ||
| { | ||
| title: "Performance", | ||
| url: "/analytics/performance", | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| title: "AI Lab", | ||
| items: [ | ||
| { | ||
| title: "Plan Testing", | ||
| url: "/ai-lab", | ||
| icon: Bot, | ||
| }, | ||
| { | ||
| title: "Model Config", | ||
| url: "/ai-lab/models", | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| title: "System", | ||
| items: [ | ||
| { | ||
| title: "Database", | ||
| url: "/system/database", | ||
| icon: Database, | ||
| }, | ||
| { | ||
| title: "Webhooks", | ||
| url: "/system/webhooks", | ||
| icon: Webhook, | ||
| }, | ||
| { | ||
| title: "Settings", | ||
| url: "/settings", | ||
| icon: Settings, | ||
| }, | ||
| ], | ||
| }, | ||
| ]; | ||
|
|
||
| export interface AppSidebarProps extends React.ComponentProps<typeof Sidebar> { | ||
| user: User; | ||
| } | ||
|
|
||
| export function AppSidebar({ user, ...props }: AppSidebarProps) { | ||
| return ( | ||
| <Sidebar {...props}> | ||
| <SidebarHeader> | ||
| <AppSidebarHeader /> | ||
| <SearchForm /> | ||
| </SidebarHeader> | ||
| <SidebarContent className="gap-0"> | ||
| {navigation.map((section) => ( | ||
| <Collapsible | ||
| key={section.title} | ||
| title={section.title} | ||
| defaultOpen | ||
| className="group/collapsible" | ||
| > | ||
| <SidebarGroup> | ||
| <SidebarGroupLabel | ||
| asChild | ||
| className="group/label text-sidebar-foreground hover:bg-sidebar-accent hover:text-sidebar-accent-foreground text-sm" | ||
| > | ||
| <CollapsibleTrigger> | ||
| {section.title} | ||
| <ChevronRight className="ml-auto transition-transform group-data-[state=open]/collapsible:rotate-90" /> | ||
| </CollapsibleTrigger> | ||
| </SidebarGroupLabel> | ||
| <CollapsibleContent> | ||
| <SidebarGroupContent> | ||
| <SidebarMenu> | ||
| {section.items.map((item) => ( | ||
| <SidebarMenuItem key={item.title}> | ||
| <SidebarMenuButton asChild> | ||
| <a href={item.url}> | ||
| {item.icon && <item.icon className="size-4" />} | ||
| {item.title} | ||
| </a> | ||
| </SidebarMenuButton> | ||
| </SidebarMenuItem> | ||
| ))} | ||
| </SidebarMenu> | ||
| </SidebarGroupContent> | ||
| </CollapsibleContent> | ||
| </SidebarGroup> | ||
| </Collapsible> | ||
| ))} | ||
| </SidebarContent> | ||
| <SidebarFooter> | ||
| <NavUser user={user} /> | ||
| </SidebarFooter> | ||
| <SidebarRail /> | ||
| </Sidebar> | ||
| ); | ||
| } |
30 changes: 30 additions & 0 deletions
30
...rc/app/(dashboard)/components/AppSidebar/components/AppSidebarHeader/AppSidebarHeader.tsx
This file contains hidden or 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,30 @@ | ||
| import { | ||
| SidebarMenu, | ||
| SidebarMenuButton, | ||
| SidebarMenuItem, | ||
| } from "@superset/ui/sidebar"; | ||
| import Image from "next/image"; | ||
|
|
||
| export function AppSidebarHeader() { | ||
| return ( | ||
| <SidebarMenu> | ||
| <SidebarMenuItem> | ||
| <SidebarMenuButton size="lg" asChild> | ||
| <a href="/"> | ||
| <Image | ||
| src="/icon.png" | ||
| alt="Superset" | ||
| width={32} | ||
| height={32} | ||
| className="size-8 rounded-lg" | ||
| /> | ||
| <div className="flex flex-col gap-0.5 leading-none"> | ||
| <span className="font-medium">Superset</span> | ||
| <span className="">Admin Panel</span> | ||
| </div> | ||
| </a> | ||
| </SidebarMenuButton> | ||
| </SidebarMenuItem> | ||
| </SidebarMenu> | ||
| ); | ||
| } |
1 change: 1 addition & 0 deletions
1
apps/admin/src/app/(dashboard)/components/AppSidebar/components/AppSidebarHeader/index.ts
This file contains hidden or 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 @@ | ||
| export { AppSidebarHeader } from "./AppSidebarHeader"; |
109 changes: 109 additions & 0 deletions
109
apps/admin/src/app/(dashboard)/components/AppSidebar/components/NavUser/NavUser.tsx
This file contains hidden or 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,109 @@ | ||
| "use client"; | ||
|
|
||
| import { Avatar, AvatarFallback, AvatarImage } from "@superset/ui/avatar"; | ||
| import { | ||
| DropdownMenu, | ||
| DropdownMenuContent, | ||
| DropdownMenuGroup, | ||
| DropdownMenuItem, | ||
| DropdownMenuLabel, | ||
| DropdownMenuSeparator, | ||
| DropdownMenuTrigger, | ||
| } from "@superset/ui/dropdown-menu"; | ||
| import { | ||
| SidebarMenu, | ||
| SidebarMenuButton, | ||
| SidebarMenuItem, | ||
| useSidebar, | ||
| } from "@superset/ui/sidebar"; | ||
| import { | ||
| BadgeCheck, | ||
| Bell, | ||
| ChevronsUpDown, | ||
| LogOut, | ||
| Settings, | ||
| } from "lucide-react"; | ||
| import { useSignOut } from "@/lib/auth/client"; | ||
| import type { User } from "@/lib/auth/types"; | ||
|
|
||
| export interface NavUserProps { | ||
| user: User; | ||
| } | ||
|
|
||
| export function NavUser({ user }: NavUserProps) { | ||
| const { isMobile } = useSidebar(); | ||
| const { signOut } = useSignOut(); | ||
|
|
||
| const userInitials = user.name | ||
| .split(" ") | ||
| .map((name) => name[0]) | ||
| .join(""); | ||
|
|
||
| return ( | ||
| <SidebarMenu> | ||
| <SidebarMenuItem> | ||
| <DropdownMenu> | ||
| <DropdownMenuTrigger asChild> | ||
| <SidebarMenuButton | ||
| size="lg" | ||
| className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground" | ||
| > | ||
| <Avatar className="h-8 w-8 rounded-lg"> | ||
| <AvatarImage src={user.imageUrl} alt={user.name} /> | ||
| <AvatarFallback className="rounded-lg"> | ||
| {userInitials} | ||
| </AvatarFallback> | ||
| </Avatar> | ||
| <div className="grid flex-1 text-left text-sm leading-tight"> | ||
| <span className="truncate font-medium">{user.name}</span> | ||
| <span className="truncate text-xs">{user.email}</span> | ||
| </div> | ||
| <ChevronsUpDown className="ml-auto size-4" /> | ||
| </SidebarMenuButton> | ||
| </DropdownMenuTrigger> | ||
| <DropdownMenuContent | ||
| className="w-[--radix-dropdown-menu-trigger-width] min-w-56 rounded-lg" | ||
| side={isMobile ? "bottom" : "right"} | ||
| align="end" | ||
| sideOffset={4} | ||
| > | ||
| <DropdownMenuLabel className="p-0 font-normal"> | ||
| <div className="flex items-center gap-2 px-1 py-1.5 text-left text-sm"> | ||
| <Avatar className="h-8 w-8 rounded-lg"> | ||
| <AvatarImage src={user.imageUrl} alt={user.name} /> | ||
| <AvatarFallback className="rounded-lg"> | ||
| {userInitials} | ||
| </AvatarFallback> | ||
| </Avatar> | ||
| <div className="grid flex-1 text-left text-sm leading-tight"> | ||
| <span className="truncate font-medium">{user.name}</span> | ||
| <span className="truncate text-xs">{user.email}</span> | ||
| </div> | ||
| </div> | ||
| </DropdownMenuLabel> | ||
| <DropdownMenuSeparator /> | ||
| <DropdownMenuGroup> | ||
| <DropdownMenuItem> | ||
| <BadgeCheck /> | ||
| Account | ||
| </DropdownMenuItem> | ||
| <DropdownMenuItem> | ||
| <Settings /> | ||
| Settings | ||
| </DropdownMenuItem> | ||
| <DropdownMenuItem> | ||
| <Bell /> | ||
| Notifications | ||
| </DropdownMenuItem> | ||
| </DropdownMenuGroup> | ||
| <DropdownMenuSeparator /> | ||
| <DropdownMenuItem onClick={signOut}> | ||
| <LogOut /> | ||
| Log out | ||
| </DropdownMenuItem> | ||
| </DropdownMenuContent> | ||
| </DropdownMenu> | ||
| </SidebarMenuItem> | ||
| </SidebarMenu> | ||
| ); | ||
| } | ||
1 change: 1 addition & 0 deletions
1
apps/admin/src/app/(dashboard)/components/AppSidebar/components/NavUser/index.ts
This file contains hidden or 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 @@ | ||
| export { NavUser } from "./NavUser"; |
25 changes: 25 additions & 0 deletions
25
apps/admin/src/app/(dashboard)/components/AppSidebar/components/SearchForm/SearchForm.tsx
This file contains hidden or 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,25 @@ | ||
| "use client"; | ||
|
|
||
| import { Label } from "@superset/ui/label"; | ||
| import { | ||
| SidebarGroup, | ||
| SidebarGroupContent, | ||
| SidebarInput, | ||
| } from "@superset/ui/sidebar"; | ||
| import { Search } from "lucide-react"; | ||
|
|
||
| export function SearchForm({ ...props }: React.ComponentProps<"form">) { | ||
| return ( | ||
| <form {...props}> | ||
| <SidebarGroup className="py-0"> | ||
| <SidebarGroupContent className="relative"> | ||
| <Label htmlFor="search" className="sr-only"> | ||
| Search | ||
| </Label> | ||
| <SidebarInput id="search" placeholder="Search..." className="pl-8" /> | ||
| <Search className="pointer-events-none absolute top-1/2 left-2 size-4 -translate-y-1/2 opacity-50 select-none" /> | ||
| </SidebarGroupContent> | ||
| </SidebarGroup> | ||
| </form> | ||
| ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle edge cases in userInitials calculation.
The current implementation could throw if
user.namecontains empty strings after splitting (e.g., "John Doe" with double space) or if name is empty.Apply this diff to add defensive handling:
This ensures:
📝 Committable suggestion
🤖 Prompt for AI Agents