Browse Source

feat(ui): add DropdownMenuItem for navigating to the last valid branch and adjust DropdownMenuContent width

Code_Uwe 1 week ago
parent
commit
956d088bc4
1 changed files with 30 additions and 3 deletions
  1. 30 3
      components/app-shell/QuickNav.jsx

+ 30 - 3
components/app-shell/QuickNav.jsx

@@ -3,7 +3,12 @@
 import React from "react";
 import React from "react";
 import Link from "next/link";
 import Link from "next/link";
 import { usePathname, useRouter } from "next/navigation";
 import { usePathname, useRouter } from "next/navigation";
-import { FolderOpen, Search as SearchIcon, TriangleAlert } from "lucide-react";
+import {
+	FolderOpen,
+	Search as SearchIcon,
+	TriangleAlert,
+	CornerDownLeft,
+} from "lucide-react";
 
 
 import { useAuth } from "@/components/auth/authContext";
 import { useAuth } from "@/components/auth/authContext";
 import { getBranches } from "@/lib/frontend/apiClient";
 import { getBranches } from "@/lib/frontend/apiClient";
@@ -24,6 +29,7 @@ import { Button } from "@/components/ui/button";
 import {
 import {
 	DropdownMenu,
 	DropdownMenu,
 	DropdownMenuContent,
 	DropdownMenuContent,
+	DropdownMenuItem,
 	DropdownMenuLabel,
 	DropdownMenuLabel,
 	DropdownMenuRadioGroup,
 	DropdownMenuRadioGroup,
 	DropdownMenuRadioItem,
 	DropdownMenuRadioItem,
@@ -42,7 +48,7 @@ const BRANCH_LIST_STATE = Object.freeze({
 
 
 // Header polish:
 // Header polish:
 // - outline buttons normally have a subtle shadow; remove it for crisp header UI
 // - outline buttons normally have a subtle shadow; remove it for crisp header UI
-// - normalize padding when an icon is present (avoid "uneven" look)
+// - normalize padding when an icon is present
 const TOPNAV_BUTTON_CLASS = "shadow-none has-[>svg]:px-3";
 const TOPNAV_BUTTON_CLASS = "shadow-none has-[>svg]:px-3";
 
 
 // Active nav style (blue like multi-branch selection)
 // Active nav style (blue like multi-branch selection)
@@ -225,7 +231,7 @@ export default function QuickNav() {
 						</Button>
 						</Button>
 					</DropdownMenuTrigger>
 					</DropdownMenuTrigger>
 
 
-					<DropdownMenuContent align="end" className="min-w-56">
+					<DropdownMenuContent align="end" className="min-w-64">
 						<DropdownMenuLabel>Niederlassung</DropdownMenuLabel>
 						<DropdownMenuLabel>Niederlassung</DropdownMenuLabel>
 						<DropdownMenuSeparator />
 						<DropdownMenuSeparator />
 
 
@@ -235,6 +241,27 @@ export default function QuickNav() {
 									Die URL-Niederlassung <strong>{routeBranch}</strong> existiert
 									Die URL-Niederlassung <strong>{routeBranch}</strong> existiert
 									nicht. Bitte wählen Sie eine gültige Niederlassung aus.
 									nicht. Bitte wählen Sie eine gültige Niederlassung aus.
 								</div>
 								</div>
+
+								<DropdownMenuItem
+									disabled={!canNavigate}
+									onSelect={(e) => {
+										e.preventDefault();
+										if (!canNavigate) return;
+										navigateToBranchKeepingContext(effectiveBranch);
+									}}
+									title={
+										canNavigate
+											? `Zur letzten gültigen Niederlassung wechseln (${effectiveBranch})`
+											: "Keine gültige Niederlassung verfügbar"
+									}
+								>
+									<CornerDownLeft className="h-4 w-4" aria-hidden="true" />
+									Zur letzten gültigen Niederlassung
+									<span className="ml-auto text-xs text-muted-foreground">
+										{canNavigate ? effectiveBranch : ""}
+									</span>
+								</DropdownMenuItem>
+
 								<DropdownMenuSeparator />
 								<DropdownMenuSeparator />
 							</>
 							</>
 						) : null}
 						) : null}