-
-
Notifications
You must be signed in to change notification settings - Fork 556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
style(preview-deployment): better preview deployment card #938
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3858205
style: better preview deployment card
190km 3a95474
chore: lint
190km 9d1cf37
chore: lint
190km 29ce890
refactor: remove all the props except id, serverid, isloading, and de…
190km 7a5b9e3
refactor: deleted separate component, and add it to show preview build
190km 65ddc22
refactor: removed useless export
190km File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
style: better preview deployment card
- Loading branch information
commit 3858205e520c44a24c912f58565c50b009d45d9f
There are no files selected for viewing
141 changes: 141 additions & 0 deletions
141
.../dokploy/components/dashboard/application/preview-deployments/preview-deployment-card.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
import { StatusTooltip } from "@/components/shared/status-tooltip"; | ||
import { Badge } from "@/components/ui/badge"; | ||
import { Button } from "@/components/ui/button"; | ||
import { Separator } from "@/components/ui/separator"; | ||
import { Clock, GitBranch, GitPullRequest, Pencil } 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 { ShowPreviewBuilds } from "./show-preview-builds"; | ||
import { RouterOutputs } from "@/utils/api"; | ||
import { AddPreviewDomain } from "./add-preview-domain"; | ||
import { DateTooltip } from "@/components/shared/date-tooltip"; | ||
|
||
interface PreviewDeploymentCardProps { | ||
appName: string; | ||
serverId: string; | ||
onDeploymentDelete: (deploymentId: string) => void; | ||
deploymentId: string; | ||
deploymentUrl: string; | ||
deployments: RouterOutputs["deployment"]["all"]; | ||
|
||
domainId: string; | ||
domainHost: string; | ||
|
||
pullRequestTitle: string; | ||
pullRequestUrl: string; | ||
status: "running" | "error" | "done" | "idle" | undefined | null; | ||
branch: string; | ||
date: string; | ||
isLoading: boolean; | ||
} | ||
|
||
export function PreviewDeploymentCard({ | ||
appName, | ||
serverId, | ||
|
||
onDeploymentDelete, | ||
deploymentId, | ||
deployments, | ||
|
||
domainId, | ||
domainHost, | ||
|
||
pullRequestTitle, | ||
pullRequestUrl, | ||
isLoading, | ||
status, | ||
branch, | ||
date, | ||
}: PreviewDeploymentCardProps) { | ||
return ( | ||
<div className="w-full border rounded-xl"> | ||
<div className="p-6 flex flex-row items-center justify-between"> | ||
<span className="text-lg font-bold">{pullRequestTitle}</span> | ||
<Badge variant="outline" className="text-sm font-medium gap-x-2"> | ||
<StatusTooltip status={status} className="size-2.5" /> | ||
{status | ||
?.replace("running", "Running") | ||
.replace("done", "Done") | ||
.replace("error", "Error") | ||
.replace("idle", "Idle") || "Idle"} | ||
</Badge> | ||
</div> | ||
<div className="p-6 pt-0 space-y-4"> | ||
<div className="flex sm:flex-row flex-col items-center gap-2"> | ||
<div className="gap-2 flex w-full sm:flex-row flex-col items-center justify-between rounded-lg border p-2"> | ||
<Link href={`http://${domainHost}`} target="_blank" className="text-sm text-blue-500/95 hover:underline"> | ||
{domainHost} | ||
</Link> | ||
</div> | ||
<AddPreviewDomain | ||
previewDeploymentId={deploymentId} | ||
domainId={domainId} | ||
> | ||
<Button className="sm:w-auto w-full" size="sm" variant="outline"> | ||
<Pencil className="mr-2 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="h-5 w-5 text-gray-400" /> | ||
<span>Branch:</span> | ||
<Badge className="p-2" variant={"blank"}> | ||
{" "} | ||
{branch} | ||
</Badge> | ||
</div> | ||
<div className="flex items-center space-x-2"> | ||
<Clock className="h-5 w-5 text-gray-400" /> | ||
<span>Deployed: </span> | ||
<Badge className="p-2" variant={"blank"}> | ||
<DateTooltip date={date} /> | ||
</Badge> | ||
</div> | ||
</div> | ||
<Separator /> | ||
<div className="rounded-lg bg-muted p-4"> | ||
<h3 className="mb-2 text-sm font-medium">Pull Request</h3> | ||
<div className="flex items-center space-x-2 text-sm text-muted-foreground"> | ||
<GitPullRequest className="h-5 w-5 text-gray-400" /> | ||
<Link | ||
className="hover:text-blue-500/95 hover:underline" | ||
target="_blank" | ||
href={pullRequestUrl} | ||
> | ||
{pullRequestTitle} | ||
</Link> | ||
</div> | ||
</div> | ||
</div> | ||
<div className="justify-center flex-wrap p-6 pt-0"> | ||
<div className="flex flex-wrap justify-end gap-2"> | ||
<ShowPreviewBuilds deployments={deployments} serverId={serverId} /> | ||
|
||
<ShowModalLogs appName={appName} serverId={serverId}> | ||
<Button className="sm:w-auto w-full" variant="outline" size="sm"> | ||
View Logs | ||
</Button> | ||
</ShowModalLogs> | ||
|
||
<DialogAction | ||
title="Delete Preview" | ||
description="Are you sure you want to delete this preview?" | ||
onClick={() => onDeploymentDelete(deploymentId)} | ||
> | ||
<Button | ||
className="sm:w-auto w-full" | ||
variant="destructive" | ||
isLoading={isLoading} | ||
size="sm" | ||
> | ||
Delete Preview | ||
</Button> | ||
</DialogAction> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel is better to just pass the deploymentId and the serverId, and then inside the component use this hook
const { data: previewDeployment } = api.previewDeployment.one.useQuery({ previewDeploymentId: previewDeploymentId, });
In this way we avoid passing too many props, and thus isolate the component in a more elegant way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we must left
onDeploymentDelete
because we need the to refetch deployments when deleting one &isLoading
on deleting.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can also abstract and put the
handleDeletePreviewDeployment
insidethe preview-deployment-card.tsx
in this case we reduce the props we need to pass, we remove the isLoading and the onDeploymentDelete prop