@orsetra/shared-ui 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,6 @@ import { useState, useEffect } from "react"
4
4
  import { usePathname } from "next/navigation"
5
5
  import { MainSidebar, Sidebar, SidebarProvider, useSidebar } from "./index"
6
6
  import { UserMenu } from "../ui"
7
- import { useZitadel } from "../../auth"
8
7
  import { getMenuFromPath } from "../../lib/menu-utils"
9
8
 
10
9
  export interface SidebarMenus {
@@ -14,10 +13,11 @@ export interface SidebarMenus {
14
13
  interface LayoutContainerProps {
15
14
  children: React.ReactNode
16
15
  sidebarMenus: SidebarMenus
16
+ user?: { profile?: { email?: string; preferred_username?: string } } | null
17
+ onSignOut?: () => void
17
18
  }
18
19
 
19
- function LayoutContent({ children, sidebarMenus }: LayoutContainerProps) {
20
- const { user, signOut } = useZitadel()
20
+ function LayoutContent({ children, sidebarMenus, user, onSignOut }: LayoutContainerProps) {
21
21
  const pathname = usePathname()
22
22
  const { setOpen } = useSidebar()
23
23
  const [isMainSidebarOpen, setIsMainSidebarOpen] = useState(false)
@@ -63,7 +63,7 @@ function LayoutContent({ children, sidebarMenus }: LayoutContainerProps) {
63
63
  <div className="h-full px-6 flex items-center justify-end">
64
64
  <UserMenu
65
65
  username={user?.profile?.email || user?.profile?.preferred_username}
66
- onSignOut={signOut}
66
+ onSignOut={onSignOut || (() => {})}
67
67
  />
68
68
  </div>
69
69
  </header>
package/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  // Utilities
2
2
  export * from './lib/utils'
3
+ export * from './lib/menu-utils'
3
4
 
4
5
  // UI Components
5
6
  export * from './components/ui'
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Menu utilities
3
+ * Helper functions for menu navigation and route detection
4
+ */
5
+
6
+ /**
7
+ * Determine the contextual menu based on the current route
8
+ * @param pathname - Current pathname from usePathname()
9
+ * @returns Menu ID string
10
+ */
11
+ export function getMenuFromPath(pathname: string): string {
12
+ if (pathname === "/") {
13
+ return "welcome"
14
+ }
15
+
16
+ // Routes pour Assets/Launchpads
17
+ if (pathname.startsWith("/assets") || pathname.startsWith("/projects")) {
18
+ return "assets"
19
+ }
20
+
21
+ // Routes pour Editor
22
+ if (pathname.startsWith("/editor")) {
23
+ return "assets"
24
+ }
25
+
26
+ // Routes pour Applications
27
+ if (pathname.startsWith("/applications") ||
28
+ pathname.startsWith("/vpcs") ||
29
+ pathname.startsWith("/environments") ||
30
+ pathname.startsWith("/secrets") ||
31
+ pathname.startsWith("/wizard")) {
32
+ return "applications"
33
+ }
34
+
35
+ // Routes pour API Manager
36
+ if (pathname.startsWith("/api-manager")) {
37
+ return "api-manager"
38
+ }
39
+
40
+ // Routes pour Access Manager
41
+ if (pathname.startsWith("/access-manager")) {
42
+ return "access-manager"
43
+ }
44
+
45
+ // Par défaut, Vue d'ensemble
46
+ return "overview"
47
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orsetra/shared-ui",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Shared UI components for Orsetra platform",
5
5
  "main": "./index.ts",
6
6
  "types": "./index.ts",
@@ -40,6 +40,7 @@
40
40
  "next": "^14.0.0 || ^15.0.0"
41
41
  },
42
42
  "dependencies": {
43
+ "react-avatar": "^5.0.3",
43
44
  "clsx": "^2.1.1",
44
45
  "tailwind-merge": "^2.5.5",
45
46
  "class-variance-authority": "^0.7.1",
@@ -83,6 +84,7 @@
83
84
  },
84
85
  "devDependencies": {
85
86
  "@types/react": "^19",
87
+ "next": "^15.0.0",
86
88
  "typescript": "^5"
87
89
  }
88
90
  }