From fd9d265d2366551b306055d2f015905c23af40b4 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 15 Nov 2025 22:42:02 +0000 Subject: [PATCH] Fix UX issues and improve Docker monitoring user experience MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Critical fixes: 1. Monitor type detection on edit - When editing a Docker monitor, type is now correctly detected from monitor object - Previously defaulted to "hardware" causing incorrect form fields to show - Fix: Detect type from query params on create, from monitor.type on edit 2. Default interval for Docker monitors - Docker monitors now default to 30 seconds (0.5 minutes) on creation - Hardware monitors remain at 15 seconds (0.25 minutes) - Pass monitorType to initializeInfrastructureMonitorForCreate 3. Type-aware fallback links - Hardware tab empty state: links to /infrastructure/create?type=hardware - Docker tab empty state: links to /infrastructure/create?type=docker - Ensures correct form is shown when creating from empty state UX improvements: 4. Enhanced error messaging in Docker container table - Differentiate between "No containers" vs "Docker daemon unavailable" - Show error details when Capture API fails - Display critical errors (docker.client) with red background - Show partial error messages when some containers fail to inspect 5. Display Capture metadata - Show Capture version in container table header - Display error count when errors are present (⚠ N error(s) encountered) - Help users identify API issues vs legitimate empty states 6. Improved empty state handling - "Docker daemon unavailable" - when Docker socket unreachable on Capture server - "No containers found" - when Capture is working but no containers exist - "Partial data available" - when some containers failed to inspect - Show specific error messages from Capture API These changes improve the user experience when: - Editing existing Docker monitors (correct form fields shown) - Creating Docker monitors (proper default interval) - Troubleshooting Capture API issues (clear error messages) - Understanding container availability (version info, error details) --- .../hooks/useInfrastructureMonitorForm.jsx | 7 +- .../Pages/v1/Infrastructure/Create/index.jsx | 12 ++- .../DockerContainersTable/index.jsx | 73 ++++++++++++++++--- .../Pages/v1/Infrastructure/Details/index.jsx | 2 + .../v1/Infrastructure/Monitors/index.jsx | 4 +- 5 files changed, 81 insertions(+), 17 deletions(-) diff --git a/client/src/Pages/v1/Infrastructure/Create/hooks/useInfrastructureMonitorForm.jsx b/client/src/Pages/v1/Infrastructure/Create/hooks/useInfrastructureMonitorForm.jsx index f0a701517..ea92829c9 100644 --- a/client/src/Pages/v1/Infrastructure/Create/hooks/useInfrastructureMonitorForm.jsx +++ b/client/src/Pages/v1/Infrastructure/Create/hooks/useInfrastructureMonitorForm.jsx @@ -31,14 +31,17 @@ const useInfrastructureMonitorForm = () => { [event.target.name]: event.target.checked, }); }; - const initializeInfrastructureMonitorForCreate = useCallback((globalSettings) => { + const initializeInfrastructureMonitorForCreate = useCallback((globalSettings, monitorType = "hardware") => { const gt = globalSettings?.data?.settings?.globalThresholds || {}; + // Docker monitors default to 30 seconds (0.5 minutes), hardware to 15 seconds (0.25 minutes) + const defaultInterval = monitorType === "docker" ? 0.5 : 0.25; + setInfrastructureMonitor((prev) => ({ ...prev, url: "", name: "", notifications: [], - interval: 0.25, + interval: defaultInterval, cpu: gt.cpu !== undefined, usage_cpu: gt.cpu !== undefined ? gt.cpu.toString() : "", memory: gt.memory !== undefined, diff --git a/client/src/Pages/v1/Infrastructure/Create/index.jsx b/client/src/Pages/v1/Infrastructure/Create/index.jsx index 7eb85f758..0f817dc0d 100644 --- a/client/src/Pages/v1/Infrastructure/Create/index.jsx +++ b/client/src/Pages/v1/Infrastructure/Create/index.jsx @@ -35,9 +35,6 @@ const CreateInfrastructureMonitor = () => { const theme = useTheme(); const { t } = useTranslation(); - // Get monitor type from query params (default to hardware for backwards compatibility) - const monitorType = searchParams.get("type") || "hardware"; - // State const [https, setHttps] = useState(false); const [updateTrigger, setUpdateTrigger] = useState(false); @@ -47,6 +44,11 @@ const CreateInfrastructureMonitor = () => { monitorId, updateTrigger, }); + + // Determine monitor type: from query params when creating, from monitor object when editing + const monitorType = isCreate + ? (searchParams.get("type") || "hardware") + : (monitor?.type || "hardware"); const [deleteMonitor, isDeleting] = useDeleteMonitor(); const [globalSettings, globalSettingsLoading] = useFetchGlobalSettings(); const [notifications, notificationsAreLoading] = useGetNotificationsByTeamId(); @@ -91,7 +93,8 @@ const CreateInfrastructureMonitor = () => { if (isCreate) { if (globalSettingsLoading) return; setHttps(false); - initializeInfrastructureMonitorForCreate(globalSettings); + const typeFromQuery = searchParams.get("type") || "hardware"; + initializeInfrastructureMonitorForCreate(globalSettings, typeFromQuery); } else if (monitor) { setHttps(monitor.url.startsWith("https")); initializeInfrastructureMonitorForUpdate(monitor); @@ -101,6 +104,7 @@ const CreateInfrastructureMonitor = () => { monitor, globalSettings, globalSettingsLoading, + searchParams, initializeInfrastructureMonitorForCreate, initializeInfrastructureMonitorForUpdate, ]); diff --git a/client/src/Pages/v1/Infrastructure/Details/Components/DockerContainersTable/index.jsx b/client/src/Pages/v1/Infrastructure/Details/Components/DockerContainersTable/index.jsx index 2d1ee12aa..53ecaf746 100644 --- a/client/src/Pages/v1/Infrastructure/Details/Components/DockerContainersTable/index.jsx +++ b/client/src/Pages/v1/Infrastructure/Details/Components/DockerContainersTable/index.jsx @@ -3,7 +3,7 @@ import { useTheme } from "@emotion/react"; import DataTable from "@/Components/v1/Table/index.jsx"; import { StatusLabel } from "@/Components/v1/Label/index.jsx"; -const DockerContainersTable = ({ containers = [] }) => { +const DockerContainersTable = ({ containers = [], errors = [], captureVersion }) => { const theme = useTheme(); // Helper to format uptime @@ -136,7 +136,22 @@ const DockerContainersTable = ({ containers = [] }) => { }, ]; + // Check if there are critical errors (Docker daemon down) + const dockerClientError = errors.find((e) => e.metric && e.metric.includes("docker.client")); + if (!containers || containers.length === 0) { + // Determine the message based on error type + let message = "No containers found"; + let errorDetails = null; + + if (dockerClientError) { + message = "Docker daemon unavailable"; + errorDetails = dockerClientError.err; + } else if (errors && errors.length > 0) { + message = "Partial data available"; + errorDetails = "Some containers could not be inspected"; + } + return ( { textAlign: "center", border: `1px solid ${theme.palette.divider}`, borderRadius: theme.spacing(2), + backgroundColor: dockerClientError ? theme.palette.error.lighter : undefined, }} > - No containers found + {message} + {errorDetails && ( + + {errorDetails} + + )} + {captureVersion && ( + + Capture version: {captureVersion} + + )} ); } return ( - - Docker Containers ({containers.length}) - + + + Docker Containers ({containers.length}) + + {errors && errors.length > 0 && ( + + ⚠ {errors.length} error(s) encountered while fetching container data + + )} + {captureVersion && ( + + Capture version: {captureVersion} + + )} + { /> )} diff --git a/client/src/Pages/v1/Infrastructure/Monitors/index.jsx b/client/src/Pages/v1/Infrastructure/Monitors/index.jsx index bef4330e9..db4561149 100644 --- a/client/src/Pages/v1/Infrastructure/Monitors/index.jsx +++ b/client/src/Pages/v1/Infrastructure/Monitors/index.jsx @@ -115,7 +115,7 @@ const InfrastructureMonitors = () => { isLoading={isLoading} items={monitors} type="infrastructureMonitor" - fallbackLink="/infrastructure/create" + fallbackLink="/infrastructure/create?type=hardware" > @@ -161,7 +161,7 @@ const InfrastructureMonitors = () => { isLoading={isLoading} items={monitors} type="infrastructureMonitor" - fallbackLink="/infrastructure/create" + fallbackLink="/infrastructure/create?type=docker" >