diff --git a/app/client/components/status-dot.tsx b/app/client/components/status-dot.tsx index 5902c777..99c6611e 100644 --- a/app/client/components/status-dot.tsx +++ b/app/client/components/status-dot.tsx @@ -1,30 +1,42 @@ -import type { VolumeStatus } from "~/client/lib/types"; import { cn } from "~/client/lib/utils"; import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/tooltip"; -export const StatusDot = ({ status }: { status: VolumeStatus }) => { +type StatusVariant = "success" | "neutral" | "error" | "warning" | "info"; + +interface StatusDotProps { + variant: StatusVariant; + label: string; + animated?: boolean; +} + +export const StatusDot = ({ variant, label, animated }: StatusDotProps) => { const statusMapping = { - mounted: { + success: { color: "bg-green-500", colorLight: "bg-emerald-400", - animated: true, + animated: animated ?? true, }, - unmounted: { + neutral: { color: "bg-gray-500", colorLight: "bg-gray-400", - animated: false, + animated: animated ?? false, }, error: { color: "bg-red-500", - colorLight: "bg-amber-700", - animated: true, + colorLight: "bg-red-400", + animated: animated ?? true, }, - unknown: { + warning: { color: "bg-yellow-500", colorLight: "bg-yellow-400", - animated: true, + animated: animated ?? true, }, - }[status]; + info: { + color: "bg-blue-500", + colorLight: "bg-blue-400", + animated: animated ?? true, + }, + }[variant]; return ( @@ -42,7 +54,7 @@ export const StatusDot = ({ status }: { status: VolumeStatus }) => { -

{status}

+

