From fda1c851cf507ca7e309e80ff068444dfaab93c3 Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 12 Oct 2025 13:42:24 +0000 Subject: feat: Add service dependency checks in the server overview page --- apps/web/components/admin/ServiceConnections.tsx | 150 +++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 apps/web/components/admin/ServiceConnections.tsx (limited to 'apps/web/components/admin/ServiceConnections.tsx') diff --git a/apps/web/components/admin/ServiceConnections.tsx b/apps/web/components/admin/ServiceConnections.tsx new file mode 100644 index 00000000..8d79d8bb --- /dev/null +++ b/apps/web/components/admin/ServiceConnections.tsx @@ -0,0 +1,150 @@ +"use client"; + +import { AdminCard } from "@/components/admin/AdminCard"; +import { useTranslation } from "@/lib/i18n/client"; +import { api } from "@/lib/trpc"; + +function ConnectionStatus({ + label, + configured, + connected, + pluginName, + error, +}: { + label: string; + configured: boolean; + connected: boolean; + pluginName?: string; + error?: string; +}) { + const { t } = useTranslation(); + + let statusText = t("admin.service_connections.status.not_configured"); + let badgeColor = + "bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400"; + let iconColor = "text-gray-400"; + let borderColor = "border-gray-200 dark:border-gray-700"; + + if (configured) { + if (connected) { + statusText = t("admin.service_connections.status.connected"); + badgeColor = + "bg-green-50 text-green-700 dark:bg-green-900/20 dark:text-green-400"; + iconColor = "text-green-500"; + borderColor = "border-green-200 dark:border-green-800"; + } else { + statusText = t("admin.service_connections.status.disconnected"); + badgeColor = + "bg-red-50 text-red-700 dark:bg-red-900/20 dark:text-red-400"; + iconColor = "text-red-500"; + borderColor = "border-red-200 dark:border-red-800"; + } + } + + return ( +
+
+
+
{label}
+ {pluginName && ( +
+ {pluginName} +
+ )} +
+
+
+
+
+
+ + {statusText} + +
+ {error && ( +
+

+ {error.length > 60 ? `${error.substring(0, 60)}...` : error} +

+
+ )} +
+ ); +} + +function ConnectionsSkeleton() { + return ( + +
+
+ {[1, 2, 3].map((i) => ( +
+
+
+
+
+
+
+
+
+ ))} +
+
+ ); +} + +export default function ServiceConnections() { + const { t } = useTranslation(); + const { data: connections } = api.admin.checkConnections.useQuery(undefined, { + refetchInterval: 10000, + }); + + if (!connections) { + return ; + } + + return ( + +
+ {t("admin.service_connections.title")} +
+

+ {t("admin.service_connections.description")} +

+
+ + + +
+
+ ); +} -- cgit v1.2.3-70-g09d2