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:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user