-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update and Delete deployments with cascade, also lint fix (#3)
Signed-off-by: Zachary Blasczyk <[email protected]>
- Loading branch information
1 parent
120b090
commit bf077e5
Showing
49 changed files
with
5,438 additions
and
3,138 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
63 changes: 63 additions & 0 deletions
63
apps/webservice/src/app/[workspaceSlug]/_components/DeleteDeployment.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,63 @@ | ||
"use client"; | ||
|
||
import { useRouter } from "next/navigation"; | ||
|
||
import { | ||
AlertDialog, | ||
AlertDialogContent, | ||
AlertDialogDescription, | ||
AlertDialogFooter, | ||
AlertDialogHeader, | ||
AlertDialogTitle, | ||
} from "@ctrlplane/ui/alert-dialog"; | ||
import { Button } from "@ctrlplane/ui/button"; | ||
|
||
import { api } from "~/trpc/react"; | ||
|
||
type DeleteDeploymentProps = { | ||
id: string; | ||
name: string; | ||
isOpen: boolean; | ||
setIsOpen: (isOpen: boolean) => void; | ||
}; | ||
|
||
export const DeleteDeploymentDialog: React.FC<DeleteDeploymentProps> = ({ | ||
id, | ||
name, | ||
isOpen, | ||
setIsOpen, | ||
}) => { | ||
const router = useRouter(); | ||
const deleteDeployment = api.deployment.delete.useMutation(); | ||
|
||
const onDelete = async () => { | ||
await deleteDeployment.mutateAsync(id); | ||
router.refresh(); | ||
setIsOpen(false); | ||
}; | ||
|
||
return ( | ||
<AlertDialog open={isOpen} onOpenChange={setIsOpen}> | ||
<AlertDialogContent> | ||
<AlertDialogHeader> | ||
<AlertDialogTitle>Delete Deployment</AlertDialogTitle> | ||
</AlertDialogHeader> | ||
<AlertDialogDescription> | ||
Are you sure you want to delete the{" "} | ||
<span className="rounded-md bg-gray-900 px-2 py-1 text-gray-100"> | ||
{name} | ||
</span>{" "} | ||
deployment? This action cannot be undone. | ||
</AlertDialogDescription> | ||
<AlertDialogFooter> | ||
<Button variant="outline" onClick={() => setIsOpen(false)}> | ||
Cancel | ||
</Button> | ||
<Button variant="destructive" onClick={onDelete}> | ||
Delete | ||
</Button> | ||
</AlertDialogFooter> | ||
</AlertDialogContent> | ||
</AlertDialog> | ||
); | ||
}; |
61 changes: 61 additions & 0 deletions
61
apps/webservice/src/app/[workspaceSlug]/_components/DeploymentOptionsDropdown.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,61 @@ | ||
"use client"; | ||
|
||
import React, { useState } from "react"; | ||
import { TbDotsVertical, TbEdit, TbTrash } from "react-icons/tb"; | ||
|
||
import { Button } from "@ctrlplane/ui/button"; | ||
import { | ||
DropdownMenu, | ||
DropdownMenuContent, | ||
DropdownMenuGroup, | ||
DropdownMenuItem, | ||
DropdownMenuTrigger, | ||
} from "@ctrlplane/ui/dropdown-menu"; | ||
|
||
import { DeleteDeploymentDialog } from "./DeleteDeployment"; | ||
import { EditDeploymentDialog } from "./EditDeploymentDialog"; | ||
|
||
export const DeploymentOptionsDropdown: React.FC<{ | ||
id: string; | ||
name: string; | ||
slug: string; | ||
description: string; | ||
}> = (props) => { | ||
const [deleteDialogOpen, setDeleteDialogOpen] = useState(false); | ||
|
||
return ( | ||
<> | ||
<DropdownMenu> | ||
<DropdownMenuTrigger asChild> | ||
<Button size="icon" variant="ghost" className="rounded-full"> | ||
<TbDotsVertical /> | ||
</Button> | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent | ||
className="w-42 bg-neutral-900" | ||
align="center" | ||
forceMount | ||
> | ||
<DropdownMenuGroup> | ||
<EditDeploymentDialog {...props}> | ||
<DropdownMenuItem onSelect={(e) => e.preventDefault()}> | ||
<TbEdit className="mr-2" /> | ||
Edit | ||
</DropdownMenuItem> | ||
</EditDeploymentDialog> | ||
<DropdownMenuItem onSelect={() => setDeleteDialogOpen(true)}> | ||
<TbTrash className="mr-2" /> | ||
Delete | ||
</DropdownMenuItem> | ||
</DropdownMenuGroup> | ||
</DropdownMenuContent> | ||
</DropdownMenu> | ||
|
||
<DeleteDeploymentDialog | ||
{...props} | ||
isOpen={deleteDialogOpen} | ||
setIsOpen={setDeleteDialogOpen} | ||
/> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.