import { faCircle } from "@fortawesome/free-regular-svg-icons"; import { faCheck, faEye, faEyeSlash, faKey, faXmark } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { twMerge } from "tailwind-merge"; import { Button, TableContainer, Td, Tr } from "@app/components/v2"; import { useToggle } from "@app/hooks"; import { DecryptedSecret } from "@app/hooks/api/secrets/types"; import { SecretEditRow } from "./SecretEditRow"; type Props = { secretKey: string; environments: { name: string; slug: string }[]; expandableColWidth: number; getSecretByKey: (slug: string, key: string) => DecryptedSecret | undefined; onSecretCreate: (env: string, key: string, value: string) => Promise; onSecretUpdate: (env: string, key: string, value: string) => Promise; onSecretDelete: (env: string, key: string) => Promise; }; export const SecretOverviewTableRow = ({ secretKey, environments = [], getSecretByKey, onSecretUpdate, onSecretCreate, onSecretDelete, expandableColWidth }: Props) => { const [isFormExpanded, setIsFormExpanded] = useToggle(); const totalCols = environments.length + 1; // secret key row const [isSecretVisible, setIsSecretVisible] = useToggle(); return ( <> setIsFormExpanded.toggle()} className="group">
{secretKey}
{environments.map(({ slug }, i) => { const secret = getSecretByKey(slug, secretKey); const isSecretPresent = Boolean(secret); const isSecretEmpty = secret?.value === ""; return (
{!isSecretEmpty && } {isSecretEmpty && }
); })} {isFormExpanded && (
{environments.map(({ name, slug }) => { const secret = getSecretByKey(slug, secretKey); const isCreatable = !secret; return ( ); })}
Environment Value
{name}
)} ); };