From 9d27bffc21f772210114e961ee57d7f2723d643c Mon Sep 17 00:00:00 2001 From: Nicolas Meienberger Date: Sat, 8 Nov 2025 10:16:18 +0100 Subject: [PATCH] feat: docker optional capability --- .../modules/volumes/routes/volume-details.tsx | 16 ++++-- .../app/modules/volumes/tabs/docker.tsx | 55 +++---------------- 2 files changed, 19 insertions(+), 52 deletions(-) diff --git a/apps/client/app/modules/volumes/routes/volume-details.tsx b/apps/client/app/modules/volumes/routes/volume-details.tsx index 47b6204..1b66682 100644 --- a/apps/client/app/modules/volumes/routes/volume-details.tsx +++ b/apps/client/app/modules/volumes/routes/volume-details.tsx @@ -5,6 +5,7 @@ import { useState } from "react"; import { deleteVolumeMutation, getVolumeOptions, + getSystemInfoOptions, mountVolumeMutation, unmountVolumeMutation, } from "~/api-client/@tanstack/react-query.gen"; @@ -58,6 +59,10 @@ export default function VolumeDetails({ loaderData }: Route.ComponentProps) { refetchOnWindowFocus: true, }); + const { data: systemInfo } = useQuery({ + ...getSystemInfoOptions(), + }); + const deleteVol = useMutation({ ...deleteVolumeMutation(), onSuccess: () => { @@ -109,6 +114,7 @@ export default function VolumeDetails({ loaderData }: Route.ComponentProps) { } const { volume, statfs } = data; + const dockerAvailable = systemInfo?.capabilities?.docker ?? false; return ( <> @@ -146,7 +152,7 @@ export default function VolumeDetails({ loaderData }: Route.ComponentProps) { Configuration Files - Docker + {dockerAvailable && Docker} @@ -154,9 +160,11 @@ export default function VolumeDetails({ loaderData }: Route.ComponentProps) { - - - + {dockerAvailable && ( + + + + )} diff --git a/apps/client/app/modules/volumes/tabs/docker.tsx b/apps/client/app/modules/volumes/tabs/docker.tsx index 7cc0c20..8d8fd92 100644 --- a/apps/client/app/modules/volumes/tabs/docker.tsx +++ b/apps/client/app/modules/volumes/tabs/docker.tsx @@ -1,12 +1,11 @@ import { useQuery } from "@tanstack/react-query"; -import { AlertCircle, Unplug } from "lucide-react"; +import { Unplug } from "lucide-react"; import * as YML from "yaml"; -import { Alert, AlertDescription, AlertTitle } from "~/components/ui/alert"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "~/components/ui/card"; import { CodeBlock } from "~/components/ui/code-block"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "~/components/ui/table"; import type { Volume } from "~/lib/types"; -import { getContainersUsingVolumeOptions, getSystemInfoOptions } from "../../../api-client/@tanstack/react-query.gen"; +import { getContainersUsingVolumeOptions } from "../../../api-client/@tanstack/react-query.gen"; type Props = { volume: Volume; @@ -29,11 +28,6 @@ export const DockerTabContent = ({ volume }: Props) => { const dockerRunCommand = `docker run -v im-${volume.name}:/path/in/container nginx:latest`; - const { data: systemInfo } = useQuery({ - ...getSystemInfoOptions(), - staleTime: 60000, // Cache for 1 minute - }); - const { data: containersData, isLoading, @@ -45,7 +39,6 @@ export const DockerTabContent = ({ volume }: Props) => { }); const containers = containersData || []; - const dockerAvailable = systemInfo?.data?.capabilities?.docker ?? true; const getStateClass = (state: string) => { switch (state) { @@ -60,28 +53,6 @@ export const DockerTabContent = ({ volume }: Props) => { return (
- {!dockerAvailable && ( -
- - - Docker Integration Unavailable - - Docker integration features are currently disabled. To enable them, you need to mount the following paths - in your docker-compose.yml: -
    -
  • - /var/run/docker.sock:/var/run/docker.sock -
  • -
  • - /run/docker/plugins:/run/docker/plugins -
  • -
-

After adding these mounts, restart the Ironmount container.

-
-
-
- )} - Plug-and-play Docker integration @@ -112,31 +83,19 @@ export const DockerTabContent = ({ volume }: Props) => { Containers Using This Volume - - {dockerAvailable - ? "List of Docker containers mounting this volume." - : "Docker integration is unavailable - enable it to see container information."} - + List of Docker containers mounting this volume. - {!dockerAvailable && ( -
- -

Docker integration is not available.

-
- )} - {dockerAvailable && isLoading &&
Loading containers...
} - {dockerAvailable && error && ( -
Failed to load containers: {String(error)}
- )} - {dockerAvailable && !isLoading && !error && containers.length === 0 && ( + {isLoading &&
Loading containers...
} + {error &&
Failed to load containers: {String(error)}
} + {!isLoading && !error && containers.length === 0 && (

No Docker containers are currently using this volume.

)} - {dockerAvailable && !isLoading && !error && containers.length > 0 && ( + {!isLoading && !error && containers.length > 0 && (