Add a global search, and stop the sidebar logo squeezing
`GET /api/v1/search/` hands the client one flat index of everything worth jumping to — flows and the nodes inside them, dashboards and the widgets on them, panels, secrets, modules, workers and alert channels — and cmdk matches it in the browser, so results narrow while typing without a round trip per keystroke. A node hit is the one thing no list endpoint could answer: it opens its flow with that node in focus. The panel is reached from **Search** above Documentation in the sidebar, or ⌘K anywhere. The flow canvas palette moves to ⌘P, being the narrower of the two. The panels dialog gains an address (`/dashboards?panels`) so a panel hit has somewhere to land, and the sidebar logo gets `shrink-0`: the rail's width animates while the logo is already back, and a flex item short of room is squeezed rather than clipped.
This commit is contained in:
@@ -8,12 +8,15 @@ import {
|
||||
LayoutDashboard,
|
||||
LogOut,
|
||||
Package,
|
||||
Search,
|
||||
Server,
|
||||
Settings,
|
||||
Users,
|
||||
Workflow,
|
||||
} from "lucide-react"
|
||||
import { useState } from "react"
|
||||
|
||||
import { GlobalSearch } from "@/components/Common/GlobalSearch"
|
||||
import { Logo } from "@/components/Common/Logo"
|
||||
import {
|
||||
Sidebar,
|
||||
@@ -24,6 +27,7 @@ import {
|
||||
} from "@/components/ui/sidebar"
|
||||
import useAuth from "@/hooks/useAuth"
|
||||
import { portalConfig } from "@/lib/portal"
|
||||
import { useShortcuts } from "@/lib/shortcuts"
|
||||
import { type Item, Main } from "./Main"
|
||||
|
||||
/**
|
||||
@@ -55,6 +59,12 @@ const baseItems: Item[] = [
|
||||
export function AppSidebar() {
|
||||
const { user: currentUser, logout } = useAuth()
|
||||
const portal = portalConfig()
|
||||
const [searchOpen, setSearchOpen] = useState(false)
|
||||
|
||||
// Mounted by both shells, so this one binding covers every screen. Listed as
|
||||
// firing inside text entry too, because reaching anything at all should not
|
||||
// depend on where the caret happens to be.
|
||||
useShortcuts({ "mod+k": () => setSearchOpen((open) => !open) }, ["mod+k"])
|
||||
|
||||
const withAdmin = currentUser?.is_superuser
|
||||
? [...baseItems, { icon: Users, title: "Admin", path: "/admin" }]
|
||||
@@ -81,41 +91,56 @@ export function AppSidebar() {
|
||||
onClick: () => window.open(DOCS_URL, "_blank", "noopener"),
|
||||
}
|
||||
|
||||
const search: Item = {
|
||||
icon: Search,
|
||||
title: "Search",
|
||||
onClick: () => setSearchOpen(true),
|
||||
}
|
||||
|
||||
const footerItems: Item[] = portal
|
||||
? [docs, { icon: Settings, title: "Settings", path: "/settings" }]
|
||||
? [search, docs, { icon: Settings, title: "Settings", path: "/settings" }]
|
||||
: [
|
||||
search,
|
||||
docs,
|
||||
{ icon: Settings, title: "Settings", path: "/settings" },
|
||||
{ icon: LogOut, title: "Log Out", onClick: logout },
|
||||
]
|
||||
|
||||
return (
|
||||
// Floating frosted chrome over whatever surface the shell paints; see the
|
||||
// root DESIGN-GUIDELINES.md → Shells and → Overlay surfaces & content chips.
|
||||
<Sidebar
|
||||
collapsible="icon"
|
||||
variant="floating"
|
||||
className="[&>[data-sidebar=sidebar]]:bg-card/80 [&>[data-sidebar=sidebar]]:backdrop-blur-md [&>[data-sidebar=sidebar]]:shadow-e2"
|
||||
>
|
||||
<SidebarHeader className="px-4 py-6 group-data-[collapsible=icon]:px-0 group-data-[collapsible=icon]:items-center">
|
||||
<div className="flex w-full items-center justify-between gap-2 group-data-[collapsible=icon]:justify-center">
|
||||
{/* Collapsed, the rail has room for one thing, and that is the way
|
||||
back out. */}
|
||||
<span className="group-data-[collapsible=icon]:hidden">
|
||||
<Logo variant="responsive" />
|
||||
</span>
|
||||
{/* On a phone the sidebar is a sheet with its own way in and out. */}
|
||||
<SidebarTrigger className="hidden shrink-0 text-muted-foreground md:inline-flex" />
|
||||
</div>
|
||||
</SidebarHeader>
|
||||
<SidebarContent>
|
||||
<Main items={items} />
|
||||
</SidebarContent>
|
||||
{/* Main already pads horizontally; the footer only adds the bottom gap. */}
|
||||
<SidebarFooter className="px-0">
|
||||
<Main items={footerItems} />
|
||||
</SidebarFooter>
|
||||
</Sidebar>
|
||||
<>
|
||||
{/* Floating frosted chrome over whatever surface the shell paints; see the
|
||||
root DESIGN-GUIDELINES.md → Shells and → Overlay surfaces & content
|
||||
chips. */}
|
||||
<Sidebar
|
||||
collapsible="icon"
|
||||
variant="floating"
|
||||
className="[&>[data-sidebar=sidebar]]:bg-card/80 [&>[data-sidebar=sidebar]]:backdrop-blur-md [&>[data-sidebar=sidebar]]:shadow-e2"
|
||||
>
|
||||
<SidebarHeader className="px-4 py-6 group-data-[collapsible=icon]:px-0 group-data-[collapsible=icon]:items-center">
|
||||
<div className="flex w-full items-center justify-between gap-2 group-data-[collapsible=icon]:justify-center">
|
||||
{/* Collapsed, the rail has room for one thing, and that is the way
|
||||
back out. `shrink-0` because the rail's width animates while the
|
||||
logo is already back: a flex item short of room is squeezed, and
|
||||
a wordmark would rather be clipped than squashed. */}
|
||||
<span className="shrink-0 group-data-[collapsible=icon]:hidden">
|
||||
<Logo variant="responsive" />
|
||||
</span>
|
||||
{/* On a phone the sidebar is a sheet with its own way in and out. */}
|
||||
<SidebarTrigger className="hidden shrink-0 text-muted-foreground md:inline-flex" />
|
||||
</div>
|
||||
</SidebarHeader>
|
||||
<SidebarContent>
|
||||
<Main items={items} />
|
||||
</SidebarContent>
|
||||
{/* Main already pads horizontally; the footer only adds the bottom gap. */}
|
||||
<SidebarFooter className="px-0">
|
||||
<Main items={footerItems} />
|
||||
</SidebarFooter>
|
||||
</Sidebar>
|
||||
{/* Outside the sidebar: on a phone that is a sheet, and a dialog is not
|
||||
one of its children. */}
|
||||
<GlobalSearch open={searchOpen} onOpenChange={setSearchOpen} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user