mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-24 21:11:53 +00:00
50556df713
Co-authored-by: Adrián Jesús Peña Rodríguez <adrianjpr@gmail.com> Co-authored-by: Alan Buscaglia <gentlemanprogramming@gmail.com>
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
"use client";
|
|
|
|
import { Row } from "@tanstack/react-table";
|
|
import { Pencil, Trash2 } from "lucide-react";
|
|
|
|
import {
|
|
ActionDropdown,
|
|
ActionDropdownDangerZone,
|
|
ActionDropdownItem,
|
|
} from "@/components/shadcn/dropdown";
|
|
|
|
import { EnrichedApiKey } from "./types";
|
|
|
|
interface DataTableRowActionsProps {
|
|
row: Row<EnrichedApiKey>;
|
|
onEdit: (apiKey: EnrichedApiKey) => void;
|
|
onRevoke: (apiKey: EnrichedApiKey) => void;
|
|
}
|
|
|
|
export function DataTableRowActions({
|
|
row,
|
|
onEdit,
|
|
onRevoke,
|
|
}: DataTableRowActionsProps) {
|
|
const apiKey = row.original;
|
|
const isRevoked = apiKey.attributes.revoked;
|
|
const isExpired = new Date(apiKey.attributes.expires_at) < new Date();
|
|
const canRevoke = !isRevoked && !isExpired;
|
|
|
|
return (
|
|
<div className="relative flex items-center justify-end gap-2">
|
|
<ActionDropdown>
|
|
<ActionDropdownItem
|
|
icon={<Pencil />}
|
|
label="Edit API Key"
|
|
onSelect={() => onEdit(apiKey)}
|
|
/>
|
|
{canRevoke && (
|
|
<ActionDropdownDangerZone>
|
|
<ActionDropdownItem
|
|
icon={<Trash2 />}
|
|
label="Revoke API Key"
|
|
destructive
|
|
onSelect={() => onRevoke(apiKey)}
|
|
/>
|
|
</ActionDropdownDangerZone>
|
|
)}
|
|
</ActionDropdown>
|
|
</div>
|
|
);
|
|
}
|