-
Notifications
You must be signed in to change notification settings - Fork 1
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
fix: Init redeploy #25
Merged
+556
−276
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
416ebed
fix: Init redeploy
adityachoudhari26 911924c
clean
adityachoudhari26 d3a8b55
clean
adityachoudhari26 472791f
live queries
adityachoudhari26 7527ada
clean
adityachoudhari26 5fe0aa7
force release
adityachoudhari26 3fd1f01
format
adityachoudhari26 068c625
clean
adityachoudhari26 3a456b8
Merge branch 'main' of github.com:sizzldev/ctrlplane into redeploy-init
adityachoudhari26 44f0afb
clean
adityachoudhari26 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
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
apps/webservice/src/app/[workspaceSlug]/systems/[systemSlug]/deployments/DeployButton.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,37 @@ | ||
"use client"; | ||
|
||
import { useRouter } from "next/navigation"; | ||
|
||
import { cn } from "@ctrlplane/ui"; | ||
import { Button } from "@ctrlplane/ui/button"; | ||
|
||
import { api } from "~/trpc/react"; | ||
|
||
export const DeployButton: React.FC<{ | ||
releaseId: string; | ||
environmentId: string; | ||
}> = ({ releaseId, environmentId }) => { | ||
const deploy = api.release.deploy.toEnvironment.useMutation(); | ||
const router = useRouter(); | ||
|
||
return ( | ||
<Button | ||
className={cn( | ||
"w-full border-dashed border-neutral-800/50 bg-transparent text-center text-neutral-800 hover:border-blue-400 hover:bg-transparent hover:text-blue-400", | ||
)} | ||
variant="outline" | ||
size="sm" | ||
onClick={() => | ||
deploy | ||
.mutateAsync({ | ||
environmentId, | ||
releaseId, | ||
}) | ||
.then(() => router.refresh()) | ||
} | ||
disabled={deploy.isPending} | ||
> | ||
Deploy | ||
</Button> | ||
); | ||
}; |
38 changes: 38 additions & 0 deletions
38
...ebservice/src/app/[workspaceSlug]/systems/[systemSlug]/deployments/DeploymentBarChart.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,38 @@ | ||
"use client"; | ||
|
||
import { capitalCase } from "change-case"; | ||
import { | ||
Bar, | ||
BarChart, | ||
Cell, | ||
ResponsiveContainer, | ||
XAxis, | ||
YAxis, | ||
} from "recharts"; | ||
|
||
import { getStatusColor } from "./status-color"; | ||
|
||
export const DeploymentBarChart: React.FC<{ | ||
data: { name: string; count: number }[]; | ||
}> = ({ data }) => ( | ||
<ResponsiveContainer width="100%" height={250}> | ||
<BarChart data={data} margin={{ top: 10, left: -25, bottom: -10 }}> | ||
<XAxis | ||
dataKey="name" | ||
type="category" | ||
interval={0} | ||
height={100} | ||
style={{ fontSize: "0.75rem" }} | ||
angle={-45} | ||
textAnchor="end" | ||
tickFormatter={(value) => capitalCase(value as string)} | ||
/> | ||
<YAxis style={{ fontSize: "0.75rem" }} /> | ||
<Bar dataKey="count" fill="#8884d8"> | ||
{data.map(({ name }) => ( | ||
<Cell key={name} fill={getStatusColor(name)} /> | ||
))} | ||
</Bar> | ||
</BarChart> | ||
</ResponsiveContainer> | ||
); |
175 changes: 175 additions & 0 deletions
175
...bservice/src/app/[workspaceSlug]/systems/[systemSlug]/deployments/ReleaseDropdownMenu.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,175 @@ | ||
"use client"; | ||
|
||
import { useRouter } from "next/navigation"; | ||
import { TbAlertTriangle, TbDotsVertical, TbReload } from "react-icons/tb"; | ||
|
||
import { | ||
AlertDialog, | ||
AlertDialogAction, | ||
AlertDialogCancel, | ||
AlertDialogContent, | ||
AlertDialogDescription, | ||
AlertDialogFooter, | ||
AlertDialogHeader, | ||
AlertDialogTitle, | ||
AlertDialogTrigger, | ||
} from "@ctrlplane/ui/alert-dialog"; | ||
import { Badge } from "@ctrlplane/ui/badge"; | ||
import { Button, buttonVariants } from "@ctrlplane/ui/button"; | ||
import { | ||
Dialog, | ||
DialogContent, | ||
DialogDescription, | ||
DialogFooter, | ||
DialogHeader, | ||
DialogTitle, | ||
DialogTrigger, | ||
} from "@ctrlplane/ui/dialog"; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuItem, | ||
DropdownMenuTrigger, | ||
} from "@ctrlplane/ui/dropdown-menu"; | ||
|
||
import { api } from "~/trpc/react"; | ||
|
||
const RedeployReleaseDialog: React.FC<{ | ||
release: { | ||
id: string; | ||
name: string; | ||
}; | ||
environment: { | ||
id: string; | ||
name: string; | ||
}; | ||
children: React.ReactNode; | ||
}> = ({ release, environment, children }) => { | ||
const router = useRouter(); | ||
const redeploy = api.release.deploy.toEnvironment.useMutation(); | ||
|
||
return ( | ||
<Dialog> | ||
<DialogTrigger asChild>{children}</DialogTrigger> | ||
<DialogContent> | ||
<DialogHeader> | ||
<DialogTitle> | ||
Redeploy{" "} | ||
<Badge variant="secondary" className="h-7 text-lg"> | ||
{release.name} | ||
</Badge>{" "} | ||
to {environment.name}? | ||
</DialogTitle> | ||
<DialogDescription> | ||
This will redeploy the release to all targets in the environment. | ||
</DialogDescription> | ||
</DialogHeader> | ||
|
||
<DialogFooter> | ||
<Button | ||
onClick={() => | ||
redeploy | ||
.mutateAsync({ | ||
environmentId: environment.id, | ||
releaseId: release.id, | ||
}) | ||
.then(() => router.refresh()) | ||
} | ||
> | ||
Redeploy | ||
</Button> | ||
</DialogFooter> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
const ForceReleaseDialog: React.FC<{ | ||
release: { | ||
id: string; | ||
name: string; | ||
}; | ||
environment: { | ||
id: string; | ||
name: string; | ||
}; | ||
children: React.ReactNode; | ||
}> = ({ release, environment, children }) => { | ||
const forceDeploy = api.release.deploy.toEnvironment.useMutation(); | ||
const router = useRouter(); | ||
return ( | ||
<AlertDialog> | ||
<AlertDialogTrigger asChild>{children}</AlertDialogTrigger> | ||
<AlertDialogContent> | ||
<AlertDialogHeader> | ||
<AlertDialogTitle> | ||
Force release {release.name} to {environment.name}? | ||
</AlertDialogTitle> | ||
<AlertDialogDescription> | ||
This will force the release to be deployed to all targets in the | ||
environment regardless of any policies set on the environment. | ||
</AlertDialogDescription> | ||
</AlertDialogHeader> | ||
<AlertDialogFooter className="flex"> | ||
<AlertDialogCancel>Cancel</AlertDialogCancel> | ||
<div className="flex-grow" /> | ||
<AlertDialogAction | ||
className={buttonVariants({ variant: "destructive" })} | ||
onClick={() => | ||
forceDeploy | ||
.mutateAsync({ | ||
environmentId: environment.id, | ||
releaseId: release.id, | ||
isForcedRelease: true, | ||
}) | ||
.then(() => router.refresh()) | ||
} | ||
> | ||
Force deploy | ||
</AlertDialogAction> | ||
</AlertDialogFooter> | ||
</AlertDialogContent> | ||
</AlertDialog> | ||
); | ||
}; | ||
|
||
export const ReleaseDropdownMenu: React.FC<{ | ||
release: { | ||
id: string; | ||
name: string; | ||
}; | ||
environment: { | ||
id: string; | ||
name: string; | ||
}; | ||
isReleaseCompleted: boolean; | ||
}> = ({ release, environment, isReleaseCompleted }) => ( | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button variant="ghost" size="icon"> | ||
<TbDotsVertical /> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent align="end"> | ||
<RedeployReleaseDialog release={release} environment={environment}> | ||
<DropdownMenuItem | ||
disabled={!isReleaseCompleted} | ||
onSelect={(e) => e.preventDefault()} | ||
className="space-x-2" | ||
> | ||
<TbReload /> | ||
<span>Redeploy</span> | ||
</DropdownMenuItem> | ||
</RedeployReleaseDialog> | ||
<ForceReleaseDialog release={release} environment={environment}> | ||
<DropdownMenuItem | ||
onSelect={(e) => e.preventDefault()} | ||
className="space-x-2" | ||
> | ||
<TbAlertTriangle /> | ||
<span>Force deploy</span> | ||
</DropdownMenuItem> | ||
</ForceReleaseDialog> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
); |
Oops, something went wrong.
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 think you can one liner this :)