@@ -37,6 +37,13 @@ export const ShowVolumes = ({ id, type }: Props) => {
3737 const { data, refetch } = queryMap [ type ]
3838 ? queryMap [ type ] ( )
3939 : api . mongo . one . useQuery ( { mongoId : id } , { enabled : ! ! id } ) ;
40+
41+ // Get volumes in docker-compose.yml for compose services
42+ const { data : composeVolumes } = api . compose . loadDefinedVolumes . useQuery (
43+ { composeId : id } ,
44+ { enabled : type === "compose" && ! ! id }
45+ ) ;
46+
4047 const { mutateAsync : deleteVolume , isLoading : isRemoving } =
4148 api . mounts . remove . useMutation ( ) ;
4249 return (
@@ -50,14 +57,15 @@ export const ShowVolumes = ({ id, type }: Props) => {
5057 </ CardDescription >
5158 </ div >
5259
53- { data && data ?. mounts . length > 0 && (
60+ { data && data ?. mounts ? .length > 0 && (
5461 < AddVolumes serviceId = { id } refetch = { refetch } serviceType = { type } >
5562 Add Volume
5663 </ AddVolumes >
5764 ) }
5865 </ CardHeader >
5966 < CardContent className = "flex flex-col gap-4" >
60- { data ?. mounts . length === 0 ? (
67+ { data ?. mounts ?. length === 0 &&
68+ ( type !== "compose" || ! composeVolumes || Object . keys ( composeVolumes ) . length === 0 ) ? (
6169 < div className = "flex w-full flex-col items-center justify-center gap-3 pt-10" >
6270 < Package className = "size-8 text-muted-foreground" />
6371 < span className = "text-base text-muted-foreground" >
@@ -69,12 +77,24 @@ export const ShowVolumes = ({ id, type }: Props) => {
6977 </ div >
7078 ) : (
7179 < div className = "flex flex-col pt-2 gap-4" >
72- < AlertBlock type = "warning" >
73- Please remember to click Redeploy after adding, editing, or
74- deleting a mount to apply the changes.
75- </ AlertBlock >
80+ { data ?. mounts ?. length > 0 && (
81+ < AlertBlock type = "warning" >
82+ Please remember to click Redeploy after adding, editing, or
83+ deleting a mount to apply the changes.
84+ </ AlertBlock >
85+ ) }
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 >
93+ </ div >
94+ </ div >
95+ ) }
7696 < div className = "flex flex-col gap-6" >
77- { data ?. mounts . map ( ( mount ) => (
97+ { data ?. mounts ? .map ( ( mount ) => (
7898 < div key = { mount . mountId } >
7999 < div
80100 key = { mount . mountId }
@@ -169,6 +189,49 @@ export const ShowVolumes = ({ id, type }: Props) => {
169189 </ div >
170190 </ div >
171191 ) }
192+ { /* 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 >
234+ ) }
172235 </ CardContent >
173236 </ Card >
174237 ) ;
0 commit comments