mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-03-22 03:08:23 +00:00
64 lines
1.9 KiB
TypeScript
64 lines
1.9 KiB
TypeScript
"use client";
|
|
|
|
import { Row } from "@tanstack/react-table";
|
|
import { Pencil, Trash2 } from "lucide-react";
|
|
import { useRouter } from "next/navigation";
|
|
import { useState } from "react";
|
|
|
|
import { VerticalDotsIcon } from "@/components/icons";
|
|
import { Button } from "@/components/shadcn";
|
|
import {
|
|
ActionDropdown,
|
|
ActionDropdownDangerZone,
|
|
ActionDropdownItem,
|
|
} from "@/components/shadcn/dropdown";
|
|
import { Modal } from "@/components/shadcn/modal";
|
|
|
|
import { DeleteRoleForm } from "../workflow/forms";
|
|
interface DataTableRowActionsProps<RoleProps> {
|
|
row: Row<RoleProps>;
|
|
}
|
|
|
|
export function DataTableRowActions<RoleProps>({
|
|
row,
|
|
}: DataTableRowActionsProps<RoleProps>) {
|
|
const router = useRouter();
|
|
const [isDeleteOpen, setIsDeleteOpen] = useState(false);
|
|
const roleId = (row.original as { id: string }).id;
|
|
return (
|
|
<>
|
|
<Modal
|
|
open={isDeleteOpen}
|
|
onOpenChange={setIsDeleteOpen}
|
|
title="Are you absolutely sure?"
|
|
description="This action cannot be undone. This will permanently delete your role and remove your data from the server."
|
|
>
|
|
<DeleteRoleForm roleId={roleId} setIsOpen={setIsDeleteOpen} />
|
|
</Modal>
|
|
<div className="relative flex items-center justify-end gap-2">
|
|
<ActionDropdown
|
|
trigger={
|
|
<Button variant="ghost" size="icon-sm" className="rounded-full">
|
|
<VerticalDotsIcon className="text-slate-400" />
|
|
</Button>
|
|
}
|
|
>
|
|
<ActionDropdownItem
|
|
icon={<Pencil />}
|
|
label="Edit Role"
|
|
onSelect={() => router.push(`/roles/edit?roleId=${roleId}`)}
|
|
/>
|
|
<ActionDropdownDangerZone>
|
|
<ActionDropdownItem
|
|
icon={<Trash2 />}
|
|
label="Delete Role"
|
|
destructive
|
|
onSelect={() => setIsDeleteOpen(true)}
|
|
/>
|
|
</ActionDropdownDangerZone>
|
|
</ActionDropdown>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|