import { useDenyKey } from "../hooks"; import { Card, Checkbox, Table } from "react-daisyui"; import Button from "@/components/ui/button"; import { Trash } from "lucide-react"; import AllowKeyDialog from "./allow-key-dialog"; import { useMemo } from "react"; import { toast } from "sonner"; import { handleError } from "@/lib/utils"; import { useBucketContext } from "../context"; const PermissionsTab = () => { const { bucket, refetch } = useBucketContext(); const denyKey = useDenyKey(bucket.id, { onSuccess: () => { toast.success("Key removed!"); refetch(); }, onError: handleError, }); const keys = useMemo(() => { return bucket?.keys.filter( (key) => key.permissions.read !== false || key.permissions.write !== false || key.permissions.owner !== false ); }, [bucket?.keys]); const onRemove = (id: string) => { if (window.confirm("Are you sure you want to remove this key?")) { denyKey.mutate({ keyId: id, permissions: { read: true, write: true, owner: true }, }); } }; return (
Access Keys key.accessKeyId)} />
# Key Read Write Owner {keys?.map((key, idx) => ( {idx + 1} {key.name || key.accessKeyId?.substring(0, 8)}
); }; export default PermissionsTab;