66 RefreshCcw ,
77 RocketIcon ,
88 Settings ,
9+ Trash2 ,
910} from "lucide-react" ;
1011import React , { useEffect , useMemo , useState } from "react" ;
1112import { toast } from "sonner" ;
@@ -25,6 +26,7 @@ import {
2526import { api , type RouterOutputs } from "@/utils/api" ;
2627import { ShowRollbackSettings } from "../rollbacks/show-rollback-settings" ;
2728import { CancelQueues } from "./cancel-queues" ;
29+ import { ClearDeployments } from "./clear-deployments" ;
2830import { KillBuild } from "./kill-build" ;
2931import { RefreshToken } from "./refresh-token" ;
3032import { ShowDeployment } from "./show-deployment" ;
@@ -77,6 +79,8 @@ export const ShowDeployments = ({
7779 api . rollback . rollback . useMutation ( ) ;
7880 const { mutateAsync : killProcess , isLoading : isKillingProcess } =
7981 api . deployment . killProcess . useMutation ( ) ;
82+ const { mutateAsync : removeDeployment , isLoading : isRemovingDeployment } =
83+ api . deployment . removeDeployment . useMutation ( ) ;
8084
8185 // Cancel deployment mutations
8286 const {
@@ -144,6 +148,9 @@ export const ShowDeployments = ({
144148 </ CardDescription >
145149 </ div >
146150 < div className = "flex flex-row items-center flex-wrap gap-2" >
151+ { ( type === "application" || type === "compose" ) && (
152+ < ClearDeployments id = { id } type = { type } />
153+ ) }
147154 { ( type === "application" || type === "compose" ) && (
148155 < KillBuild id = { id } type = { type } />
149156 ) }
@@ -252,6 +259,8 @@ export const ShowDeployments = ({
252259 const isExpanded = expandedDescriptions . has (
253260 deployment . deploymentId ,
254261 ) ;
262+ const canDelete =
263+ deployment . status === "done" || deployment . status === "error" ;
255264
256265 return (
257266 < div
@@ -370,6 +379,33 @@ export const ShowDeployments = ({
370379 View
371380 </ Button >
372381
382+ { canDelete && (
383+ < DialogAction
384+ title = "Delete Deployment"
385+ description = "Are you sure you want to delete this deployment? This action cannot be undone."
386+ type = "default"
387+ onClick = { async ( ) => {
388+ try {
389+ await removeDeployment ( {
390+ deploymentId : deployment . deploymentId ,
391+ } ) ;
392+ toast . success ( "Deployment deleted successfully" ) ;
393+ } catch ( error ) {
394+ toast . error ( "Error deleting deployment" ) ;
395+ }
396+ } }
397+ >
398+ < Button
399+ variant = "destructive"
400+ size = "sm"
401+ isLoading = { isRemovingDeployment }
402+ >
403+ Delete
404+ < Trash2 className = "size-4" />
405+ </ Button >
406+ </ DialogAction >
407+ ) }
408+
373409 { deployment ?. rollback &&
374410 deployment . status === "done" &&
375411 type === "application" && (
0 commit comments