Dashboard palette: switch dashboard, publish, settings; ⌘S publishes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-12 22:05:39 +02:00
co-authored by Claude Opus 5.5
parent 72b4cf3556
commit 0ef7d027b8
3 changed files with 156 additions and 85 deletions
@@ -39,6 +39,7 @@ import { appPath } from "@/lib/portal"
import { useShortcuts } from "@/lib/shortcuts"
import { cn } from "@/lib/utils"
import { handleError } from "@/utils"
import { DashboardPalette } from "./DashboardPalette"
import {
areaOf,
CanvasSurface,
@@ -66,7 +67,6 @@ import { PaletteProvider } from "./settings"
import { useUi } from "./ui"
import { showTitle } from "./ui/core/config"
import { LookProvider, useCanvasRoot } from "./ui/core/look"
import { WidgetPalette } from "./WidgetPalette"
import {
WIDGET_LABELS,
WIDGET_SIZES,
@@ -335,11 +335,25 @@ export function DashboardEditor({
setSelected(id)
}
// ⌘P, as on the flow canvas. Reachable while typing, so a settings field
// having focus does not hide it.
const openSettings = () => {
setSelected(null)
setSettingsOpen(true)
}
// As on the flow canvas, and reachable while typing for the same reasons.
// Outside edit mode both keys stay the browser's.
useShortcuts(
{ "mod+p": () => (edit ? setPaletteOpen((open) => !open) : false) },
["mod+p"],
{
"mod+p": () => (edit ? setPaletteOpen((open) => !open) : false),
// An edit still waiting for its autosave counts: publishing flushes it.
"mod+s": () => {
if (!edit) return false
if (!publish.isPending && (hasDraft || timer.current)) {
void publishDashboard()
}
},
},
["mod+p", "mod+s"],
)
const patch = (id: string, changes: Partial<WidgetDef>) =>
@@ -639,14 +653,9 @@ export function DashboardEditor({
"text-muted-foreground",
settingsOpen && "text-primary",
)}
onClick={() => {
if (settingsOpen) {
setSettingsOpen(false)
return
}
setSelected(null)
setSettingsOpen(true)
}}
onClick={() =>
settingsOpen ? setSettingsOpen(false) : openSettings()
}
aria-pressed={settingsOpen}
aria-label="Dashboard settings"
data-testid="edit-dashboard"
@@ -718,10 +727,12 @@ export function DashboardEditor({
{edit ? (
<>
<WidgetPalette
<DashboardPalette
open={paletteOpen}
onOpenChange={setPaletteOpen}
onAdd={addWidget}
onSettings={openSettings}
onPublish={hasDraft ? () => void publishDashboard() : undefined}
/>
<WidgetPanel