Skip to content

Commit a4a13b9

Browse files
committed
fix(ui): resolve tooltips overlapping open modals on remote servers page
1 parent 48504fd commit a4a13b9

5 files changed

Lines changed: 125 additions & 114 deletions

File tree

‎apps/dokploy/components/dashboard/settings/servers/actions/show-server-actions.tsx‎

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
import { Activity } from "lucide-react";
21
import { useState } from "react";
3-
import { Button } from "@/components/ui/button";
42
import {
53
Dialog,
64
DialogContent,
@@ -15,29 +13,26 @@ import { ToggleDockerCleanup } from "./toggle-docker-cleanup";
1513

1614
interface Props {
1715
serverId: string;
18-
asButton?: boolean;
16+
children?: React.ReactNode;
1917
}
2018

21-
export const ShowServerActions = ({ serverId, asButton = false }: Props) => {
19+
export const ShowServerActions = ({ serverId, children }: Props) => {
2220
const [isOpen, setIsOpen] = useState(false);
2321
return (
2422
<Dialog open={isOpen} onOpenChange={setIsOpen}>
25-
{asButton ? (
23+
{children ? (
24+
<DialogTrigger asChild>{children}</DialogTrigger>
25+
) : (
2626
<DialogTrigger asChild>
27-
<Button variant="outline" size="icon" className="h-9 w-9">
28-
<Activity className="h-4 w-4" />
29-
</Button>
27+
<DropdownMenuItem
28+
className="w-full cursor-pointer"
29+
onSelect={(e) => {
30+
e.preventDefault();
31+
}}
32+
>
33+
View Actions
34+
</DropdownMenuItem>
3035
</DialogTrigger>
31-
) : (
32-
<DropdownMenuItem
33-
className="w-full cursor-pointer"
34-
onSelect={(e) => {
35-
e.preventDefault();
36-
setIsOpen(true);
37-
}}
38-
>
39-
View Actions
40-
</DropdownMenuItem>
4136
)}
4237
<DialogContent className="sm:max-w-xl">
4338
<div className="flex flex-col gap-1">

‎apps/dokploy/components/dashboard/settings/servers/handle-servers.tsx‎

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { standardSchemaResolver as zodResolver } from "@hookform/resolvers/standard-schema";
2-
import { Pencil, PlusIcon } from "lucide-react";
2+
import { PlusIcon } from "lucide-react";
33
import Link from "next/link";
44
import { useEffect, useState } from "react";
55
import { useForm } from "react-hook-form";
@@ -61,10 +61,10 @@ type Schema = z.infer<typeof Schema>;
6161

6262
interface Props {
6363
serverId?: string;
64-
asButton?: boolean;
64+
children?: React.ReactNode;
6565
}
6666

67-
export const HandleServers = ({ serverId, asButton = false }: Props) => {
67+
export const HandleServers = ({ serverId, children }: Props) => {
6868
const utils = api.useUtils();
6969
const [isOpen, setIsOpen] = useState(false);
7070
const { data: canCreateMoreServers, refetch } =
@@ -141,24 +141,19 @@ export const HandleServers = ({ serverId, asButton = false }: Props) => {
141141

142142
return (
143143
<Dialog open={isOpen} onOpenChange={setIsOpen}>
144-
{serverId ? (
145-
asButton ? (
146-
<DialogTrigger asChild>
147-
<Button variant="outline" size="icon" className="h-9 w-9">
148-
<Pencil className="h-4 w-4" />
149-
</Button>
150-
</DialogTrigger>
151-
) : (
144+
{children ? (
145+
<DialogTrigger asChild>{children}</DialogTrigger>
146+
) : serverId ? (
147+
<DialogTrigger asChild>
152148
<DropdownMenuItem
153149
className="w-full cursor-pointer "
154150
onSelect={(e) => {
155151
e.preventDefault();
156-
setIsOpen(true);
157152
}}
158153
>
159154
Edit Server
160155
</DropdownMenuItem>
161-
)
156+
</DialogTrigger>
162157
) : (
163158
<DialogTrigger asChild>
164159
<Button className="cursor-pointer space-x-3">

‎apps/dokploy/components/dashboard/settings/servers/setup-server.tsx‎

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ import { ValidateServer } from "./validate-server";
3535

3636
interface Props {
3737
serverId: string;
38-
asButton?: boolean;
38+
children?: React.ReactNode;
3939
}
4040

41-
export const SetupServer = ({ serverId, asButton = false }: Props) => {
41+
export const SetupServer = ({ serverId, children }: Props) => {
4242
const [isOpen, setIsOpen] = useState(false);
4343
const { data: server } = api.server.one.useQuery(
4444
{
@@ -81,22 +81,14 @@ export const SetupServer = ({ serverId, asButton = false }: Props) => {
8181

8282
return (
8383
<Dialog open={isOpen} onOpenChange={setIsOpen}>
84-
{asButton ? (
84+
{children ? (
85+
<DialogTrigger asChild>{children}</DialogTrigger>
86+
) : (
8587
<DialogTrigger asChild>
86-
<Button variant="outline" size="icon" className="h-9 w-9">
87-
<Settings className="h-4 w-4" />
88+
<Button className="w-full cursor-pointer " size="sm">
89+
Setup Server <Settings className="size-4" />
8890
</Button>
8991
</DialogTrigger>
90-
) : (
91-
<Button
92-
className="w-full cursor-pointer "
93-
size="sm"
94-
onClick={() => {
95-
setIsOpen(true);
96-
}}
97-
>
98-
Setup Server <Settings className="size-4" />
99-
</Button>
10092
)}
10193
<DialogContent className="sm:max-w-4xl ">
10294
<DialogHeader>

‎apps/dokploy/components/dashboard/settings/servers/show-monitoring-modal.tsx‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,23 @@ import { ShowPaidMonitoring } from "../../monitoring/paid/servers/show-paid-moni
77
interface Props {
88
url: string;
99
token: string;
10+
children?: React.ReactNode;
1011
}
1112

12-
export const ShowMonitoringModal = ({ url, token }: Props) => {
13+
export const ShowMonitoringModal = ({ url, token, children }: Props) => {
1314
const [isOpen, setIsOpen] = useState(false);
1415

1516
return (
1617
<Dialog open={isOpen} onOpenChange={setIsOpen}>
17-
<DialogTrigger asChild>
18-
<Button variant="outline" size="icon" className="h-9 w-9">
19-
<BarChartHorizontalBigIcon className="h-4 w-4" />
20-
</Button>
21-
</DialogTrigger>
18+
{children ? (
19+
<DialogTrigger asChild>{children}</DialogTrigger>
20+
) : (
21+
<DialogTrigger asChild>
22+
<Button variant="outline" size="icon" className="h-9 w-9">
23+
<BarChartHorizontalBigIcon className="h-4 w-4" />
24+
</Button>
25+
</DialogTrigger>
26+
)}
2227
<DialogContent className="sm:max-w-7xl ">
2328
<div className="flex gap-4 py-4 w-full">
2429
<ShowPaidMonitoring BASE_URL={url} token={token} />

‎apps/dokploy/components/dashboard/settings/servers/show-servers.tsx‎

Lines changed: 86 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import { format } from "date-fns";
22
import {
3+
Activity,
4+
BarChartHorizontalBigIcon,
35
Clock,
46
Key,
57
KeyIcon,
68
Loader2,
79
Network,
10+
Pencil,
811
ServerIcon,
12+
Settings,
913
Terminal,
1014
Trash2,
1115
User,
@@ -224,11 +228,19 @@ export const ShowServers = () => {
224228
<div className="flex items-center gap-2 pt-3 border-t mt-auto flex-wrap">
225229
<div className="flex items-center gap-2 w-full">
226230
<Tooltip>
227-
<TooltipTrigger asChild>
228-
<SetupServer
229-
serverId={server.serverId}
230-
/>
231-
</TooltipTrigger>
231+
<SetupServer
232+
serverId={server.serverId}
233+
>
234+
<TooltipTrigger asChild>
235+
<Button
236+
className="w-full cursor-pointer "
237+
size="sm"
238+
>
239+
Setup Server{" "}
240+
<Settings className="size-4" />
241+
</Button>
242+
</TooltipTrigger>
243+
</SetupServer>
232244
<TooltipContent
233245
className="max-w-xs"
234246
side="bottom"
@@ -251,52 +263,60 @@ export const ShowServers = () => {
251263
{server.sshKeyId &&
252264
permissions?.server.terminal && (
253265
<Tooltip>
254-
<TooltipTrigger asChild>
255-
<div>
256-
<TerminalModal
257-
serverId={server.serverId}
258-
asButton={true}
266+
<TerminalModal
267+
serverId={server.serverId}
268+
asButton={true}
269+
>
270+
<TooltipTrigger asChild>
271+
<Button
272+
variant="outline"
273+
size="icon"
274+
className="h-9 w-9"
259275
>
260-
<Button
261-
variant="outline"
262-
size="icon"
263-
className="h-9 w-9"
264-
>
265-
<Terminal className="h-4 w-4" />
266-
</Button>
267-
</TerminalModal>
268-
</div>
269-
</TooltipTrigger>
276+
<Terminal className="h-4 w-4" />
277+
</Button>
278+
</TooltipTrigger>
279+
</TerminalModal>
270280
<TooltipContent>
271281
<p>Terminal</p>
272282
</TooltipContent>
273283
</Tooltip>
274284
)}
275285

276286
<Tooltip>
277-
<TooltipTrigger asChild>
278-
<div>
279-
<HandleServers
280-
serverId={server.serverId}
281-
asButton={true}
282-
/>
283-
</div>
284-
</TooltipTrigger>
287+
<HandleServers
288+
serverId={server.serverId}
289+
>
290+
<TooltipTrigger asChild>
291+
<Button
292+
variant="outline"
293+
size="icon"
294+
className="h-9 w-9"
295+
>
296+
<Pencil className="h-4 w-4" />
297+
</Button>
298+
</TooltipTrigger>
299+
</HandleServers>
285300
<TooltipContent>
286301
<p>Edit Server</p>
287302
</TooltipContent>
288303
</Tooltip>
289304

290305
{server.sshKeyId && !isBuildServer && (
291306
<Tooltip>
292-
<TooltipTrigger asChild>
293-
<div>
294-
<ShowServerActions
295-
serverId={server.serverId}
296-
asButton={true}
297-
/>
298-
</div>
299-
</TooltipTrigger>
307+
<ShowServerActions
308+
serverId={server.serverId}
309+
>
310+
<TooltipTrigger asChild>
311+
<Button
312+
variant="outline"
313+
size="icon"
314+
className="h-9 w-9"
315+
>
316+
<Activity className="h-4 w-4" />
317+
</Button>
318+
</TooltipTrigger>
319+
</ShowServerActions>
300320
<TooltipContent>
301321
<p>Web Server Actions</p>
302322
</TooltipContent>
@@ -307,17 +327,23 @@ export const ShowServers = () => {
307327
server.sshKeyId &&
308328
!isBuildServer && (
309329
<Tooltip>
310-
<TooltipTrigger asChild>
311-
<div>
312-
<ShowMonitoringModal
313-
url={`http://${server.ipAddress}:${server?.metricsConfig?.server?.port}/metrics`}
314-
token={
315-
server?.metricsConfig
316-
?.server?.token
317-
}
318-
/>
319-
</div>
320-
</TooltipTrigger>
330+
<ShowMonitoringModal
331+
url={`http://${server.ipAddress}:${server?.metricsConfig?.server?.port}/metrics`}
332+
token={
333+
server?.metricsConfig?.server
334+
?.token
335+
}
336+
>
337+
<TooltipTrigger asChild>
338+
<Button
339+
variant="outline"
340+
size="icon"
341+
className="h-9 w-9"
342+
>
343+
<BarChartHorizontalBigIcon className="h-4 w-4" />
344+
</Button>
345+
</TooltipTrigger>
346+
</ShowMonitoringModal>
321347
<TooltipContent>
322348
<p>Monitoring</p>
323349
</TooltipContent>
@@ -328,22 +354,20 @@ export const ShowServers = () => {
328354

329355
{permissions?.server.delete && (
330356
<Tooltip>
331-
<TooltipTrigger asChild>
332-
<div>
333-
<DeleteServerModal
334-
serverId={server.serverId}
335-
serverName={server.name}
357+
<DeleteServerModal
358+
serverId={server.serverId}
359+
serverName={server.name}
360+
>
361+
<TooltipTrigger asChild>
362+
<Button
363+
variant="ghost"
364+
size="icon"
365+
className="h-9 w-9 text-destructive hover:text-destructive hover:bg-destructive/10"
336366
>
337-
<Button
338-
variant="ghost"
339-
size="icon"
340-
className="h-9 w-9 text-destructive hover:text-destructive hover:bg-destructive/10"
341-
>
342-
<Trash2 className="h-4 w-4" />
343-
</Button>
344-
</DeleteServerModal>
345-
</div>
346-
</TooltipTrigger>
367+
<Trash2 className="h-4 w-4" />
368+
</Button>
369+
</TooltipTrigger>
370+
</DeleteServerModal>
347371
<TooltipContent>
348372
<p>Delete Server</p>
349373
</TooltipContent>

0 commit comments

Comments
 (0)