From 0a826fbf1c0b73b8c2538792ce4324b152c4fe46 Mon Sep 17 00:00:00 2001 From: vishalkadam47 Date: Fri, 24 Jan 2025 06:13:54 +0530 Subject: [PATCH] feat: add dropdown menu for service domains and add download functionality for SSH keys --- .../components/dashboard/projects/show.tsx | 100 ++++++++++++++++-- .../settings/ssh-keys/handle-ssh-keys.tsx | 58 +++++++++- 2 files changed, 147 insertions(+), 11 deletions(-) diff --git a/apps/dokploy/components/dashboard/projects/show.tsx b/apps/dokploy/components/dashboard/projects/show.tsx index afeabf309..ca83b5889 100644 --- a/apps/dokploy/components/dashboard/projects/show.tsx +++ b/apps/dokploy/components/dashboard/projects/show.tsx @@ -23,8 +23,10 @@ import { import { DropdownMenu, DropdownMenuContent, + DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, + DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Input } from "@/components/ui/input"; @@ -149,14 +151,91 @@ export const ShowProjects = () => { href={`/dashboard/project/${project.projectId}`} > - - + {project.applications.length > 0 || + project.compose.length > 0 ? ( + + + + + e.stopPropagation()} + > + {project.applications.length > 0 && ( + + + Applications + + {project.applications.map((app) => ( +
+ + + + {app.name} + + + {app.domains.map((domain) => ( + + + {domain.host} + + + + ))} + +
+ ))} +
+ )} + {project.compose.length > 0 && ( + + + Compose + + {project.compose.map((comp) => ( +
+ + + + {comp.name} + + + {comp.domains.map((domain) => ( + + + {domain.host} + + + + ))} + +
+ ))} +
+ )} +
+
+ ) : null} @@ -182,7 +261,10 @@ export const ShowProjects = () => { - + e.stopPropagation()} + > Actions diff --git a/apps/dokploy/components/dashboard/settings/ssh-keys/handle-ssh-keys.tsx b/apps/dokploy/components/dashboard/settings/ssh-keys/handle-ssh-keys.tsx index f100979e3..fc48134a2 100644 --- a/apps/dokploy/components/dashboard/settings/ssh-keys/handle-ssh-keys.tsx +++ b/apps/dokploy/components/dashboard/settings/ssh-keys/handle-ssh-keys.tsx @@ -22,7 +22,7 @@ import { Textarea } from "@/components/ui/textarea"; import { sshKeyCreate, type sshKeyType } from "@/server/db/validations"; import { api } from "@/utils/api"; import { zodResolver } from "@hookform/resolvers/zod"; -import { PenBoxIcon, PlusIcon } from "lucide-react"; +import { DownloadIcon, PenBoxIcon, PlusIcon } from "lucide-react"; import { useEffect, useState } from "react"; import { useForm } from "react-hook-form"; import { toast } from "sonner"; @@ -111,6 +111,26 @@ export const HandleSSHKeys = ({ sshKeyId }: Props) => { toast.error("Error generating the SSH Key"); }); + const downloadKey = ( + content: string, + defaultFilename: string, + keyType: "private" | "public", + ) => { + const keyName = form.watch("name"); + const filename = keyName + ? `${keyName}${sshKeyId ? `_${sshKeyId}` : ""}_${keyType}_${defaultFilename}` + : `${keyType}_${defaultFilename}`; + const blob = new Blob([content], { type: "text/plain" }); + const url = window.URL.createObjectURL(blob); + const a = document.createElement("a"); + a.href = url; + a.download = filename; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + window.URL.revokeObjectURL(url); + }; + return ( @@ -245,7 +265,41 @@ export const HandleSSHKeys = ({ sshKeyId }: Props) => { )} /> - + +
+ {form.watch("privateKey") && ( + + )} + {form.watch("publicKey") && ( + + )} +