Open in dashboard: searchable Command list
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,14 @@ import {
|
|||||||
dashboardsQueryOptions,
|
dashboardsQueryOptions,
|
||||||
} from "@/components/Dashboard/queries"
|
} from "@/components/Dashboard/queries"
|
||||||
import { Button } from "@/components/ui/button"
|
import { Button } from "@/components/ui/button"
|
||||||
|
import {
|
||||||
|
Command,
|
||||||
|
CommandEmpty,
|
||||||
|
CommandGroup,
|
||||||
|
CommandInput,
|
||||||
|
CommandItem,
|
||||||
|
CommandList,
|
||||||
|
} from "@/components/ui/command"
|
||||||
import {
|
import {
|
||||||
Popover,
|
Popover,
|
||||||
PopoverContent,
|
PopoverContent,
|
||||||
@@ -78,39 +86,46 @@ export function OpenInDashboard({
|
|||||||
Open in dashboard
|
Open in dashboard
|
||||||
</Button>
|
</Button>
|
||||||
</PopoverTrigger>
|
</PopoverTrigger>
|
||||||
<PopoverContent align="end" className="w-64 p-1">
|
<PopoverContent align="end" className="w-64 p-0">
|
||||||
{flow && !hasResults && (
|
<Command>
|
||||||
<button
|
<CommandInput placeholder="Search dashboards" />
|
||||||
type="button"
|
<CommandList>
|
||||||
onClick={() => generate.mutate(flow)}
|
<CommandEmpty>
|
||||||
disabled={generate.isPending}
|
{dashboards.length
|
||||||
className="w-full rounded-md px-2 py-1.5 text-left text-sm hover:bg-accent disabled:opacity-50"
|
? "No dashboard by that name."
|
||||||
>
|
: "No dashboards yet."}
|
||||||
{generate.isPending
|
</CommandEmpty>
|
||||||
? "Building…"
|
{flow && !hasResults ? (
|
||||||
: `Build a results dashboard for ${flow}`}
|
<CommandGroup>
|
||||||
</button>
|
<CommandItem
|
||||||
)}
|
value={`build results ${flow}`}
|
||||||
{dashboards.map((one) => (
|
onSelect={() => generate.mutate(flow)}
|
||||||
<button
|
disabled={generate.isPending}
|
||||||
key={one.name}
|
>
|
||||||
type="button"
|
{generate.isPending
|
||||||
onClick={() => show(one.name)}
|
? "Building…"
|
||||||
className="w-full rounded-md px-2 py-1.5 text-left text-sm hover:bg-accent"
|
: `Build a results dashboard for ${flow}`}
|
||||||
>
|
</CommandItem>
|
||||||
{one.title || one.name}
|
</CommandGroup>
|
||||||
{one.name === results && (
|
) : null}
|
||||||
<span className="ml-2 text-muted-foreground text-xs">
|
<CommandGroup>
|
||||||
results
|
{dashboards.map((one) => (
|
||||||
</span>
|
<CommandItem
|
||||||
)}
|
key={one.name}
|
||||||
</button>
|
value={`${one.name} ${one.title}`}
|
||||||
))}
|
onSelect={() => show(one.name)}
|
||||||
{dashboards.length === 0 && !flow && (
|
>
|
||||||
<p className="px-2 py-1.5 text-muted-foreground text-sm">
|
{one.title || one.name}
|
||||||
No dashboards yet.
|
{one.name === results ? (
|
||||||
</p>
|
<span className="ml-2 text-xs text-muted-foreground">
|
||||||
)}
|
results
|
||||||
|
</span>
|
||||||
|
) : null}
|
||||||
|
</CommandItem>
|
||||||
|
))}
|
||||||
|
</CommandGroup>
|
||||||
|
</CommandList>
|
||||||
|
</Command>
|
||||||
</PopoverContent>
|
</PopoverContent>
|
||||||
</Popover>
|
</Popover>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user