Skip to content

Commit 54d5266

Browse files
authored
Merge pull request #3291 from Dokploy/feat/use-cards-in-remote-servers
Feat/use cards in remote servers
2 parents 5ebcbf8 + 3a5ac9d commit 54d5266

File tree

5 files changed

+366
-242
lines changed

5 files changed

+366
-242
lines changed

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Activity } from "lucide-react";
12
import { useState } from "react";
23
import {
34
Dialog,
@@ -6,27 +7,38 @@ import {
67
DialogTitle,
78
DialogTrigger,
89
} from "@/components/ui/dialog";
10+
import { Button } from "@/components/ui/button";
911
import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
1012
import { ShowStorageActions } from "./show-storage-actions";
1113
import { ShowTraefikActions } from "./show-traefik-actions";
1214
import { ToggleDockerCleanup } from "./toggle-docker-cleanup";
1315

1416
interface Props {
1517
serverId: string;
18+
asButton?: boolean;
1619
}
1720

18-
export const ShowServerActions = ({ serverId }: Props) => {
21+
export const ShowServerActions = ({ serverId, asButton = false }: Props) => {
1922
const [isOpen, setIsOpen] = useState(false);
2023
return (
2124
<Dialog open={isOpen} onOpenChange={setIsOpen}>
22-
<DialogTrigger asChild>
25+
{asButton ? (
26+
<DialogTrigger asChild>
27+
<Button variant="outline" size="icon" className="h-9 w-9">
28+
<Activity className="h-4 w-4" />
29+
</Button>
30+
</DialogTrigger>
31+
) : (
2332
<DropdownMenuItem
2433
className="w-full cursor-pointer"
25-
onSelect={(e) => e.preventDefault()}
34+
onSelect={(e) => {
35+
e.preventDefault();
36+
setIsOpen(true);
37+
}}
2638
>
2739
View Actions
2840
</DropdownMenuItem>
29-
</DialogTrigger>
41+
)}
3042
<DialogContent className="sm:max-w-xl">
3143
<div className="flex flex-col gap-1">
3244
<DialogTitle className="text-xl">Web server settings</DialogTitle>

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

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { zodResolver } from "@hookform/resolvers/zod";
2-
import { PlusIcon } from "lucide-react";
2+
import { PlusIcon, Pencil } from "lucide-react";
33
import Link from "next/link";
44
import { useTranslation } from "next-i18next";
55
import { useEffect, useState } from "react";
@@ -59,9 +59,10 @@ type Schema = z.infer<typeof Schema>;
5959

6060
interface Props {
6161
serverId?: string;
62+
asButton?: boolean;
6263
}
6364

64-
export const HandleServers = ({ serverId }: Props) => {
65+
export const HandleServers = ({ serverId, asButton = false }: Props) => {
6566
const { t } = useTranslation("settings");
6667

6768
const utils = api.useUtils();
@@ -137,21 +138,32 @@ export const HandleServers = ({ serverId }: Props) => {
137138

138139
return (
139140
<Dialog open={isOpen} onOpenChange={setIsOpen}>
140-
<DialogTrigger asChild>
141-
{serverId ? (
141+
{serverId ? (
142+
asButton ? (
143+
<DialogTrigger asChild>
144+
<Button variant="outline" size="icon" className="h-9 w-9">
145+
<Pencil className="h-4 w-4" />
146+
</Button>
147+
</DialogTrigger>
148+
) : (
142149
<DropdownMenuItem
143150
className="w-full cursor-pointer "
144-
onSelect={(e) => e.preventDefault()}
151+
onSelect={(e) => {
152+
e.preventDefault();
153+
setIsOpen(true);
154+
}}
145155
>
146156
Edit Server
147157
</DropdownMenuItem>
148-
) : (
158+
)
159+
) : (
160+
<DialogTrigger asChild>
149161
<Button className="cursor-pointer space-x-3">
150162
<PlusIcon className="h-4 w-4" />
151163
Create Server
152164
</Button>
153-
)}
154-
</DialogTrigger>
165+
</DialogTrigger>
166+
)}
155167
<DialogContent className="sm:max-w-3xl ">
156168
<DialogHeader>
157169
<DialogTitle>{serverId ? "Edit" : "Create"} Server</DialogTitle>

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import copy from "copy-to-clipboard";
2-
import { CopyIcon, ExternalLinkIcon, ServerIcon } from "lucide-react";
2+
import { CopyIcon, ExternalLinkIcon, ServerIcon, Settings } from "lucide-react";
33
import Link from "next/link";
44
import { useState } from "react";
55
import { toast } from "sonner";
@@ -36,9 +36,10 @@ import { ValidateServer } from "./validate-server";
3636

3737
interface Props {
3838
serverId: string;
39+
asButton?: boolean;
3940
}
4041

41-
export const SetupServer = ({ serverId }: Props) => {
42+
export const SetupServer = ({ serverId, asButton = false }: Props) => {
4243
const [isOpen, setIsOpen] = useState(false);
4344
const { data: server } = api.server.one.useQuery(
4445
{
@@ -81,14 +82,23 @@ export const SetupServer = ({ serverId }: Props) => {
8182

8283
return (
8384
<Dialog open={isOpen} onOpenChange={setIsOpen}>
84-
<DialogTrigger asChild>
85+
{asButton ? (
86+
<DialogTrigger asChild>
87+
<Button variant="outline" size="icon" className="h-9 w-9">
88+
<Settings className="h-4 w-4" />
89+
</Button>
90+
</DialogTrigger>
91+
) : (
8592
<DropdownMenuItem
8693
className="w-full cursor-pointer "
87-
onSelect={(e) => e.preventDefault()}
94+
onSelect={(e) => {
95+
e.preventDefault();
96+
setIsOpen(true);
97+
}}
8898
>
8999
Setup Server
90100
</DropdownMenuItem>
91-
</DialogTrigger>
101+
)}
92102
<DialogContent className="sm:max-w-4xl ">
93103
<DialogHeader>
94104
<div className="flex flex-col gap-1.5">

0 commit comments

Comments
 (0)