@@ -13,6 +13,7 @@ import {
1313import { api } from "@/utils/api" ;
1414import type { ServiceType } from "../show-resources" ;
1515import { AddVolumes } from "./add-volumes" ;
16+ import { ComposeVolumes } from "./compose-volumes" ;
1617import { UpdateVolume } from "./update-volume" ;
1718
1819interface Props {
@@ -41,7 +42,7 @@ export const ShowVolumes = ({ id, type }: Props) => {
4142 // Get volumes in docker-compose.yml for compose services
4243 const { data : composeVolumes } = api . compose . loadDefinedVolumes . useQuery (
4344 { composeId : id } ,
44- { enabled : type === "compose" && ! ! id }
45+ { enabled : type === "compose" && ! ! id } ,
4546 ) ;
4647
4748 const { mutateAsync : deleteVolume , isLoading : isRemoving } =
@@ -57,50 +58,49 @@ export const ShowVolumes = ({ id, type }: Props) => {
5758 </ CardDescription >
5859 </ div >
5960
60- { data && data ?. mounts ?. length > 0 && (
61- < AddVolumes serviceId = { id } refetch = { refetch } serviceType = { type } >
62- Add Volume
63- </ AddVolumes >
64- ) }
61+ < AddVolumes serviceId = { id } refetch = { refetch } serviceType = { type } >
62+ Add Volume
63+ </ AddVolumes >
6564 </ CardHeader >
6665 < CardContent className = "flex flex-col gap-4" >
67- { data ?. mounts ?. length === 0 &&
68- ( type !== "compose" || ! composeVolumes || Object . keys ( composeVolumes ) . length === 0 ) ? (
66+ { ! data ?. mounts ?. length &&
67+ ! Object . keys ( composeVolumes || { } ) . length && (
6968 < div className = "flex w-full flex-col items-center justify-center gap-3 pt-10" >
7069 < Package className = "size-8 text-muted-foreground" />
7170 < span className = "text-base text-muted-foreground" >
7271 No volumes/mounts configured
7372 </ span >
74- < AddVolumes serviceId = { id } refetch = { refetch } serviceType = { type } >
75- Add Volume
76- </ AddVolumes >
7773 </ div >
78- ) : (
74+ ) }
75+ { ( ( data ?. mounts ?. length ?? 0 ) > 0 ||
76+ Object . keys ( composeVolumes || { } ) . length > 0 ) && (
7977 < div className = "flex flex-col pt-2 gap-4" >
80- { data ?. mounts ?. length > 0 && (
78+ { ( data ?. mounts ?. length ?? 0 ) > 0 && (
8179 < AlertBlock type = "warning" >
8280 Please remember to click Redeploy after adding, editing, or
8381 deleting a mount to apply the changes.
8482 </ AlertBlock >
8583 ) }
86- { data ?. mounts ?. length > 0 && type === "compose" && composeVolumes && Object . keys ( composeVolumes ) . length > 0 && (
87- < div className = "border-t pt-4" >
88- < div >
89- < h3 className = "text-lg font-semibold" > File Mounts</ h3 >
90- < p className = "text-sm text-muted-foreground" >
91- File mounts configured through Dokploy interface
92- </ p >
84+ { ( data ?. mounts ?. length ?? 0 ) > 0 &&
85+ type === "compose" &&
86+ composeVolumes &&
87+ Object . keys ( composeVolumes ) . length > 0 && (
88+ < div className = "border-t pt-4" >
89+ < div >
90+ < h3 className = "text-lg font-semibold" > File Mounts</ h3 >
91+ < p className = "text-sm text-muted-foreground" >
92+ File mounts configured through Dokploy interface
93+ </ p >
94+ </ div >
9395 </ div >
94- </ div >
95- ) }
96+ ) }
9697 < div className = "flex flex-col gap-6" >
9798 { data ?. mounts ?. map ( ( mount ) => (
9899 < div key = { mount . mountId } >
99100 < div
100101 key = { mount . mountId }
101102 className = "flex w-full flex-col sm:flex-row sm:items-center justify-between gap-4 sm:gap-10 border rounded-lg p-4"
102103 >
103- { /* <Package className="size-8 self-center text-muted-foreground" /> */ }
104104 < div className = "grid grid-cols-1 sm:grid-cols-2 md:grid-cols-4 flex-col gap-4 sm:gap-8" >
105105 < div className = "flex flex-col gap-1" >
106106 < span className = "font-medium" > Mount Type</ span >
@@ -190,47 +190,8 @@ export const ShowVolumes = ({ id, type }: Props) => {
190190 </ div >
191191 ) }
192192 { /* Show defined volumes from docker-compose.yml for compose services */ }
193- { type === "compose" && composeVolumes && Object . keys ( composeVolumes ) . length > 0 && (
194- < div className = "space-y-4" >
195- < div >
196- < h3 className = "text-lg font-semibold" > Defined Volumes</ h3 >
197- < p className = "text-sm text-muted-foreground" >
198- Volumes defined in your docker-compose.yml file
199- </ p >
200- </ div >
201- < div className = "grid gap-3" >
202- { Object . entries ( composeVolumes ) . map ( ( [ volumeName , volumeConfig ] ) => (
203- < div key = { volumeName } className = "border rounded-lg p-4" >
204- < div className = "grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4" >
205- < div className = "flex flex-col gap-1" >
206- < span className = "font-medium" > Volume Name</ span >
207- < span className = "text-sm text-muted-foreground" >
208- { volumeName }
209- </ span >
210- </ div >
211- < div className = "flex flex-col gap-1" >
212- < span className = "font-medium" > Driver</ span >
213- < span className = "text-sm text-muted-foreground" >
214- { typeof volumeConfig === 'object' && volumeConfig !== null
215- ? ( volumeConfig as any ) ?. driver || 'default'
216- : 'default'
217- }
218- </ span >
219- </ div >
220- < div className = "flex flex-col gap-1" >
221- < span className = "font-medium" > External</ span >
222- < span className = "text-sm text-muted-foreground" >
223- { typeof volumeConfig === 'object' && volumeConfig !== null
224- ? ( volumeConfig as any ) ?. external ? 'Yes' : 'No'
225- : 'No'
226- }
227- </ span >
228- </ div >
229- </ div >
230- </ div >
231- ) ) }
232- </ div >
233- </ div >
193+ { type === "compose" && composeVolumes && (
194+ < ComposeVolumes composeVolumes = { composeVolumes } />
234195 ) }
235196 </ CardContent >
236197 </ Card >
0 commit comments