mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-16 17:05:04 +02:00
add api keys to sidebar nav
This commit is contained in:
parent
566e66daa4
commit
a6d6aaaadd
3 changed files with 38 additions and 11 deletions
|
@ -6,7 +6,8 @@ import {
|
||||||
Link as LinkIcon,
|
Link as LinkIcon,
|
||||||
Waypoints,
|
Waypoints,
|
||||||
Combine,
|
Combine,
|
||||||
Fingerprint
|
Fingerprint,
|
||||||
|
KeyRound
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
|
|
||||||
export const orgLangingNavItems: SidebarNavItem[] = [
|
export const orgLangingNavItems: SidebarNavItem[] = [
|
||||||
|
@ -63,6 +64,12 @@ export const orgNavItems: SidebarNavItem[] = [
|
||||||
href: "/{orgId}/settings/share-links",
|
href: "/{orgId}/settings/share-links",
|
||||||
icon: <LinkIcon className="h-4 w-4" />
|
icon: <LinkIcon className="h-4 w-4" />
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "API Keys",
|
||||||
|
href: "/{orgId}/settings/api-keys",
|
||||||
|
icon: <KeyRound className="h-4 w-4" />,
|
||||||
|
showEnterprise: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "Settings",
|
title: "Settings",
|
||||||
href: "/{orgId}/settings/general",
|
href: "/{orgId}/settings/general",
|
||||||
|
@ -76,6 +83,12 @@ export const adminNavItems: SidebarNavItem[] = [
|
||||||
href: "/admin/users",
|
href: "/admin/users",
|
||||||
icon: <Users className="h-4 w-4" />
|
icon: <Users className="h-4 w-4" />
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: "API Keys",
|
||||||
|
href: "/{orgId}/settings/api-keys",
|
||||||
|
icon: <KeyRound className="h-4 w-4" />,
|
||||||
|
showEnterprise: true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: "Identity Providers",
|
title: "Identity Providers",
|
||||||
href: "/admin/idp",
|
href: "/admin/idp",
|
||||||
|
|
|
@ -61,6 +61,9 @@ export default function StepperForm() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const checkOrgIdAvailability = useCallback(async (value: string) => {
|
const checkOrgIdAvailability = useCallback(async (value: string) => {
|
||||||
|
if (loading) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const res = await api.get(`/org/checkId`, {
|
const res = await api.get(`/org/checkId`, {
|
||||||
params: {
|
params: {
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { useParams, usePathname } from "next/navigation";
|
||||||
import { cn } from "@app/lib/cn";
|
import { cn } from "@app/lib/cn";
|
||||||
import { ChevronDown, ChevronRight } from "lucide-react";
|
import { ChevronDown, ChevronRight } from "lucide-react";
|
||||||
import { useUserContext } from "@app/hooks/useUserContext";
|
import { useUserContext } from "@app/hooks/useUserContext";
|
||||||
|
import { Badge } from "@app/components/ui/badge";
|
||||||
|
|
||||||
export interface SidebarNavItem {
|
export interface SidebarNavItem {
|
||||||
href: string;
|
href: string;
|
||||||
|
@ -13,6 +14,7 @@ export interface SidebarNavItem {
|
||||||
icon?: React.ReactNode;
|
icon?: React.ReactNode;
|
||||||
children?: SidebarNavItem[];
|
children?: SidebarNavItem[];
|
||||||
autoExpand?: boolean;
|
autoExpand?: boolean;
|
||||||
|
showEnterprise?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SidebarNavProps extends React.HTMLAttributes<HTMLElement> {
|
export interface SidebarNavProps extends React.HTMLAttributes<HTMLElement> {
|
||||||
|
@ -95,7 +97,9 @@ export function SidebarNav({
|
||||||
const isActive = pathname.startsWith(hydratedHref);
|
const isActive = pathname.startsWith(hydratedHref);
|
||||||
const hasChildren = item.children && item.children.length > 0;
|
const hasChildren = item.children && item.children.length > 0;
|
||||||
const isExpanded = expandedItems.has(hydratedHref);
|
const isExpanded = expandedItems.has(hydratedHref);
|
||||||
const indent = level * 16; // Base indent for each level
|
const indent = level * 28; // Base indent for each level
|
||||||
|
const isEnterprise = item.showEnterprise;
|
||||||
|
const isDisabled = disabled || isEnterprise;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={hydratedHref}>
|
<div key={hydratedHref}>
|
||||||
|
@ -110,34 +114,41 @@ export function SidebarNav({
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Link
|
<Link
|
||||||
href={hydratedHref}
|
href={isEnterprise ? "#" : hydratedHref}
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex items-center w-full px-3 py-2",
|
"flex items-center w-full px-3 py-2",
|
||||||
isActive
|
isActive
|
||||||
? "text-primary font-medium"
|
? "text-primary font-medium"
|
||||||
: "text-muted-foreground group-hover:text-foreground",
|
: "text-muted-foreground group-hover:text-foreground",
|
||||||
disabled && "cursor-not-allowed opacity-60"
|
isDisabled && "cursor-not-allowed"
|
||||||
)}
|
)}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
if (disabled) {
|
if (isDisabled) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
} else if (onItemClick) {
|
} else if (onItemClick) {
|
||||||
onItemClick();
|
onItemClick();
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
tabIndex={disabled ? -1 : undefined}
|
tabIndex={isDisabled ? -1 : undefined}
|
||||||
aria-disabled={disabled}
|
aria-disabled={isDisabled}
|
||||||
>
|
>
|
||||||
{item.icon && (
|
<div className={cn("flex items-center", isDisabled && "opacity-60")}>
|
||||||
<span className="mr-3">{item.icon}</span>
|
{item.icon && (
|
||||||
|
<span className="mr-3">{item.icon}</span>
|
||||||
|
)}
|
||||||
|
{item.title}
|
||||||
|
</div>
|
||||||
|
{isEnterprise && (
|
||||||
|
<Badge className="ml-2">
|
||||||
|
Enterprise
|
||||||
|
</Badge>
|
||||||
)}
|
)}
|
||||||
{item.title}
|
|
||||||
</Link>
|
</Link>
|
||||||
{hasChildren && (
|
{hasChildren && (
|
||||||
<button
|
<button
|
||||||
onClick={() => toggleItem(hydratedHref)}
|
onClick={() => toggleItem(hydratedHref)}
|
||||||
className="p-2 rounded-md text-muted-foreground hover:text-foreground cursor-pointer"
|
className="p-2 rounded-md text-muted-foreground hover:text-foreground cursor-pointer"
|
||||||
disabled={disabled}
|
disabled={isDisabled}
|
||||||
>
|
>
|
||||||
{isExpanded ? (
|
{isExpanded ? (
|
||||||
<ChevronDown className="h-5 w-5" />
|
<ChevronDown className="h-5 w-5" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue