Dashboard palette: switch dashboard, publish, settings; ⌘S publishes
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user