{label}

); diff --git a/app/client/modules/backups/components/backup-status-dot.tsx b/app/client/modules/backups/components/backup-status-dot.tsx index 624b07c1..6d30224d 100644 --- a/app/client/modules/backups/components/backup-status-dot.tsx +++ b/app/client/modules/backups/components/backup-status-dot.tsx @@ -1,7 +1,4 @@ -import { cn } from "~/client/lib/utils"; -import { Tooltip, TooltipContent, TooltipTrigger } from "~/client/components/ui/tooltip"; - -type BackupStatus = "active" | "paused" | "error" | "in_progress"; +import { StatusDot } from "~/client/components/status-dot"; export const BackupStatusDot = ({ enabled, @@ -12,60 +9,22 @@ export const BackupStatusDot = ({ hasError?: boolean; isInProgress?: boolean; }) => { - let status: BackupStatus = "paused"; + let variant: "success" | "neutral" | "error" | "info"; + let label: string; + if (isInProgress) { - status = "in_progress"; + variant = "info"; + label = "Backup in progress"; } else if (hasError) { - status = "error"; + variant = "error"; + label = "Error"; } else if (enabled) { - status = "active"; + variant = "success"; + label = "Active"; + } else { + variant = "neutral"; + label = "Paused"; } - const statusMapping = { - active: { - color: "bg-green-500", - colorLight: "bg-emerald-400", - animated: true, - label: "Active", - }, - paused: { - color: "bg-gray-500", - colorLight: "bg-gray-400", - animated: false, - label: "Paused", - }, - error: { - color: "bg-red-500", - colorLight: "bg-red-400", - animated: true, - label: "Error", - }, - in_progress: { - color: "bg-blue-500", - colorLight: "bg-blue-400", - animated: true, - label: "Backup in progress", - }, - }[status]; - - return ( - - - - {statusMapping.animated && ( - - )} - - - - -

{statusMapping.label}

-
-
- ); + return ; }; diff --git a/app/client/modules/notifications/routes/create-notification.tsx b/app/client/modules/notifications/routes/create-notification.tsx index da5db306..6f6f0dd7 100644 --- a/app/client/modules/notifications/routes/create-notification.tsx +++ b/app/client/modules/notifications/routes/create-notification.tsx @@ -31,9 +31,9 @@ export default function CreateNotification() { const createNotification = useMutation({ ...createNotificationDestinationMutation(), - onSuccess: (data) => { + onSuccess: () => { toast.success("Notification destination created successfully"); - navigate(`/notifications/${data.id}`); + navigate(`/notifications`); }, }); diff --git a/app/client/modules/notifications/routes/notification-details.tsx b/app/client/modules/notifications/routes/notification-details.tsx index 29f535f6..e418f27d 100644 --- a/app/client/modules/notifications/routes/notification-details.tsx +++ b/app/client/modules/notifications/routes/notification-details.tsx @@ -56,7 +56,6 @@ export default function NotificationDetailsPage({ loaderData }: Route.ComponentP const navigate = useNavigate(); const formId = useId(); const [showDeleteConfirm, setShowDeleteConfirm] = useState(false); - const [isEditing, setIsEditing] = useState(false); const { data } = useQuery({ ...getNotificationDestinationOptions({ path: { id: String(loaderData.id) } }), @@ -82,7 +81,6 @@ export default function NotificationDetailsPage({ loaderData }: Route.ComponentP ...updateNotificationDestinationMutation(), onSuccess: () => { toast.success("Notification destination updated successfully"); - setIsEditing(false); }, onError: (error) => { toast.error("Failed to update notification destination", { @@ -146,11 +144,6 @@ export default function NotificationDetailsPage({ loaderData }: Route.ComponentP Test - {!isEditing && ( - - )} - - - - ) : ( -
-
-
Type
-
{data.type}
-
-
-
Created
-
{new Date(data.createdAt * 1000).toLocaleString()}
-
-
-
Last Updated
-
{new Date(data.updatedAt * 1000).toLocaleString()}
-
+ <> + +
+
- )} + diff --git a/app/client/modules/notifications/routes/notifications.tsx b/app/client/modules/notifications/routes/notifications.tsx index d838aaa9..546c8883 100644 --- a/app/client/modules/notifications/routes/notifications.tsx +++ b/app/client/modules/notifications/routes/notifications.tsx @@ -157,7 +157,7 @@ export default function Notifications({ loaderData }: Route.ComponentProps) { {notification.name} {notification.type} - + )) diff --git a/app/client/modules/volumes/routes/volume-details.tsx b/app/client/modules/volumes/routes/volume-details.tsx index ed803345..1cd1e079 100644 --- a/app/client/modules/volumes/routes/volume-details.tsx +++ b/app/client/modules/volumes/routes/volume-details.tsx @@ -24,6 +24,7 @@ import { DockerTabContent } from "../tabs/docker"; import { Tooltip, TooltipContent, TooltipTrigger } from "~/client/components/ui/tooltip"; import { useSystemInfo } from "~/client/hooks/use-system-info"; import { getVolume } from "~/client/api-client"; +import type { VolumeStatus } from "~/client/lib/types"; import { deleteVolumeMutation, getVolumeOptions, @@ -31,6 +32,16 @@ import { unmountVolumeMutation, } from "~/client/api-client/@tanstack/react-query.gen"; +const getVolumeStatusVariant = (status: VolumeStatus): "success" | "neutral" | "error" | "warning" => { + const statusMap = { + mounted: "success" as const, + unmounted: "neutral" as const, + error: "error" as const, + unknown: "warning" as const, + }; + return statusMap[status]; +}; + export const handle = { breadcrumb: (match: Route.MetaArgs) => [{ label: "Volumes", href: "/volumes" }, { label: match.params.name }], }; @@ -124,7 +135,12 @@ export default function VolumeDetails({ loaderData }: Route.ComponentProps) {
- {volume.status[0].toUpperCase() + volume.status.slice(1)} + +   + {volume.status[0].toUpperCase() + volume.status.slice(1)}
diff --git a/app/client/modules/volumes/routes/volumes.tsx b/app/client/modules/volumes/routes/volumes.tsx index 2f903852..fc8bbda4 100644 --- a/app/client/modules/volumes/routes/volumes.tsx +++ b/app/client/modules/volumes/routes/volumes.tsx @@ -13,6 +13,17 @@ import { VolumeIcon } from "~/client/components/volume-icon"; import type { Route } from "./+types/volumes"; import { listVolumes } from "~/client/api-client"; import { listVolumesOptions } from "~/client/api-client/@tanstack/react-query.gen"; +import type { VolumeStatus } from "~/client/lib/types"; + +const getVolumeStatusVariant = (status: VolumeStatus): "success" | "neutral" | "error" | "warning" => { + const statusMap = { + mounted: "success" as const, + unmounted: "neutral" as const, + error: "error" as const, + unknown: "warning" as const, + }; + return statusMap[status]; +}; export const handle = { breadcrumb: () => [{ label: "Volumes" }], @@ -157,7 +168,10 @@ export default function Volumes({ loaderData }: Route.ComponentProps) { - + ))