Add hover-reveal edit button to widget cards + auto-open edit mode

Each widget card now shows a settings icon in the top-right corner on
hover (desktop) or always-visible (mobile via mobile-touch-target).
Clicking it opens the WidgetConfigDialog directly in edit mode for that
widget (via a new editWidgetId prop on WidgetConfigDialog that
auto-enters the draft-edit path via useEffect).

Wired across all three widget surfaces:
- Dashboard (both mobile section + desktop grid)
- Service OverviewTab
- NamedDashboardPage

128 tests pass; build/lint green.
This commit is contained in:
Developer
2026-07-06 12:53:14 +00:00
parent 691d78ff06
commit eeb0cccbce
5 changed files with 74 additions and 21 deletions
+16 -1
View File
@@ -1,4 +1,4 @@
import { useMemo, useState } from "react";
import { useEffect, useMemo, useState } from "react";
import {
Dialog,
DialogContent,
@@ -56,6 +56,8 @@ interface Props {
serviceId?: string;
/** When set, enable widget references ("Add existing") for this dashboard scope. */
dashboardScope?: string;
/** When set, auto-open in edit mode for this widget id (instead of the list view). */
editWidgetId?: string;
}
interface Draft {
@@ -203,6 +205,7 @@ export function WidgetConfigDialog({
onClose,
serviceId,
dashboardScope,
editWidgetId,
}: Props) {
const { data: instances = [] } = useWidgetInstances(serviceId);
const { data: services = [] } = useServiceInstances();
@@ -220,6 +223,18 @@ export function WidgetConfigDialog({
const [draft, setDraft] = useState<Draft | null>(null);
// When editWidgetId is set and the dialog opens, auto-enter edit mode for
// that widget (instead of showing the list view).
useEffect(() => {
if (open && editWidgetId && instances.length > 0) {
const target = instances.find((w) => w.id === editWidgetId);
if (target) {
startEdit(target);
}
}
}, [open, editWidgetId, instances]);
function startAddBuiltIn(kind: string) {
const binding = BUILTIN_WIDGETS[kind];
setDraft({