mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
Merge pull request #974 from drudge/preview-deployments
feat(preview-deployments): new UI
This commit is contained in:
@@ -18,17 +18,26 @@ import { ShowDeployment } from "../deployments/show-deployment";
|
|||||||
interface Props {
|
interface Props {
|
||||||
deployments: RouterOutputs["deployment"]["all"];
|
deployments: RouterOutputs["deployment"]["all"];
|
||||||
serverId?: string;
|
serverId?: string;
|
||||||
|
trigger?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ShowPreviewBuilds = ({ deployments, serverId }: Props) => {
|
export const ShowPreviewBuilds = ({
|
||||||
|
deployments,
|
||||||
|
serverId,
|
||||||
|
trigger,
|
||||||
|
}: Props) => {
|
||||||
const [activeLog, setActiveLog] = useState<string | null>(null);
|
const [activeLog, setActiveLog] = useState<string | null>(null);
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
return (
|
return (
|
||||||
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
||||||
<DialogTrigger asChild>
|
<DialogTrigger asChild>
|
||||||
<Button className="sm:w-auto w-full" size="sm" variant="outline">
|
{trigger ? (
|
||||||
View Builds
|
trigger
|
||||||
</Button>
|
) : (
|
||||||
|
<Button className="sm:w-auto w-full" size="sm" variant="outline">
|
||||||
|
View Builds
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
<DialogContent className="max-h-screen overflow-y-auto sm:max-w-5xl">
|
<DialogContent className="max-h-screen overflow-y-auto sm:max-w-5xl">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { GithubIcon } from "@/components/icons/data-tools-icons";
|
||||||
import { DateTooltip } from "@/components/shared/date-tooltip";
|
import { DateTooltip } from "@/components/shared/date-tooltip";
|
||||||
import { DialogAction } from "@/components/shared/dialog-action";
|
import { DialogAction } from "@/components/shared/dialog-action";
|
||||||
import { StatusTooltip } from "@/components/shared/status-tooltip";
|
import { StatusTooltip } from "@/components/shared/status-tooltip";
|
||||||
@@ -10,16 +11,17 @@ import {
|
|||||||
CardHeader,
|
CardHeader,
|
||||||
CardTitle,
|
CardTitle,
|
||||||
} from "@/components/ui/card";
|
} from "@/components/ui/card";
|
||||||
import { Separator } from "@/components/ui/separator";
|
import { Input } from "@/components/ui/input";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import {
|
import {
|
||||||
Clock,
|
ExternalLink,
|
||||||
GitBranch,
|
FileText,
|
||||||
GitPullRequest,
|
GitPullRequest,
|
||||||
Pencil,
|
Layers,
|
||||||
|
PenSquare,
|
||||||
RocketIcon,
|
RocketIcon,
|
||||||
|
Trash2,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import Link from "next/link";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { ShowModalLogs } from "../../settings/web-server/show-modal-logs";
|
import { ShowModalLogs } from "../../settings/web-server/show-modal-logs";
|
||||||
@@ -88,136 +90,136 @@ export const ShowPreviewDeployments = ({ applicationId }: Props) => {
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div className="flex flex-col gap-4">
|
<div className="flex flex-col gap-4">
|
||||||
{previewDeployments.map((previewDeployment) => (
|
{previewDeployments?.map((deployment) => {
|
||||||
<div
|
const deploymentUrl = `${deployment.domain?.https ? "https" : "http"}://${deployment.domain?.host}${deployment.domain?.path || "/"}`;
|
||||||
key={previewDeployment.previewDeploymentId}
|
const status = deployment.previewStatus;
|
||||||
className="w-full border rounded-xl"
|
return (
|
||||||
>
|
<div
|
||||||
<div className="md:p-6 p-2 md:pb-3 flex flex-row items-center justify-between">
|
key={deployment.previewDeploymentId}
|
||||||
<span className="text-lg font-bold">
|
className="group relative overflow-hidden border rounded-lg transition-colors"
|
||||||
{previewDeployment.pullRequestTitle}
|
>
|
||||||
</span>
|
<div
|
||||||
<Badge
|
className={`absolute left-0 top-0 w-1 h-full ${
|
||||||
variant="outline"
|
status === "done"
|
||||||
className="text-sm font-medium gap-x-2"
|
? "bg-green-500"
|
||||||
>
|
: status === "running"
|
||||||
<StatusTooltip
|
? "bg-yellow-500"
|
||||||
status={previewDeployment.previewStatus}
|
: "bg-red-500"
|
||||||
className="size-2.5"
|
}`}
|
||||||
/>
|
/>
|
||||||
{previewDeployment.previewStatus
|
|
||||||
?.replace("running", "Running")
|
|
||||||
.replace("done", "Done")
|
|
||||||
.replace("error", "Error")
|
|
||||||
.replace("idle", "Idle") || "Idle"}
|
|
||||||
</Badge>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="md:p-6 p-2 md:pt-0 space-y-4">
|
<div className="p-4">
|
||||||
<div className="flex sm:flex-row flex-col items-center gap-2">
|
<div className="flex items-start justify-between mb-3">
|
||||||
<Link
|
<div className="flex items-start gap-3">
|
||||||
href={`http://${previewDeployment.domain?.host}`}
|
<GitPullRequest className="size-5 text-muted-foreground mt-1 flex-shrink-0" />
|
||||||
target="_blank"
|
<div>
|
||||||
className="text-sm text-blue-500/95 hover:underline gap-2 flex w-full sm:flex-row flex-col items-center justify-between rounded-lg border p-2"
|
<div className="font-medium text-sm">
|
||||||
>
|
{deployment.pullRequestTitle}
|
||||||
{previewDeployment.domain?.host}
|
</div>
|
||||||
</Link>
|
<div className="text-sm text-muted-foreground mt-1">
|
||||||
|
{deployment.branch}
|
||||||
<AddPreviewDomain
|
</div>
|
||||||
previewDeploymentId={
|
</div>
|
||||||
previewDeployment.previewDeploymentId
|
</div>
|
||||||
}
|
<Badge variant="outline" className="gap-2">
|
||||||
domainId={previewDeployment.domain?.domainId}
|
<StatusTooltip
|
||||||
>
|
status={deployment.previewStatus}
|
||||||
<Button
|
className="size-2"
|
||||||
className="sm:w-auto w-full"
|
/>
|
||||||
size="sm"
|
<DateTooltip date={deployment.createdAt} />
|
||||||
variant="outline"
|
|
||||||
>
|
|
||||||
<Pencil className="size-4" />
|
|
||||||
Edit
|
|
||||||
</Button>
|
|
||||||
</AddPreviewDomain>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex sm:flex-row text-sm flex-col items-center justify-between">
|
|
||||||
<div className="flex items-center space-x-2">
|
|
||||||
<GitBranch className="size-5 text-gray-400" />
|
|
||||||
<span>Branch:</span>
|
|
||||||
<Badge className="p-2" variant="blank">
|
|
||||||
{previewDeployment.branch}
|
|
||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center space-x-2">
|
|
||||||
<Clock className="size-5 text-gray-400" />
|
|
||||||
<span>Deployed:</span>
|
|
||||||
<Badge className="p-2" variant="blank">
|
|
||||||
<DateTooltip date={previewDeployment.createdAt} />
|
|
||||||
</Badge>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Separator />
|
<div className="pl-8 space-y-3">
|
||||||
|
<div className="relative flex-grow">
|
||||||
|
<Input
|
||||||
|
value={deploymentUrl}
|
||||||
|
readOnly
|
||||||
|
className="pr-8 text-sm text-blue-500 hover:text-blue-600 cursor-pointer"
|
||||||
|
onClick={() =>
|
||||||
|
window.open(deploymentUrl, "_blank")
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<ExternalLink className="absolute right-3 top-1/2 -translate-y-1/2 size-4 text-gray-400" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="rounded-lg bg-muted p-4">
|
<div className="flex gap-2 opacity-80 group-hover:opacity-100 transition-opacity">
|
||||||
<h3 className="mb-2 text-sm font-medium">
|
<Button
|
||||||
Pull Request
|
variant="outline"
|
||||||
</h3>
|
size="sm"
|
||||||
<div className="flex items-center space-x-2 text-sm text-muted-foreground">
|
className="gap-2"
|
||||||
<GitPullRequest className="size-5 text-gray-400" />
|
onClick={() =>
|
||||||
<Link
|
window.open(deployment.pullRequestURL, "_blank")
|
||||||
className="hover:text-blue-500/95 hover:underline"
|
}
|
||||||
target="_blank"
|
>
|
||||||
href={previewDeployment.pullRequestURL}
|
<GithubIcon className="size-4" />
|
||||||
>
|
Pull Request
|
||||||
{previewDeployment.pullRequestTitle}
|
</Button>
|
||||||
</Link>
|
<ShowModalLogs
|
||||||
|
appName={deployment.appName}
|
||||||
|
serverId={data?.serverId || ""}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
className="gap-2"
|
||||||
|
>
|
||||||
|
<FileText className="size-4" />
|
||||||
|
Logs
|
||||||
|
</Button>
|
||||||
|
</ShowModalLogs>
|
||||||
|
|
||||||
|
<ShowPreviewBuilds
|
||||||
|
deployments={deployment.deployments || []}
|
||||||
|
serverId={data?.serverId || ""}
|
||||||
|
trigger={
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="sm"
|
||||||
|
className="gap-2"
|
||||||
|
>
|
||||||
|
<Layers className="size-4" />
|
||||||
|
Builds
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<AddPreviewDomain
|
||||||
|
previewDeploymentId={`${deployment.previewDeploymentId}`}
|
||||||
|
domainId={deployment.domain?.domainId}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
className="gap-2"
|
||||||
|
>
|
||||||
|
<PenSquare className="size-4" />
|
||||||
|
</Button>
|
||||||
|
</AddPreviewDomain>
|
||||||
|
<DialogAction
|
||||||
|
title="Delete Preview"
|
||||||
|
description="Are you sure you want to delete this preview?"
|
||||||
|
onClick={() =>
|
||||||
|
handleDeletePreviewDeployment(
|
||||||
|
deployment.previewDeploymentId,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="sm"
|
||||||
|
isLoading={isLoading}
|
||||||
|
className="text-red-600 hover:text-red-700 hover:bg-red-50"
|
||||||
|
>
|
||||||
|
<Trash2 className="size-4" />
|
||||||
|
</Button>
|
||||||
|
</DialogAction>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
);
|
||||||
<div className="justify-center flex-wrap md:p-6 p-2 md:pt-0">
|
})}
|
||||||
<div className="flex flex-wrap justify-end gap-2">
|
|
||||||
<ShowModalLogs
|
|
||||||
appName={previewDeployment.appName}
|
|
||||||
serverId={data?.serverId || ""}
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
className="sm:w-auto w-full"
|
|
||||||
variant="outline"
|
|
||||||
size="sm"
|
|
||||||
>
|
|
||||||
View Logs
|
|
||||||
</Button>
|
|
||||||
</ShowModalLogs>
|
|
||||||
|
|
||||||
<ShowPreviewBuilds
|
|
||||||
deployments={previewDeployment.deployments || []}
|
|
||||||
serverId={data?.serverId || ""}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<DialogAction
|
|
||||||
title="Delete Preview"
|
|
||||||
description="Are you sure you want to delete this preview?"
|
|
||||||
onClick={() =>
|
|
||||||
handleDeletePreviewDeployment(
|
|
||||||
previewDeployment.previewDeploymentId,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Button
|
|
||||||
className="sm:w-auto w-full"
|
|
||||||
variant="destructive"
|
|
||||||
isLoading={isLoading}
|
|
||||||
size="sm"
|
|
||||||
>
|
|
||||||
Delete Preview
|
|
||||||
</Button>
|
|
||||||
</DialogAction>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import {
|
|||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
import { api } from "@/utils/api";
|
import { api } from "@/utils/api";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import { Settings2 } from "lucide-react";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
@@ -116,7 +117,10 @@ export const ShowPreviewSettings = ({ applicationId }: Props) => {
|
|||||||
<div>
|
<div>
|
||||||
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
<Dialog open={isOpen} onOpenChange={setIsOpen}>
|
||||||
<DialogTrigger asChild>
|
<DialogTrigger asChild>
|
||||||
<Button variant="outline">View Settings</Button>
|
<Button variant="outline">
|
||||||
|
<Settings2 className="size-4" />
|
||||||
|
Configure
|
||||||
|
</Button>
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
<DialogContent className="max-h-screen overflow-y-auto sm:max-w-5xl w-full">
|
<DialogContent className="max-h-screen overflow-y-auto sm:max-w-5xl w-full">
|
||||||
<DialogHeader>
|
<DialogHeader>
|
||||||
|
|||||||
Reference in New Issue
Block a user