diff --git a/apps/dokploy/components/dashboard/application/preview-deployments/preview-deployment-card.tsx b/apps/dokploy/components/dashboard/application/preview-deployments/preview-deployment-card.tsx deleted file mode 100644 index 4d61fdec9..000000000 --- a/apps/dokploy/components/dashboard/application/preview-deployments/preview-deployment-card.tsx +++ /dev/null @@ -1,106 +0,0 @@ -import { Badge } from "@/components/ui/badge"; -import { Button } from "@/components/ui/button"; -import { Separator } from "@/components/ui/separator"; -import { Clock, GitBranch, GitPullRequest } from "lucide-react"; -import Link from "next/link"; -import { ShowModalLogs } from "../../settings/web-server/show-modal-logs"; -import { DialogAction } from "@/components/shared/dialog-action"; -import { api } from "@/utils/api"; -import { ShowPreviewBuilds } from "./show-preview-builds"; -import { DateTooltip } from "@/components/shared/date-tooltip"; - -interface PreviewDeploymentCardProps { - deploymentId: string; - serverId: string; - onDeploymentDelete: (deploymentId: string) => void; - isLoading: boolean; -} - -export function PreviewDeploymentCard({ - deploymentId, - serverId, - onDeploymentDelete, - isLoading, -}: PreviewDeploymentCardProps) { - const { data: previewDeployment } = api.previewDeployment.one.useQuery({ - previewDeploymentId: deploymentId, - }); - - if (!previewDeployment) return null; - - return ( -
-
- {previewDeployment.pullRequestTitle} - - {previewDeployment.previewStatus || "Idle"} - -
-
-
- - {previewDeployment.domain?.host} - -
-
-
- - Branch: - - {previewDeployment.branch} - -
-
- - Deployed: - - - -
-
- -
-

Pull Request

-
- - - {previewDeployment.pullRequestTitle} - -
-
-
-
-
- - - - - onDeploymentDelete(deploymentId)} - > - - -
-
-
- ); -} \ No newline at end of file diff --git a/apps/dokploy/components/dashboard/application/preview-deployments/show-preview-deployments.tsx b/apps/dokploy/components/dashboard/application/preview-deployments/show-preview-deployments.tsx index fbcc9a728..2ce187319 100644 --- a/apps/dokploy/components/dashboard/application/preview-deployments/show-preview-deployments.tsx +++ b/apps/dokploy/components/dashboard/application/preview-deployments/show-preview-deployments.tsx @@ -1,93 +1,239 @@ -import { - Card, - CardContent, - CardDescription, - CardHeader, - CardTitle, -} from "@/components/ui/card"; -import { api } from "@/utils/api"; -import { RocketIcon } from "lucide-react"; import React from "react"; +import { Badge } from "@/components/ui/badge"; +import { Button } from "@/components/ui/button"; +import { Separator } from "@/components/ui/separator"; +import { + Clock, + GitBranch, + GitPullRequest, + Pencil, + RocketIcon, +} from "lucide-react"; +import Link from "next/link"; +import { ShowModalLogs } from "../../settings/web-server/show-modal-logs"; +import { DialogAction } from "@/components/shared/dialog-action"; +import { api } from "@/utils/api"; +import { ShowPreviewBuilds } from "./show-preview-builds"; +import { DateTooltip } from "@/components/shared/date-tooltip"; import { toast } from "sonner"; -import { PreviewDeploymentCard } from "./preview-deployment-card"; +import { StatusTooltip } from "@/components/shared/status-tooltip"; +import { AddPreviewDomain } from "./add-preview-domain"; +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "@/components/ui/card"; import { ShowPreviewSettings } from "./show-preview-settings"; interface Props { - applicationId: string; + applicationId: string; } export const ShowPreviewDeployments = ({ applicationId }: Props) => { - const { data } = api.application.one.useQuery({ applicationId }); + const { data } = api.application.one.useQuery({ applicationId }); - const { mutateAsync: deletePreviewDeployment, isLoading } = - api.previewDeployment.delete.useMutation(); - const { data: previewDeployments, refetch: refetchPreviewDeployments } = - api.previewDeployment.all.useQuery( - { applicationId }, - { - enabled: !!applicationId, - } - ); + const { mutateAsync: deletePreviewDeployment, isLoading } = + api.previewDeployment.delete.useMutation(); - const handleDeletePreviewDeployment = async (previewDeploymentId: string) => { - deletePreviewDeployment({ - previewDeploymentId: previewDeploymentId, - }) - .then(() => { - refetchPreviewDeployments(); - toast.success("Preview deployment deleted"); - }) - .catch((error) => { - toast.error(error.message); - }); - }; + const { data: previewDeployments, refetch: refetchPreviewDeployments } = + api.previewDeployment.all.useQuery( + { applicationId }, + { + enabled: !!applicationId, + } + ); - return ( - - -
- Preview Deployments - See all the preview deployments -
- {data?.isPreviewDeploymentsActive && ( - - )} -
- - {data?.isPreviewDeploymentsActive ? ( - <> - {data?.previewDeployments?.length === 0 ? ( -
- - - No preview deployments found - -
- ) : ( -
- {previewDeployments?.map((previewDeployment) => ( - - ))} -
- )} - - ) : ( -
- - - Preview deployments are disabled for this application, please - enable it - - -
- )} -
-
- ); + const handleDeletePreviewDeployment = async (previewDeploymentId: string) => { + deletePreviewDeployment({ + previewDeploymentId: previewDeploymentId, + }) + .then(() => { + refetchPreviewDeployments(); + toast.success("Preview deployment deleted"); + }) + .catch((error) => { + toast.error(error.message); + }); + }; + + return ( + + +
+ Preview Deployments + See all the preview deployments +
+ {data?.isPreviewDeploymentsActive && ( + + )} +
+ + {data?.isPreviewDeploymentsActive ? ( + <> +
+ + Preview deployments are a way to test your application before it + is deployed to production. It will create a new deployment for + each pull request you create. + +
+ {!previewDeployments?.length ? ( +
+ + + No preview deployments found + +
+ ) : ( +
+ {previewDeployments.map((previewDeployment) => ( +
+
+ + {previewDeployment.pullRequestTitle} + + + + {previewDeployment.previewStatus + ?.replace("running", "Running") + .replace("done", "Done") + .replace("error", "Error") + .replace("idle", "Idle") || "Idle"} + +
+ +
+
+ + {previewDeployment.domain?.host} + + + + + +
+ +
+
+ + Branch: + + {previewDeployment.branch} + +
+
+ + Deployed: + + + +
+
+ + + +
+

+ Pull Request +

+
+ + + {previewDeployment.pullRequestTitle} + +
+
+
+ +
+
+ + + + + + + + handleDeletePreviewDeployment( + previewDeployment.previewDeploymentId + ) + } + > + + +
+
+
+ ))} +
+ )} + + ) : ( +
+ + + Preview deployments are disabled for this application, please + enable it + + +
+ )} +
+
+ ); }; + +export default ShowPreviewDeployments;