feat(services): add role-based delete service permissions

- Restrict bulk delete action to owners and users with delete service permissions
- Conditionally render delete button based on user role and authorization
- Improve service management security by implementing fine-grained access control
This commit is contained in:
Mauricio Siu 2025-03-08 18:51:59 -06:00
parent 85734c0a24
commit 62bd8e3c95

View File

@ -668,20 +668,24 @@ const Project = (
Stop
</Button>
</DialogAction>
<DialogAction
title="Delete Services"
description={`Are you sure you want to delete ${selectedServices.length} services? This action cannot be undone.`}
type="destructive"
onClick={handleBulkDelete}
>
<Button
variant="ghost"
className="w-full justify-start text-destructive"
{(auth?.role === "owner" ||
auth?.canDeleteServices) && (
<DialogAction
title="Delete Services"
description={`Are you sure you want to delete ${selectedServices.length} services? This action cannot be undone.`}
type="destructive"
onClick={handleBulkDelete}
>
<Trash2 className="mr-2 h-4 w-4" />
Delete
</Button>
</DialogAction>
<Button
variant="ghost"
className="w-full justify-start text-destructive"
>
<Trash2 className="mr-2 h-4 w-4" />
Delete
</Button>
</DialogAction>
)}
<Dialog
open={isMoveDialogOpen}
onOpenChange={setIsMoveDialogOpen}