Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

improvement(secrets): normalize honey token v3 interactions (#7735)

Andrew Huang85cc71ce4620
diff --git a/frontend/src/components/honey-tokens/CreateHoneyTokenModal.tsx b/frontend/src/components/honey-tokens/CreateHoneyTokenModal.tsx
index 6b0f004a48..0353ad3dfb 100644
--- a/frontend/src/components/honey-tokens/CreateHoneyTokenModal.tsx
+++ b/frontend/src/components/honey-tokens/CreateHoneyTokenModal.tsx
@@ -4,12 +4,12 @@ import { HoneyTokenForm } from "@app/components/honey-tokens/forms";
import { HoneyTokenModalHeader } from "@app/components/honey-tokens/HoneyTokenModalHeader";
import { HoneyTokenSelect } from "@app/components/honey-tokens/HoneyTokenSelect";
import {
- Dialog,
- DialogContent,
- DialogDescription,
- DialogHeader,
- DialogTitle,
- DocumentationLinkBadge
+ DocumentationLinkBadge,
+ Sheet,
+ SheetContent,
+ SheetDescription,
+ SheetHeader,
+ SheetTitle
} from "@app/components/v3";
import { HoneyTokenType } from "@app/hooks/api/honeyTokens/enums";
import { ProjectEnv } from "@app/hooks/api/projects/types";
@@ -32,6 +32,9 @@ type ContentProps = {
onCancel: () => void;
} & SharedProps;
+const HONEY_TOKEN_TYPES = Object.values(HoneyTokenType);
+const DEFAULT_HONEY_TOKEN_TYPE = HONEY_TOKEN_TYPES.length === 1 ? HONEY_TOKEN_TYPES[0] : null;
+
const Content = ({ setSelectedType, selectedType, onCancel, ...props }: ContentProps) => {
if (selectedType) {
return <HoneyTokenForm onCancel={onCancel} type={selectedType} {...props} />;
@@ -41,48 +44,75 @@ const Content = ({ setSelectedType, selectedType, onCancel, ...props }: ContentP
};
export const CreateHoneyTokenModal = ({ onOpenChange, isOpen, ...props }: Props) => {
- const [selectedType, setSelectedType] = useState<HoneyTokenType | null>(null);
+ const [selectedType, setSelectedType] = useState<HoneyTokenType | null>(DEFAULT_HONEY_TOKEN_TYPE);
const handleReset = () => {
- setSelectedType(null);
+ setSelectedType(DEFAULT_HONEY_TOKEN_TYPE);
+ };
+
+ const closeSheet = () => {
+ handleReset();
+ onOpenChange(false);
+ };
+
+ const handleCancel = () => {
+ if (DEFAULT_HONEY_TOKEN_TYPE) {
+ closeSheet();
+ return;
+ }
+
+ handleReset();
+ };
+
+ const handleSheetOpenChange = (open: boolean) => {
+ if (!open) {
+ closeSheet();
+ return;
+ }
+
+ onOpenChange(true);
};
return (
- <Dialog
- open={isOpen}
- onOpenChange={(open) => {
- if (!open) {
- handleReset();
- }
- onOpenChange(open);
- }}
- >
- <DialogContent className="max-w-3xl">
- <DialogHeader>
- <DialogTitle>
- {selectedType ? (
- <HoneyTokenModalHeader type={selectedType} />
- ) : (
+ <Sheet open={isOpen} onOpenChange={handleSheetOpenChange}>
+ <SheetContent className="flex h-full max-h-full flex-col gap-y-0 sm:max-w-5xl">
+ <SheetHeader className="border-b">
+ {selectedType ? (
+ <HoneyTokenModalHeader type={selectedType} />
+ ) : (
+ <SheetTitle>
<div className="flex items-center gap-x-2">
Add Honey Token
<DocumentationLinkBadge href="https://infisical.com/docs/documentation/platform/honey-tokens/overview" />
</div>
- )}
- </DialogTitle>
+ </SheetTitle>
+ )}
{!selectedType && (
- <DialogDescription>Select a provider to create a honey token for.</DialogDescription>
+ <SheetDescription>Select a provider to create a honey token for.</SheetDescription>
)}
- </DialogHeader>
- <Content
- onComplete={() => {
- onOpenChange(false);
- }}
- onCancel={handleReset}
- selectedType={selectedType}
- setSelectedType={setSelectedType}
- {...props}
- />
- </DialogContent>
- </Dialog>
+ </SheetHeader>
+ {selectedType ? (
+ <div className="flex min-h-0 flex-1 flex-col">
+ <Content
+ onComplete={closeSheet}
+ onCancel={handleCancel}
+ selectedType={selectedType}
+ setSelectedType={setSelectedType}
+ {...props}
+ />
+ </div>
+ ) : (
+ <div className="flex min-h-0 flex-1 flex-col overflow-y-auto p-4">
+ <Content
+ onComplete={closeSheet}
+ onCancel={handleCancel}
+ selectedType={selectedType}
+ setSelectedType={setSelectedType}
+ {...props}
+ />
+ </div>
+ )}
+ </SheetContent>
+ </Sheet>
);
};
diff --git a/frontend/src/components/honey-tokens/DeleteHoneyTokenModal.tsx b/frontend/src/components/honey-tokens/DeleteHoneyTokenModal.tsx
index 12f08a6d37..2247dddcf8 100644
--- a/frontend/src/components/honey-tokens/DeleteHoneyTokenModal.tsx
+++ b/frontend/src/components/honey-tokens/DeleteHoneyTokenModal.tsx
@@ -1,21 +1,14 @@
-import { useEffect, useState } from "react";
-import { Trash2Icon } from "lucide-react";
-
import { createNotification } from "@app/components/notifications";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
+ AlertDialogConfirmationField,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
- AlertDialogMedia,
- AlertDialogTitle,
- Field,
- FieldContent,
- FieldLabel,
- Input
+ AlertDialogTitle
} from "@app/components/v3";
import { useRevokeHoneyToken } from "@app/hooks/api/honeyTokens";
import { TDashboardHoneyToken } from "@app/hooks/api/honeyTokens/types";
@@ -28,11 +21,6 @@ type Props = {
export const DeleteHoneyTokenModal = ({ isOpen, onOpenChange, honeyToken }: Props) => {
const revokeHoneyToken = useRevokeHoneyToken();
- const [inputData, setInputData] = useState("");
-
- useEffect(() => {
- setInputData("");
- }, [isOpen]);
if (!honeyToken) return null;
@@ -51,43 +39,29 @@ export const DeleteHoneyTokenModal = ({ isOpen, onOpenChange, honeyToken }: Prop
};
return (
- <AlertDialog open={isOpen} onOpenChange={onOpenChange}>
+ <AlertDialog open={isOpen} confirmationValue={honeyToken.name} onOpenChange={onOpenChange}>
<AlertDialogContent className="sm:max-w-xl!">
<AlertDialogHeader>
- <AlertDialogMedia>
- <Trash2Icon />
- </AlertDialogMedia>
<AlertDialogTitle>Are you sure you want to delete {honeyToken.name}?</AlertDialogTitle>
<AlertDialogDescription>
This will revoke the AWS IAM credentials and remove the associated decoy secrets from
this environment.
</AlertDialogDescription>
</AlertDialogHeader>
- <form
- onSubmit={(e) => {
- e.preventDefault();
- if (inputData === honeyToken.name) handleDelete();
+ <AlertDialogConfirmationField
+ onConfirm={() => {
+ if (!revokeHoneyToken.isPending) handleDelete().catch(() => undefined);
}}
- >
- <Field>
- <FieldLabel>
- Type <span className="font-bold">{honeyToken.name}</span> to confirm
- </FieldLabel>
- <FieldContent>
- <Input
- value={inputData}
- onChange={(e) => setInputData(e.target.value)}
- placeholder={`Type ${honeyToken.name} here`}
- />
- </FieldContent>
- </Field>
- </form>
+ />
<AlertDialogFooter>
- <AlertDialogCancel>Cancel</AlertDialogCancel>
+ <AlertDialogCancel isDisabled={revokeHoneyToken.isPending}>Cancel</AlertDialogCancel>
<AlertDialogAction
variant="danger"
- onClick={handleDelete}
- disabled={inputData !== honeyToken.name}
+ isPending={revokeHoneyToken.isPending}
+ onClick={(event) => {
+ event.preventDefault();
+ if (!revokeHoneyToken.isPending) handleDelete().catch(() => undefined);
+ }}
>
Delete
</AlertDialogAction>
diff --git a/frontend/src/components/honey-tokens/EditHoneyTokenModal.tsx b/frontend/src/components/honey-tokens/EditHoneyTokenModal.tsx
index 2ed5fd7f74..fda9928dc3 100644
--- a/frontend/src/components/honey-tokens/EditHoneyTokenModal.tsx
+++ b/frontend/src/components/honey-tokens/EditHoneyTokenModal.tsx
@@ -1,6 +1,6 @@
import { HoneyTokenForm } from "@app/components/honey-tokens/forms";
import { HoneyTokenModalHeader } from "@app/components/honey-tokens/HoneyTokenModalHeader";
-import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@app/components/v3";
+import { Sheet, SheetContent, SheetHeader } from "@app/components/v3";
import { HoneyTokenType } from "@app/hooks/api/honeyTokens/enums";
import { TDashboardHoneyToken } from "@app/hooks/api/honeyTokens/types";
@@ -14,13 +14,11 @@ export const EditHoneyTokenModal = ({ isOpen, onOpenChange, honeyToken }: Props)
if (!honeyToken) return null;
return (
- <Dialog open={isOpen} onOpenChange={onOpenChange}>
- <DialogContent className="max-w-2xl">
- <DialogHeader>
- <DialogTitle>
- <HoneyTokenModalHeader type={honeyToken.type as HoneyTokenType} isEdit />
- </DialogTitle>
- </DialogHeader>
+ <Sheet open={isOpen} onOpenChange={onOpenChange}>
+ <SheetContent className="flex h-full max-h-full flex-col gap-y-0 sm:max-w-5xl">
+ <SheetHeader className="border-b">
+ <HoneyTokenModalHeader type={honeyToken.type as HoneyTokenType} isEdit />
+ </SheetHeader>
<HoneyTokenForm
onComplete={() => onOpenChange(false)}
onCancel={() => onOpenChange(false)}
@@ -29,7 +27,7 @@ export const EditHoneyTokenModal = ({ isOpen, onOpenChange, honeyToken }: Props)
secretPath={honeyToken.folder.path}
environment={honeyToken.environment.slug}
/>
- </DialogContent>
- </Dialog>
+ </SheetContent>
+ </Sheet>
);
};
diff --git a/frontend/src/components/honey-tokens/HoneyTokenDetailsDrawer.tsx b/frontend/src/components/honey-tokens/HoneyTokenDetailsDrawer.tsx
index ce53c85188..1932e50601 100644
--- a/frontend/src/components/honey-tokens/HoneyTokenDetailsDrawer.tsx
+++ b/frontend/src/components/honey-tokens/HoneyTokenDetailsDrawer.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useState } from "react";
+import { useState } from "react";
import { subject } from "@casl/ability";
import { format, formatDistanceToNow } from "date-fns";
import {
@@ -7,7 +7,6 @@ import {
CalendarIcon,
ClockIcon,
HexagonIcon,
- KeyIcon,
MapPinIcon,
RotateCcw
} from "lucide-react";
@@ -15,29 +14,25 @@ import {
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
import {
- Accordion,
- AccordionContent,
- AccordionItem,
- AccordionTrigger,
Alert,
+ AlertDescription,
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
+ AlertDialogConfirmationField,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogMedia,
AlertDialogTitle,
+ AlertTitle,
Badge,
Button,
- Field,
- FieldContent,
- FieldLabel,
- Input,
PageLoader,
Sheet,
SheetContent,
+ SheetFooter,
SheetHeader,
SheetTitle,
Skeleton,
@@ -64,7 +59,7 @@ type Props = {
onClose: () => void;
};
-const DrawerContent = ({
+const HoneyTokenDetailsContent = ({
honeyTokenId,
projectId
}: {
@@ -78,11 +73,10 @@ const DrawerContent = ({
});
const { mutateAsync: resetHoneyToken } = useResetHoneyToken();
- const { mutateAsync: revokeHoneyToken } = useRevokeHoneyToken();
+ const { mutateAsync: revokeHoneyToken, isPending: isRevoking } = useRevokeHoneyToken();
const { permission } = useProjectPermission();
const [isRevokeOpen, setIsRevokeOpen] = useState(false);
const [isResetOpen, setIsResetOpen] = useState(false);
- const [revokeInput, setRevokeInput] = useState("");
const honeyTokenSubject = subject(ProjectPermissionSub.HoneyTokens, {
environment: honeyToken?.environment?.slug ?? "",
secretPath: honeyToken?.folder?.path ?? ""
@@ -98,20 +92,28 @@ const DrawerContent = ({
enabled: Boolean(honeyTokenId && projectId && canReadCredentials)
});
- useEffect(() => {
- setRevokeInput("");
- }, [isRevokeOpen]);
-
if (isPending) {
return (
- <div className="flex h-full w-full items-center justify-center p-8">
- <PageLoader />
- </div>
+ <>
+ <SheetHeader className="sr-only">
+ <SheetTitle>Honey token details</SheetTitle>
+ </SheetHeader>
+ <div className="flex h-full w-full items-center justify-center p-8">
+ <PageLoader />
+ </div>
+ </>
);
}
if (!honeyToken) {
- return <div className="p-4 text-center text-sm text-muted">Could not find honey token.</div>;
+ return (
+ <>
+ <SheetHeader className="sr-only">
+ <SheetTitle>Honey token details</SheetTitle>
+ </SheetHeader>
+ <div className="p-4 text-center text-sm text-muted">Could not find honey token.</div>
+ </>
+ );
}
const isTriggered = honeyToken.status === HoneyTokenStatus.Triggered;
@@ -142,12 +144,13 @@ const DrawerContent = ({
text: `Successfully revoked honey token "${honeyToken.name}"`,
type: "success"
});
+ setIsRevokeOpen(false);
};
return (
<>
- <div className="flex flex-col gap-4 p-4">
- <div className="flex items-start justify-between">
+ <SheetHeader className="gap-4">
+ <div className="flex items-start pr-8">
<div className="flex items-center gap-3">
{tokenInfo && (
<img
@@ -156,9 +159,9 @@ const DrawerContent = ({
alt={`${tokenInfo.name} logo`}
/>
)}
- <div className="min-w-0">
+ <div className="flex min-w-0 flex-col gap-1">
<div className="flex flex-wrap items-center gap-2">
- <p className="truncate font-medium">{honeyToken.name}</p>
+ <SheetTitle className="truncate">{honeyToken.name}</SheetTitle>
<Badge variant={statusBadgeVariant}>
{isTriggered && <AlertTriangle size={12} className="mr-1" />}
{statusLabel}
@@ -169,81 +172,70 @@ const DrawerContent = ({
</p>
</div>
</div>
- <div className="flex shrink-0 items-center gap-2">
- {isTriggered && (
- <ProjectPermissionCan
- I={ProjectPermissionHoneyTokenActions.Reset}
- a={honeyTokenSubject}
- >
- {(isAllowed) => (
- <Button
- variant="outline"
- size="xs"
- onClick={() => setIsResetOpen(true)}
- isDisabled={!isAllowed}
- >
- <RotateCcw size={14} />
- Reset
- </Button>
- )}
- </ProjectPermissionCan>
- )}
- {!isRevoked && (
- <ProjectPermissionCan
- I={ProjectPermissionHoneyTokenActions.Revoke}
- a={honeyTokenSubject}
- >
- {(isAllowed) => (
- <Button
- variant="danger"
- size="xs"
- onClick={() => setIsRevokeOpen(true)}
- isDisabled={!isAllowed}
- >
- <BanIcon size={14} />
- Revoke
- </Button>
- )}
- </ProjectPermissionCan>
- )}
- </div>
</div>
+ </SheetHeader>
- <div className="flex flex-wrap items-center gap-x-4 gap-y-2 border-t border-border pt-4 text-xs text-muted">
- <Tooltip>
- <TooltipTrigger asChild>
- <div className="flex items-center gap-1.5">
- <CalendarIcon size={13} />
- <span>
+ <div className="flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto p-4">
+ <div className="flex flex-col gap-4">
+ <div className="flex flex-wrap gap-2">
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Badge variant="shaded" iconPosition="left">
+ <CalendarIcon size={13} />
Created {formatDistanceToNow(new Date(honeyToken.createdAt), { addSuffix: true })}
- </span>
- </div>
- </TooltipTrigger>
- <TooltipContent>
- {format(new Date(honeyToken.createdAt), "MMMM do, yyyy 'at' h:mm a")}
- </TooltipContent>
- </Tooltip>
- {honeyToken.environment && (
- <div className="flex items-center gap-1.5">
- <MapPinIcon size={13} />
- <span>
+ </Badge>
+ </TooltipTrigger>
+ <TooltipContent>
+ {format(new Date(honeyToken.createdAt), "MMMM do, yyyy 'at' h:mm a")}
+ </TooltipContent>
+ </Tooltip>
+ {honeyToken.environment && (
+ <Badge variant="shaded" iconPosition="left">
+ <MapPinIcon size={13} />
{honeyToken.environment.name}
{honeyToken.folder?.path && honeyToken.folder.path !== "/"
? ` — ${honeyToken.folder.path}`
: ""}
- </span>
- </div>
- )}
- <div className="flex items-center gap-1.5">
- <HexagonIcon size={13} />
- <span>
+ </Badge>
+ )}
+ <Badge variant="shaded" iconPosition="left">
+ <HexagonIcon size={13} />
{honeyToken.openEvents} open event{honeyToken.openEvents !== 1 && "s"}
- </span>
- </div>
- <div className="flex items-center gap-1.5">
- <ClockIcon size={13} />
- <span>Active for {formatDistanceToNow(new Date(honeyToken.createdAt))}</span>
+ </Badge>
+ <Badge variant="shaded" iconPosition="left">
+ <ClockIcon size={13} />
+ Active for {formatDistanceToNow(new Date(honeyToken.createdAt))}
+ </Badge>
</div>
+
+ {isRevoked && (
+ <Alert variant="info">
+ <BanIcon />
+ <AlertTitle>Honey token revoked</AlertTitle>
+ <AlertDescription>
+ The AWS IAM credentials have been revoked and the decoy secrets removed. The honey
+ token record and its events are preserved for audit purposes.
+ </AlertDescription>
+ </Alert>
+ )}
+
+ {isTriggered && (
+ <Alert variant="warning">
+ <AlertTriangle />
+ <AlertTitle>What to do now?</AlertTitle>
+ <AlertDescription className="gap-2">
+ <p>
+ If this is a false alarm, reset the honey token to return it to active status and
+ hide past events.
+ </p>
+ <p>
+ If this activity is suspicious, follow your company&apos;s incident response plan,
+ rotate any real secrets stored alongside the honey token, then revoke and replace
+ the honey token.
+ </p>
+ </AlertDescription>
+ </Alert>
+ )}
</div>
{!isRevoked && (
@@ -253,11 +245,7 @@ const DrawerContent = ({
>
{(isAllowed) =>
isAllowed && (
- <div className="border-t border-border pt-4">
- <div className="mb-2 flex items-center gap-1.5 text-xs text-muted">
- <KeyIcon size={13} />
- <span>Credentials</span>
- </div>
+ <div>
{isCredentialsPending && (
<div className="flex flex-col gap-2 py-2">
<Skeleton className="h-8 w-full rounded-md" />
@@ -286,66 +274,44 @@ const DrawerContent = ({
</ProjectPermissionCan>
)}
- {isRevoked && (
- <div className="rounded-md border border-border bg-container p-4">
- <div className="mb-2 flex items-center gap-2">
- <BanIcon size={16} className="text-muted" />
- <p className="text-sm font-medium text-muted">Honey token revoked</p>
- </div>
- <p className="text-xs text-foreground/85">
- The AWS IAM credentials have been revoked and the decoy secrets removed. The honey
- token record and its events are preserved for audit purposes.
- </p>
- </div>
- )}
-
- {isTriggered && (
- <Accordion
- type="single"
- collapsible
- variant="ghost"
- className="border-t border-border pt-2"
- >
- <AccordionItem value="response-guidance">
- <AccordionTrigger className="text-sm font-medium">
- How should I respond?
- </AccordionTrigger>
- <AccordionContent>
- <Alert variant="info" className="flex flex-col gap-4">
- <div>
- <p className="text-xs font-medium text-white">1. False alarm confirmed?</p>
- <p className="text-xs text-accent">
- You might want to <strong>reset the honey token</strong>. This will revert its
- status to active and hide the past events, so that the honey token can be
- triggered again.
- </p>
- </div>
- <div>
- <p className="text-xs font-medium text-white">
- 2. Malicious activity confirmed?
- </p>
- <p className="text-xs text-accent">
- 1. Take immediate steps as per your company Incident Response Plan.
- <br />
- 2. <strong>Rotate any real secrets</strong> that were stored alongside the
- honey token, as they may also be compromised.
- <br />
- 3. <strong>Revoke the honey token</strong>. This will prevent any new
- connections while we keep the compromised key in our records.
- <br />
- 4. Don&apos;t forget to recreate a new honey token to replace it in the same
- location.
- </p>
- </div>
- </Alert>
- </AccordionContent>
- </AccordionItem>
- </Accordion>
- )}
-
<HoneyTokenEventsSection honeyTokenId={honeyTokenId} projectId={projectId} />
</div>
+ {!isRevoked && (
+ <SheetFooter className="shrink-0 items-center border-t">
+ {isTriggered && (
+ <ProjectPermissionCan
+ I={ProjectPermissionHoneyTokenActions.Reset}
+ a={honeyTokenSubject}
+ >
+ {(isAllowed) => (
+ <Button
+ variant="outline"
+ onClick={() => setIsResetOpen(true)}
+ isDisabled={!isAllowed}
+ >
+ <RotateCcw />
+ Reset
+ </Button>
+ )}
+ </ProjectPermissionCan>
+ )}
+ <ProjectPermissionCan I={ProjectPermissionHoneyTokenActions.Revoke} a={honeyTokenSubject}>
+ {(isAllowed) => (
+ <Button
+ className="ml-auto"
+ variant="danger"
+ onClick={() => setIsRevokeOpen(true)}
+ isDisabled={!isAllowed}
+ >
+ <BanIcon />
+ Revoke
+ </Button>
+ )}
+ </ProjectPermissionCan>
+ </SheetFooter>
+ )}
+
<AlertDialog open={isResetOpen} onOpenChange={setIsResetOpen}>
<AlertDialogContent>
<AlertDialogHeader>
@@ -355,7 +321,8 @@ const DrawerContent = ({
<AlertDialogTitle>Reset {honeyToken.name}?</AlertDialogTitle>
<AlertDialogDescription>
This will revert the honey token status to active and hide past events. The honey
- token will be able to trigger again on new activity.
+ token will be able to trigger again on new activity. Its credentials will remain
+ unchanged.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
@@ -371,44 +338,38 @@ const DrawerContent = ({
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
- <AlertDialog open={isRevokeOpen} onOpenChange={setIsRevokeOpen}>
+ <AlertDialog
+ open={isRevokeOpen}
+ confirmationValue={honeyToken.name}
+ onOpenChange={setIsRevokeOpen}
+ >
<AlertDialogContent className="sm:max-w-xl!">
<AlertDialogHeader>
- <AlertDialogMedia>
- <BanIcon />
- </AlertDialogMedia>
<AlertDialogTitle>Are you sure you want to revoke {honeyToken.name}?</AlertDialogTitle>
- <AlertDialogDescription>
- This will revoke the AWS IAM credentials and remove the associated decoy secrets from
- this environment. The honey token record and its events will be preserved for audit
- purposes.
+ <AlertDialogDescription asChild>
+ <Alert variant="danger" appearance="borderless">
+ <AlertDescription>
+ This will revoke the AWS IAM credentials and remove the associated decoy secrets
+ from this environment. The honey token record and its events will be preserved for
+ audit purposes.
+ </AlertDescription>
+ </Alert>
</AlertDialogDescription>
</AlertDialogHeader>
- <form
- onSubmit={(e) => {
- e.preventDefault();
- if (revokeInput === honeyToken.name) handleRevoke();
+ <AlertDialogConfirmationField
+ onConfirm={() => {
+ if (!isRevoking) handleRevoke().catch(() => undefined);
}}
- >
- <Field>
- <FieldLabel>
- Type <span className="font-bold">{honeyToken.name}</span> to confirm
- </FieldLabel>
- <FieldContent>
- <Input
- value={revokeInput}
- onChange={(e) => setRevokeInput(e.target.value)}
- placeholder={`Type ${honeyToken.name} here`}
- />
- </FieldContent>
- </Field>
- </form>
+ />
<AlertDialogFooter>
- <AlertDialogCancel>Cancel</AlertDialogCancel>
+ <AlertDialogCancel isDisabled={isRevoking}>Cancel</AlertDialogCancel>
<AlertDialogAction
variant="danger"
- onClick={handleRevoke}
- disabled={revokeInput !== honeyToken.name}
+ isPending={isRevoking}
+ onClick={(event) => {
+ event.preventDefault();
+ if (!isRevoking) handleRevoke().catch(() => undefined);
+ }}
>
Revoke
</AlertDialogAction>
@@ -429,12 +390,9 @@ export const HoneyTokenDetailsDrawer = ({ projectId, honeyTokenId, onClose }: Pr
if (!open) onClose();
}}
>
- <SheetContent className="flex h-full flex-col gap-y-0 overflow-y-auto sm:max-w-3xl">
- <SheetHeader className="border-b">
- <SheetTitle>Honey Token Details</SheetTitle>
- </SheetHeader>
+ <SheetContent className="flex h-full flex-col gap-y-0 overflow-hidden sm:max-w-3xl">
{isOpen && honeyTokenId && (
- <DrawerContent honeyTokenId={honeyTokenId} projectId={projectId} />
+ <HoneyTokenDetailsContent honeyTokenId={honeyTokenId} projectId={projectId} />
)}
</SheetContent>
</Sheet>
diff --git a/frontend/src/components/honey-tokens/HoneyTokenEventsSection.tsx b/frontend/src/components/honey-tokens/HoneyTokenEventsSection.tsx
index cd0ce67dbc..86fda3303c 100644
--- a/frontend/src/components/honey-tokens/HoneyTokenEventsSection.tsx
+++ b/frontend/src/components/honey-tokens/HoneyTokenEventsSection.tsx
@@ -1,13 +1,17 @@
import { useState } from "react";
import { format, formatDistanceToNow } from "date-fns";
-import { ActivityIcon, Check, ClipboardCopy } from "lucide-react";
+import { ActivityIcon, AlertCircleIcon } from "lucide-react";
import {
+ Alert,
+ AlertDescription,
+ AlertTitle,
Badge,
+ Button,
+ CopyButton,
Empty,
EmptyHeader,
EmptyTitle,
- IconButton,
PageLoader,
Pagination,
Table,
@@ -20,7 +24,6 @@ import {
TooltipContent,
TooltipTrigger
} from "@app/components/v3";
-import { useTimedReset } from "@app/hooks";
import { useGetHoneyTokenEvents } from "@app/hooks/api/honeyTokens/queries";
type Props = {
@@ -31,26 +34,18 @@ type Props = {
const DEFAULT_PER_PAGE = 25;
const UserAgentCell = ({ userAgent }: { userAgent?: string }) => {
- const [, isCopied, setCopied] = useTimedReset<string>({ initialState: "" });
-
if (!userAgent) return <TableCell>—</TableCell>;
return (
<TableCell className="max-w-[150px]" isTruncatable>
<div className="flex items-center gap-1">
<span className="block truncate">{userAgent}</span>
- <IconButton
- variant="ghost"
- size="xs"
- className="shrink-0"
- onClick={() => {
- setCopied(userAgent);
- navigator.clipboard.writeText(userAgent);
- }}
- aria-label="Copy user agent"
- >
- {isCopied ? <Check className="size-3" /> : <ClipboardCopy className="size-3" />}
- </IconButton>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <CopyButton value={userAgent} ariaLabel="Copy user agent" className="shrink-0" />
+ </TooltipTrigger>
+ <TooltipContent>Copy user agent</TooltipContent>
+ </Tooltip>
</div>
</TableCell>
);
@@ -60,7 +55,7 @@ export const HoneyTokenEventsSection = ({ honeyTokenId, projectId }: Props) => {
const [page, setPage] = useState(1);
const [perPage, setPerPage] = useState(DEFAULT_PER_PAGE);
- const { data, isPending } = useGetHoneyTokenEvents({
+ const { data, isError, isPending, refetch } = useGetHoneyTokenEvents({
honeyTokenId,
projectId,
offset: (page - 1) * perPage,
@@ -82,9 +77,27 @@ export const HoneyTokenEventsSection = ({ honeyTokenId, projectId }: Props) => {
)}
</div>
- {isPending && <PageLoader />}
+ {isPending && (
+ <div className="flex min-h-24 items-center justify-center" role="status">
+ <PageLoader />
+ <span className="sr-only">Loading honey token events</span>
+ </div>
+ )}
- {!isPending && (!events || events.length === 0) && (
+ {!isPending && isError && (
+ <Alert variant="danger">
+ <AlertCircleIcon />
+ <AlertTitle>Honey token events could not be loaded</AlertTitle>
+ <AlertDescription>
+ <p>Check your connection and try again.</p>
+ <Button variant="outline" size="sm" onClick={() => refetch()}>
+ Retry
+ </Button>
+ </AlertDescription>
+ </Alert>
+ )}
+
+ {!isPending && !isError && (!events || events.length === 0) && (
<Empty className="border">
<EmptyHeader>
<EmptyTitle>No events recorded yet</EmptyTitle>
@@ -92,7 +105,7 @@ export const HoneyTokenEventsSection = ({ honeyTokenId, projectId }: Props) => {
</Empty>
)}
- {events && events.length > 0 && (
+ {!isPending && !isError && events && events.length > 0 && (
<Table>
<TableHeader>
<TableRow>
@@ -135,18 +148,20 @@ export const HoneyTokenEventsSection = ({ honeyTokenId, projectId }: Props) => {
</Table>
)}
- <Pagination
- count={totalCount}
- page={page}
- perPage={perPage}
- onChangePage={setPage}
- onChangePerPage={(newPerPage) => {
- const totalPages = Math.ceil(totalCount / newPerPage);
- if (page > totalPages) setPage(totalPages);
- setPerPage(newPerPage);
- }}
- perPageList={[25, 50, 100]}
- />
+ {!isPending && !isError && totalCount > 0 && (
+ <Pagination
+ count={totalCount}
+ page={page}
+ perPage={perPage}
+ onChangePage={setPage}
+ onChangePerPage={(newPerPage) => {
+ const totalPages = Math.ceil(totalCount / newPerPage);
+ if (page > totalPages) setPage(totalPages);
+ setPerPage(newPerPage);
+ }}
+ perPageList={[25, 50, 100]}
+ />
+ )}
</div>
);
};
diff --git a/frontend/src/components/honey-tokens/HoneyTokenModalHeader.tsx b/frontend/src/components/honey-tokens/HoneyTokenModalHeader.tsx
index daffc40ea6..fa359c910d 100644
--- a/frontend/src/components/honey-tokens/HoneyTokenModalHeader.tsx
+++ b/frontend/src/components/honey-tokens/HoneyTokenModalHeader.tsx
@@ -1,4 +1,4 @@
-import { DocumentationLinkBadge } from "@app/components/v3";
+import { DocumentationLinkBadge, SheetDescription, SheetTitle } from "@app/components/v3";
import { HONEY_TOKEN_MAP } from "@app/helpers/honeyTokens";
import { HoneyTokenType } from "@app/hooks/api/honeyTokens/enums";
@@ -17,14 +17,14 @@ export const HoneyTokenModalHeader = ({ type, isEdit }: Props) => {
src={`/images/integrations/${details.image}`}
className="h-10 w-10"
/>
- <div>
- <div className="flex items-center gap-x-2 text-mineshaft-300">
+ <div className="flex flex-col gap-1">
+ <SheetTitle className="flex items-center gap-x-2">
{isEdit ? "Edit" : ""} {details.name} Honey Token
<DocumentationLinkBadge href="https://infisical.com/docs/documentation/platform/honey-tokens/overview" />
- </div>
- <p className="text-sm leading-4 text-mineshaft-400">
+ </SheetTitle>
+ <SheetDescription className="leading-4 text-muted">
Plant a decoy credential that alerts on access
- </p>
+ </SheetDescription>
</div>
</div>
);
diff --git a/frontend/src/components/honey-tokens/HoneyTokenSelect.tsx b/frontend/src/components/honey-tokens/HoneyTokenSelect.tsx
index bcbb6c8810..f52cf440b1 100644
--- a/frontend/src/components/honey-tokens/HoneyTokenSelect.tsx
+++ b/frontend/src/components/honey-tokens/HoneyTokenSelect.tsx
@@ -17,25 +17,19 @@ export const HoneyTokenSelect = ({ onSelect }: Props) => {
return (
<Item
+ asChild
key={type}
variant="outline"
className="cursor-pointer flex-col items-center justify-center py-4 hover:bg-foreground/5"
- role="button"
- tabIndex={0}
- onClick={() => onSelect(type)}
- onKeyDown={(e) => {
- if (e.key === "Enter" || e.key === " ") {
- e.preventDefault();
- onSelect(type);
- }
- }}
>
- <ItemMedia variant="image" className="size-12">
- <img src={`/images/integrations/${image}`} width={size} alt={`${name} logo`} />
- </ItemMedia>
- <ItemContent className="items-center">
- <ItemTitle>{name}</ItemTitle>
- </ItemContent>
+ <button type="button" onClick={() => onSelect(type)}>
+ <ItemMedia variant="image" className="size-12">
+ <img src={`/images/integrations/${image}`} width={size} alt="" />
+ </ItemMedia>
+ <ItemContent className="items-center">
+ <ItemTitle>{name}</ItemTitle>
+ </ItemContent>
+ </button>
</Item>
);
})}
diff --git a/frontend/src/components/honey-tokens/RevokeHoneyTokenModal.tsx b/frontend/src/components/honey-tokens/RevokeHoneyTokenModal.tsx
index 72598e44b2..379861539f 100644
--- a/frontend/src/components/honey-tokens/RevokeHoneyTokenModal.tsx
+++ b/frontend/src/components/honey-tokens/RevokeHoneyTokenModal.tsx
@@ -1,21 +1,16 @@
-import { useEffect, useState } from "react";
-import { BanIcon } from "lucide-react";
-
import { createNotification } from "@app/components/notifications";
import {
+ Alert,
+ AlertDescription,
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
+ AlertDialogConfirmationField,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
- AlertDialogMedia,
- AlertDialogTitle,
- Field,
- FieldContent,
- FieldLabel,
- Input
+ AlertDialogTitle
} from "@app/components/v3";
import { useRevokeHoneyToken } from "@app/hooks/api/honeyTokens";
import { TDashboardHoneyToken } from "@app/hooks/api/honeyTokens/types";
@@ -28,11 +23,6 @@ type Props = {
export const RevokeHoneyTokenModal = ({ isOpen, onOpenChange, honeyToken }: Props) => {
const revokeHoneyToken = useRevokeHoneyToken();
- const [inputData, setInputData] = useState("");
-
- useEffect(() => {
- setInputData("");
- }, [isOpen]);
if (!honeyToken) return null;
@@ -51,44 +41,34 @@ export const RevokeHoneyTokenModal = ({ isOpen, onOpenChange, honeyToken }: Prop
};
return (
- <AlertDialog open={isOpen} onOpenChange={onOpenChange}>
+ <AlertDialog open={isOpen} confirmationValue={honeyToken.name} onOpenChange={onOpenChange}>
<AlertDialogContent className="sm:max-w-xl!">
<AlertDialogHeader>
- <AlertDialogMedia>
- <BanIcon />
- </AlertDialogMedia>
<AlertDialogTitle>Are you sure you want to revoke {honeyToken.name}?</AlertDialogTitle>
- <AlertDialogDescription>
- This will revoke the AWS IAM credentials and remove the associated decoy secrets from
- this environment. The honey token record and its events will be preserved for audit
- purposes.
+ <AlertDialogDescription asChild>
+ <Alert variant="danger" appearance="borderless">
+ <AlertDescription>
+ This will revoke the AWS IAM credentials and remove the associated decoy secrets
+ from this environment. The honey token record and its events will be preserved for
+ audit purposes.
+ </AlertDescription>
+ </Alert>
</AlertDialogDescription>
</AlertDialogHeader>
- <form
- onSubmit={(e) => {
- e.preventDefault();
- if (inputData === honeyToken.name) handleRevoke();
+ <AlertDialogConfirmationField
+ onConfirm={() => {
+ if (!revokeHoneyToken.isPending) handleRevoke().catch(() => undefined);
}}
- >
- <Field>
- <FieldLabel>
- Type <span className="font-bold">{honeyToken.name}</span> to confirm
- </FieldLabel>
- <FieldContent>
- <Input
- value={inputData}
- onChange={(e) => setInputData(e.target.value)}
- placeholder={`Type ${honeyToken.name} here`}
- />
- </FieldContent>
- </Field>
- </form>
+ />
<AlertDialogFooter>
- <AlertDialogCancel>Cancel</AlertDialogCancel>
+ <AlertDialogCancel isDisabled={revokeHoneyToken.isPending}>Cancel</AlertDialogCancel>
<AlertDialogAction
variant="danger"
- onClick={handleRevoke}
- disabled={inputData !== honeyToken.name}
+ isPending={revokeHoneyToken.isPending}
+ onClick={(event) => {
+ event.preventDefault();
+ if (!revokeHoneyToken.isPending) handleRevoke().catch(() => undefined);
+ }}
>
Revoke
</AlertDialogAction>
diff --git a/frontend/src/components/honey-tokens/ViewHoneyTokenCredentials/AwsHoneyTokenCredentials.tsx b/frontend/src/components/honey-tokens/ViewHoneyTokenCredentials/AwsHoneyTokenCredentials.tsx
deleted file mode 100644
index 5c5c7b865c..0000000000
--- a/frontend/src/components/honey-tokens/ViewHoneyTokenCredentials/AwsHoneyTokenCredentials.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-import { TAwsHoneyToken } from "@app/hooks/api/honeyTokens/types";
-
-import { CredentialField } from "./CredentialField";
-
-type Props = {
- secretsMapping: TAwsHoneyToken["secretsMapping"];
- credentials: Record<string, string>;
-};
-
-const CREDENTIAL_FIELDS: { key: keyof TAwsHoneyToken["secretsMapping"]; label: string }[] = [
- { key: "accessKeyId", label: "Access Key ID" },
- { key: "secretAccessKey", label: "Secret Access Key" }
-];
-
-export const AwsHoneyTokenCredentials = ({ secretsMapping, credentials }: Props) => {
- return (
- <div className="flex flex-col gap-4">
- {CREDENTIAL_FIELDS.map(({ key, label }) => {
- const secretName = secretsMapping[key];
- const value = (secretName ? credentials[secretName] : undefined) ?? credentials[key];
-
- return <CredentialField key={key} label={label} value={value} />;
- })}
- </div>
- );
-};
diff --git a/frontend/src/components/honey-tokens/ViewHoneyTokenCredentials/CredentialField.tsx b/frontend/src/components/honey-tokens/ViewHoneyTokenCredentials/CredentialField.tsx
index f5b01bdfec..92bc077ced 100644
--- a/frontend/src/components/honey-tokens/ViewHoneyTokenCredentials/CredentialField.tsx
+++ b/frontend/src/components/honey-tokens/ViewHoneyTokenCredentials/CredentialField.tsx
@@ -1,9 +1,16 @@
-import { useReducer } from "react";
-import { faCopy, faEye, faEyeSlash } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
+import { useId, useReducer } from "react";
+import { EyeIcon, EyeOffIcon } from "lucide-react";
-import { Field, FieldContent, FieldLabel, IconButton, Input } from "@app/components/v3";
-import { useTimedReset } from "@app/hooks";
+import {
+ CopyButton,
+ Field,
+ FieldContent,
+ FieldLabel,
+ InputGroup,
+ InputGroupAddon,
+ InputGroupButton,
+ InputGroupInput
+} from "@app/components/v3";
type Props = {
label: string;
@@ -12,40 +19,33 @@ type Props = {
export const CredentialField = ({ label, value }: Props) => {
const [showCredential, toggleShowCredential] = useReducer((prev) => !prev, false);
- const [, isCopied, setCopied] = useTimedReset<boolean>({ initialState: false });
+ const inputId = useId();
if (!value) return null;
return (
<Field>
- <FieldLabel>{label}</FieldLabel>
+ <FieldLabel htmlFor={inputId}>{label}</FieldLabel>
<FieldContent>
<div className="flex items-center gap-2">
- <Input
- value={value}
- type={showCredential ? "text" : "password"}
- readOnly
- className="flex-1 font-mono"
- />
- <IconButton
- aria-label={`${showCredential ? "Hide" : "Show"} ${label}`}
- variant="outline"
- size="md"
- onClick={toggleShowCredential}
- >
- <FontAwesomeIcon icon={showCredential ? faEyeSlash : faEye} />
- </IconButton>
- <IconButton
- aria-label={`Copy ${label}`}
- variant="outline"
- size="md"
- onClick={() => {
- navigator.clipboard.writeText(value);
- setCopied(true);
- }}
- >
- <FontAwesomeIcon icon={faCopy} className={isCopied ? "text-green-500" : ""} />
- </IconButton>
+ <InputGroup className="flex-1">
+ <InputGroupInput
+ id={inputId}
+ value={value}
+ type={showCredential ? "text" : "password"}
+ readOnly
+ className="font-mono"
+ />
+ <InputGroupAddon align="inline-end">
+ <InputGroupButton
+ aria-label={`${showCredential ? "Hide" : "Show"} ${label}`}
+ onClick={toggleShowCredential}
+ >
+ {showCredential ? <EyeOffIcon /> : <EyeIcon />}
+ </InputGroupButton>
+ </InputGroupAddon>
+ </InputGroup>
+ <CopyButton value={value} ariaLabel={`Copy ${label}`} variant="outline" size="md" />
</div>
</FieldContent>
</Field>
diff --git a/frontend/src/components/honey-tokens/ViewHoneyTokenCredentialsModal.tsx b/frontend/src/components/honey-tokens/ViewHoneyTokenCredentialsModal.tsx
deleted file mode 100644
index b937eb27ba..0000000000
--- a/frontend/src/components/honey-tokens/ViewHoneyTokenCredentialsModal.tsx
+++ /dev/null
@@ -1,107 +0,0 @@
-import { ReactNode } from "react";
-import { subject } from "@casl/ability";
-
-import {
- Dialog,
- DialogContent,
- DialogDescription,
- DialogHeader,
- DialogTitle,
- PageLoader
-} from "@app/components/v3";
-import { ProjectPermissionSub, useProjectPermission } from "@app/context";
-import { ProjectPermissionHoneyTokenActions } from "@app/context/ProjectPermissionContext/types";
-import { useGetHoneyTokenCredentials } from "@app/hooks/api/honeyTokens";
-import { HoneyTokenStatus, HoneyTokenType } from "@app/hooks/api/honeyTokens/enums";
-import { TDashboardHoneyToken } from "@app/hooks/api/honeyTokens/types";
-
-import { AwsHoneyTokenCredentials } from "./ViewHoneyTokenCredentials/AwsHoneyTokenCredentials";
-
-type Props = {
- honeyToken?: TDashboardHoneyToken;
- projectId: string;
- isOpen: boolean;
- onOpenChange: (isOpen: boolean) => void;
-};
-
-const renderCredentials = (
- honeyToken: TDashboardHoneyToken,
- credentials: Record<string, string>
-): ReactNode => {
- switch (honeyToken.type) {
- case HoneyTokenType.AWS:
- return (
- <AwsHoneyTokenCredentials
- secretsMapping={honeyToken.secretsMapping}
- credentials={credentials}
- />
- );
- default:
- throw new Error("Unhandled honey token type");
- }
-};
-
-const ModalBody = ({
- honeyToken,
- projectId,
- isOpen
-}: {
- honeyToken?: TDashboardHoneyToken;
- projectId: string;
- isOpen: boolean;
-}) => {
- const { permission } = useProjectPermission();
- const canReadCredentials = honeyToken
- ? permission.can(
- ProjectPermissionHoneyTokenActions.ReadCredentials,
- subject(ProjectPermissionSub.HoneyTokens, {
- environment: honeyToken.environment.slug,
- secretPath: honeyToken.folder.path
- })
- )
- : false;
- const { data: credentials, isPending } = useGetHoneyTokenCredentials({
- honeyTokenId: honeyToken?.id ?? "",
- projectId,
- enabled: isOpen && honeyToken?.status !== HoneyTokenStatus.Revoked && canReadCredentials
- });
-
- if (isPending) {
- return <PageLoader />;
- }
-
- if (!canReadCredentials) {
- return (
- <p className="text-sm text-muted">
- You do not have permission to view honey token credentials.
- </p>
- );
- }
-
- if (credentials && honeyToken) {
- return renderCredentials(honeyToken, credentials);
- }
-
- return <p className="text-sm text-red">No credentials found for this honey token.</p>;
-};
-
-export const ViewHoneyTokenCredentialsModal = ({
- honeyToken,
- projectId,
- isOpen,
- onOpenChange
-}: Props) => {
- return (
- <Dialog open={isOpen} onOpenChange={onOpenChange}>
- <DialogContent className="max-w-2xl" onOpenAutoFocus={(e) => e.preventDefault()}>
- <DialogHeader>
- <DialogTitle>Honey Token Credentials</DialogTitle>
- {honeyToken && (
- <DialogDescription>Credentials for &quot;{honeyToken.name}&quot;.</DialogDescription>
- )}
- </DialogHeader>
- <ModalBody honeyToken={honeyToken} projectId={projectId} isOpen={isOpen} />
- </DialogContent>
- </Dialog>
- );
-};
diff --git a/frontend/src/components/honey-tokens/forms/HoneyTokenConfigurationFields.tsx b/frontend/src/components/honey-tokens/forms/HoneyTokenConfigurationFields.tsx
index ee3512dd0f..f91b95e44b 100644
--- a/frontend/src/components/honey-tokens/forms/HoneyTokenConfigurationFields.tsx
+++ b/frontend/src/components/honey-tokens/forms/HoneyTokenConfigurationFields.tsx
@@ -10,34 +10,37 @@ type Props = {
};
export const HoneyTokenConfigurationFields = ({ environments }: Props) => {
- const { control } = useFormContext<THoneyTokenForm>();
+ const { control, setValue } = useFormContext<THoneyTokenForm>();
return (
- <>
- <p className="mb-4 text-sm text-bunker-300">Select where to plant the honey token secrets.</p>
- {environments && (
- <Controller
- control={control}
- name="environment"
- render={({ field: { value, onChange }, fieldState: { error } }) => (
- <Field>
- <FieldLabel>Environment</FieldLabel>
- <FieldContent>
- <FilterableSelect
- value={value}
- onChange={onChange}
- options={environments}
- placeholder="Select an environment..."
- getOptionLabel={(option) => option?.name}
- getOptionValue={(option) => option?.id}
- isError={Boolean(error)}
- />
- </FieldContent>
- {error && <FieldError>{error.message}</FieldError>}
- </Field>
- )}
- />
- )}
- </>
+ environments && (
+ <Controller
+ control={control}
+ name="environment"
+ render={({ field: { value }, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel>Environment</FieldLabel>
+ <FieldContent>
+ <FilterableSelect
+ value={value}
+ onChange={(environment) =>
+ setValue("environment", environment as ProjectEnv, {
+ shouldDirty: true,
+ shouldTouch: true,
+ shouldValidate: true
+ })
+ }
+ options={environments}
+ placeholder="Select an environment..."
+ getOptionLabel={(option) => option?.name}
+ getOptionValue={(option) => option?.id}
+ isError={Boolean(error)}
+ />
+ </FieldContent>
+ {error && <FieldError>{error.message}</FieldError>}
+ </Field>
+ )}
+ />
+ )
);
};
diff --git a/frontend/src/components/honey-tokens/forms/HoneyTokenDetailsFields.tsx b/frontend/src/components/honey-tokens/forms/HoneyTokenDetailsFields.tsx
index 57fbe55bf3..6a2cbe3a01 100644
--- a/frontend/src/components/honey-tokens/forms/HoneyTokenDetailsFields.tsx
+++ b/frontend/src/components/honey-tokens/forms/HoneyTokenDetailsFields.tsx
@@ -1,14 +1,6 @@
import { Controller, useFormContext } from "react-hook-form";
-import {
- Field,
- FieldContent,
- FieldDescription,
- FieldError,
- FieldLabel,
- Input,
- TextArea
-} from "@app/components/v3";
+import { Field, FieldContent, FieldError, FieldLabel, Input, TextArea } from "@app/components/v3";
import { THoneyTokenForm } from "./schemas";
@@ -17,9 +9,6 @@ export const HoneyTokenDetailsFields = () => {
return (
<div className="flex flex-col gap-4">
- <p className="text-sm text-bunker-300">
- Provide a name and description for this honey token.
- </p>
<Controller
render={({ field: { value, onChange }, fieldState: { error } }) => (
<Field>
@@ -32,11 +21,7 @@ export const HoneyTokenDetailsFields = () => {
placeholder="aws-canary-prod-key"
isError={Boolean(error)}
/>
- {error ? (
- <FieldError>{error.message}</FieldError>
- ) : (
- <FieldDescription>Must be slug-friendly</FieldDescription>
- )}
+ {error && <FieldError>{error.message}</FieldError>}
</FieldContent>
</Field>
)}
diff --git a/frontend/src/components/honey-tokens/forms/HoneyTokenForm.tsx b/frontend/src/components/honey-tokens/forms/HoneyTokenForm.tsx
index a340ca4f6d..cdd0f7498b 100644
--- a/frontend/src/components/honey-tokens/forms/HoneyTokenForm.tsx
+++ b/frontend/src/components/honey-tokens/forms/HoneyTokenForm.tsx
@@ -1,11 +1,10 @@
import { useState } from "react";
import { FormProvider, useForm } from "react-hook-form";
-import { Tab } from "@headlessui/react";
import { zodResolver } from "@hookform/resolvers/zod";
import { Link } from "@tanstack/react-router";
import { createNotification } from "@app/components/notifications";
-import { Button } from "@app/components/v3";
+import { Button, SheetFooter, Stepper, StepperList, StepperStep } from "@app/components/v3";
import { ROUTE_PATHS } from "@app/const/routes";
import { useOrganization, useProject } from "@app/context";
import { HONEY_TOKEN_DEFAULT_SECRET_NAMES, HONEY_TOKEN_MAP } from "@app/helpers/honeyTokens";
@@ -30,14 +29,40 @@ type Props = {
honeyToken?: TDashboardHoneyToken;
};
-const FORM_TABS: { name: string; key: string; fields: (keyof THoneyTokenForm)[] }[] = [
+type FormTab = {
+ name: string;
+ key: string;
+ shortDescription: string;
+ title: string;
+ subtitle: string;
+ fields: (keyof THoneyTokenForm)[];
+};
+
+const FORM_TABS: FormTab[] = [
{
name: "Configuration",
key: "configuration",
+ shortDescription: "Environment",
+ title: "Choose where to plant it",
+ subtitle: "Select the environment where Infisical should store the decoy credentials.",
fields: ["environment"]
},
- { name: "Mapping", key: "mapping", fields: ["secretsMapping"] },
- { name: "Details", key: "details", fields: ["name", "description"] }
+ {
+ name: "Mapping",
+ key: "mapping",
+ shortDescription: "Secret keys",
+ title: "Map the generated credentials",
+ subtitle: "Choose the secret keys that will receive each decoy credential field.",
+ fields: ["secretsMapping"]
+ },
+ {
+ name: "Details",
+ key: "details",
+ shortDescription: "Name and description",
+ title: "Add honey token details",
+ subtitle: "Give this honey token a clear name and an optional description.",
+ fields: ["name", "description"]
+ }
];
export const HoneyTokenForm = ({
@@ -108,7 +133,7 @@ export const HoneyTokenForm = ({
: "Token was created, but stack is not deployed yet.",
callToAction: (
<Link
- className="inline-flex h-7 items-center rounded border border-mineshaft-500 px-2 text-xs text-primary transition-colors hover:bg-mineshaft-700 hover:text-primary"
+ className="inline-flex h-7 items-center rounded border border-border px-2 text-xs text-foreground transition-colors hover:bg-container-hover"
to={ROUTE_PATHS.Organization.SettingsPage.path}
params={{ orgId: currentOrg.id }}
search={{ selectedTab: "product-settings" }}
@@ -224,61 +249,90 @@ export const HoneyTokenForm = ({
return isEnabled;
};
+ const handleStepChange = (index: number) => {
+ isTabEnabled(index).then((isEnabled) => {
+ if (isEnabled) setSelectedTabIndex(index);
+ });
+ };
+
+ const currentStep = formTabs[selectedTabIndex];
+
+ const formFields = (
+ <>
+ {currentStep.key === "configuration" && (
+ <HoneyTokenConfigurationFields environments={environments} />
+ )}
+ {currentStep.key === "mapping" && <HoneyTokenMappingFields />}
+ {currentStep.key === "details" && <HoneyTokenDetailsFields />}
+ </>
+ );
+
+ const displayedStepNumber = selectedTabIndex + 1;
+ const totalSteps = formTabs.length;
+
return (
- <form className="flex max-h-[75vh] flex-col">
- <div className="min-h-0 flex-1">
- <FormProvider {...formMethods}>
- <Tab.Group selectedIndex={selectedTabIndex} onChange={setSelectedTabIndex}>
- <Tab.List className="-pb-1 mb-6 w-full border-b-2 border-mineshaft-600">
- {formTabs.map((tab, index) => (
- <Tab
- onClick={async (e) => {
- e.preventDefault();
- const isEnabled = await isTabEnabled(index);
- setSelectedTabIndex((prev) => (isEnabled ? index : prev));
- }}
- className={({ selected }) =>
- `-mb-[0.14rem] whitespace-nowrap ${index > selectedTabIndex ? "opacity-30" : ""} px-4 py-2 text-sm font-medium outline-hidden disabled:opacity-60 ${
- selected
- ? "border-b-2 border-mineshaft-300 text-mineshaft-200"
- : "text-bunker-300"
- }`
- }
- key={tab.key}
- >
- {index + 1}. {tab.name}
- </Tab>
- ))}
- </Tab.List>
- <Tab.Panels>
- {!isUpdate && (
- <Tab.Panel>
- <HoneyTokenConfigurationFields environments={environments} />
- </Tab.Panel>
- )}
- <Tab.Panel>
- <HoneyTokenMappingFields />
- </Tab.Panel>
- <Tab.Panel>
- <HoneyTokenDetailsFields />
- </Tab.Panel>
- </Tab.Panels>
- </Tab.Group>
- </FormProvider>
- </div>
- <div className="flex w-full flex-shrink-0 flex-row-reverse justify-between gap-4 pt-4">
- <Button
- onClick={handleNext}
- isPending={isSubmitting || isValidating}
- isDisabled={isSubmitting || isValidating}
- variant={isFinalStep ? "org" : "outline"}
- >
- {isFinalStep ? `${honeyToken ? "Update" : "Create"} Honey Token` : "Next"}
- </Button>
- <Button onClick={handlePrev} variant="outline">
- Back
- </Button>
- </div>
- </form>
+ <FormProvider {...formMethods}>
+ <form className="flex min-h-0 flex-1 flex-col" onSubmit={(event) => event.preventDefault()}>
+ <div className="flex min-h-0 flex-1 overflow-hidden">
+ <aside className="hidden w-60 shrink-0 flex-col border-r border-border px-5 py-6 md:flex">
+ <p className="mb-5 text-[11px] font-medium tracking-wider text-muted uppercase">
+ Setup steps
+ </p>
+ <Stepper
+ activeStep={selectedTabIndex}
+ orientation="vertical"
+ onStepChange={handleStepChange}
+ nonLinear
+ >
+ <StepperList aria-label="Honey token setup progress">
+ {formTabs.map((tab, index) => (
+ <StepperStep
+ key={tab.key}
+ index={index}
+ title={tab.name}
+ description={tab.shortDescription}
+ disabled={isSubmitting || isValidating}
+ />
+ ))}
+ </StepperList>
+ </Stepper>
+ </aside>
+
+ <div className="flex min-w-0 flex-1 flex-col overflow-y-auto">
+ <div className="border-b border-border px-4 py-4 md:hidden">
+ <p className="text-xs font-medium text-muted">
+ Step {displayedStepNumber} of {totalSteps}: {currentStep.name}
+ </p>
+ </div>
+ <div className="flex w-full max-w-3xl flex-col gap-y-2 px-4 py-6 md:px-8">
+ <div className="mb-6">
+ <h2 className="text-lg font-semibold text-foreground">{currentStep.title}</h2>
+ <p className="mt-1 text-sm text-muted">{currentStep.subtitle}</p>
+ </div>
+ {formFields}
+ </div>
+ </div>
+ </div>
+ </form>
+ <SheetFooter className="flex-col items-stretch border-t sm:flex-row sm:items-center sm:justify-between">
+ <span className="text-xs text-muted">
+ Step {displayedStepNumber} of {totalSteps}
+ </span>
+ <div className="flex flex-col-reverse gap-3 sm:flex-row sm:items-center">
+ <Button className="w-full sm:w-fit" onClick={handlePrev} variant="outline">
+ Back
+ </Button>
+ <Button
+ onClick={handleNext}
+ isPending={isSubmitting || isValidating}
+ isDisabled={isSubmitting || isValidating}
+ className="w-full sm:w-fit"
+ variant={isFinalStep ? "org" : "outline"}
+ >
+ {isFinalStep ? `${honeyToken ? "Update" : "Create"} Honey Token` : "Next"}
+ </Button>
+ </div>
+ </SheetFooter>
+ </FormProvider>
);
};
diff --git a/frontend/src/components/honey-tokens/forms/HoneyTokenMappingFields/AwsHoneyTokenMappingFields.tsx b/frontend/src/components/honey-tokens/forms/HoneyTokenMappingFields/AwsHoneyTokenMappingFields.tsx
index fc2000b803..8b6ef92ffa 100644
--- a/frontend/src/components/honey-tokens/forms/HoneyTokenMappingFields/AwsHoneyTokenMappingFields.tsx
+++ b/frontend/src/components/honey-tokens/forms/HoneyTokenMappingFields/AwsHoneyTokenMappingFields.tsx
@@ -1,11 +1,20 @@
+import { useId } from "react";
import { Controller, useFormContext } from "react-hook-form";
import { ArrowRightIcon, InfoIcon, KeyIcon, LockIcon } from "lucide-react";
import {
+ Alert,
+ AlertDescription,
Badge,
+ Field,
FieldError,
FieldLabel,
- Input,
+ FieldLegend,
+ FieldSet,
+ IconButton,
+ InputGroup,
+ InputGroupAddon,
+ InputGroupInput,
Tooltip,
TooltipContent,
TooltipTrigger
@@ -16,6 +25,7 @@ import { HoneyTokenType } from "@app/hooks/api/honeyTokens/enums";
import { THoneyTokenForm } from "../schemas";
export const AwsHoneyTokenMappingFields = () => {
+ const fieldIdPrefix = useId();
const {
control,
formState: { errors }
@@ -27,12 +37,14 @@ export const AwsHoneyTokenMappingFields = () => {
const items = [
{
+ id: "access-key-id",
name: "Access Key ID",
icon: <KeyIcon />,
fieldName: "secretsMapping.accessKeyId" as const,
placeholder: defaults.accessKeyId
},
{
+ id: "secret-access-key",
name: "Secret Access Key",
icon: <LockIcon />,
fieldName: "secretsMapping.secretAccessKey" as const,
@@ -41,82 +53,76 @@ export const AwsHoneyTokenMappingFields = () => {
];
return (
- <div className="w-full overflow-hidden">
- <table className="w-full table-auto">
- <thead>
- <tr className="text-left">
- <th className="pb-3 whitespace-nowrap">
- <FieldLabel>Decoy Credential</FieldLabel>
- </th>
- <th className="pb-3" />
- <th className="pb-3">
- <FieldLabel>
- Secret Name
- <Tooltip>
- <TooltipTrigger asChild>
- <InfoIcon className="size-3.5 text-muted" />
- </TooltipTrigger>
- <TooltipContent className="max-w-sm">
- The name of the secret that the decoy credential will be mapped to in your
- project.
- </TooltipContent>
- </Tooltip>
- </FieldLabel>
- </th>
- </tr>
- </thead>
- <tbody>
- {items.map(({ name, icon, fieldName, placeholder }) => (
- <tr key={name}>
- <td className="pb-4 align-top whitespace-nowrap">
- <Badge variant="neutral" className="h-9 w-full justify-center text-xs">
- {icon}
- {name}
- </Badge>
- </td>
- <td className="px-5 pb-4 align-top">
- <div className="flex h-9 items-center">
- <ArrowRightIcon className="size-5 text-accent" />
- </div>
- </td>
- <td className="w-full pb-4 align-top">
- <Controller
- render={({ field: { value, onChange }, fieldState: { error } }) => (
- <div>
- <div className="relative">
- <Input
- value={value}
- onChange={onChange}
- placeholder={placeholder}
- isError={Boolean(error)}
- />
- <span className="pointer-events-none absolute top-1/2 right-2 -translate-y-1/2">
- <Badge variant="warning" className="text-[10px]">
- Decoy
- </Badge>
- </span>
- </div>
- {error && <FieldError>{error.message}</FieldError>}
- </div>
- )}
- control={control}
- name={fieldName}
- />
- </td>
- </tr>
- ))}
- </tbody>
- </table>
- {mappingError && (
- <div className="mt-2 rounded-sm border border-red/40 bg-red/10 p-3 text-xs text-mineshaft-200">
- {mappingError}
+ <FieldSet className="@container">
+ <FieldLegend className="sr-only">Honey token secret mappings</FieldLegend>
+ <div className="grid min-w-0 grid-cols-1 gap-x-4 gap-y-2 @lg:grid-cols-[minmax(10rem,auto)_1.25rem_minmax(0,1fr)] @lg:gap-y-1">
+ <span className="hidden items-center text-xs font-medium text-accent @lg:flex">
+ Decoy credential
+ </span>
+ <span className="hidden @lg:block" />
+ <div className="hidden items-center gap-1 @lg:flex">
+ <span className="text-xs font-medium text-accent">Secret name</span>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <IconButton variant="ghost-muted" size="xs" aria-label="About secret names">
+ <InfoIcon />
+ </IconButton>
+ </TooltipTrigger>
+ <TooltipContent className="max-w-sm">
+ The name of the secret that the decoy credential will be mapped to in your project.
+ </TooltipContent>
+ </Tooltip>
</div>
- )}
- <div className="mt-2 flex items-start gap-2 rounded-sm border border-info/40 bg-info/10 p-3 text-xs text-mineshaft-200">
- <InfoIcon className="mt-0.5 size-3.5 shrink-0 text-info" />
- These keys will appear as normal secrets in your project but are tied to a sandboxed IAM
- user with zero permissions. Any API call made with these credentials triggers an alert.
+ {items.map(({ id, name, icon, fieldName, placeholder }) => (
+ <Controller
+ key={fieldName}
+ render={({ field, fieldState: { error } }) => {
+ const inputId = `${fieldIdPrefix}-${id}`;
+ const errorId = `${inputId}-error`;
+
+ return (
+ <>
+ <Badge variant="neutral" isFullWidth className="h-9 text-xs">
+ {icon}
+ {name}
+ </Badge>
+ <div className="flex h-5 items-center justify-center @lg:h-9">
+ <ArrowRightIcon className="size-5 rotate-90 text-accent @lg:rotate-0" />
+ </div>
+ <Field data-invalid={Boolean(error)}>
+ <FieldLabel htmlFor={inputId} className="@lg:sr-only">
+ Secret name for {name}
+ </FieldLabel>
+ <InputGroup>
+ <InputGroupInput
+ {...field}
+ id={inputId}
+ placeholder={placeholder}
+ isError={Boolean(error)}
+ aria-describedby={error ? errorId : undefined}
+ />
+ <InputGroupAddon align="inline-end">
+ <Badge variant="warning">Decoy</Badge>
+ </InputGroupAddon>
+ </InputGroup>
+ <FieldError id={errorId}>{error?.message}</FieldError>
+ </Field>
+ </>
+ );
+ }}
+ control={control}
+ name={fieldName}
+ />
+ ))}
</div>
- </div>
+ <FieldError>{mappingError}</FieldError>
+ <Alert variant="info">
+ <InfoIcon />
+ <AlertDescription>
+ These keys will appear as normal secrets in your project but are tied to a sandboxed IAM
+ user with zero permissions. Any API call made with these credentials triggers an alert.
+ </AlertDescription>
+ </Alert>
+ </FieldSet>
);
};
diff --git a/frontend/src/components/honey-tokens/forms/HoneyTokenMappingFields/HoneyTokenMappingFields.tsx b/frontend/src/components/honey-tokens/forms/HoneyTokenMappingFields/HoneyTokenMappingFields.tsx
index 7e5e4dc161..f7dcd141f5 100644
--- a/frontend/src/components/honey-tokens/forms/HoneyTokenMappingFields/HoneyTokenMappingFields.tsx
+++ b/frontend/src/components/honey-tokens/forms/HoneyTokenMappingFields/HoneyTokenMappingFields.tsx
@@ -16,12 +16,5 @@ export const HoneyTokenMappingFields = () => {
const Component = COMPONENT_MAP[honeyTokenType];
- return (
- <>
- <p className="mb-4 text-sm text-bunker-300">
- Map the decoy credential&apos;s fields to secrets in your Infisical project.
- </p>
- <Component />
- </>
- );
+ return <Component />;
};
diff --git a/frontend/src/components/honey-tokens/forms/HoneyTokenParametersFields/AwsHoneyTokenParametersFields.tsx b/frontend/src/components/honey-tokens/forms/HoneyTokenParametersFields/AwsHoneyTokenParametersFields.tsx
index f58b9efb6b..57dcd2de04 100644
--- a/frontend/src/components/honey-tokens/forms/HoneyTokenParametersFields/AwsHoneyTokenParametersFields.tsx
+++ b/frontend/src/components/honey-tokens/forms/HoneyTokenParametersFields/AwsHoneyTokenParametersFields.tsx
@@ -1,6 +1,6 @@
export const AwsHoneyTokenParametersFields = () => {
return (
- <p className="text-sm text-bunker-300">
+ <p className="text-sm text-muted">
No additional parameters are required for AWS Honey Tokens. The decoy IAM credentials will be
generated automatically.
</p>
diff --git a/frontend/src/components/honey-tokens/forms/HoneyTokenParametersFields/HoneyTokenParametersFields.tsx b/frontend/src/components/honey-tokens/forms/HoneyTokenParametersFields/HoneyTokenParametersFields.tsx
index c359e9488c..66c87339f4 100644
--- a/frontend/src/components/honey-tokens/forms/HoneyTokenParametersFields/HoneyTokenParametersFields.tsx
+++ b/frontend/src/components/honey-tokens/forms/HoneyTokenParametersFields/HoneyTokenParametersFields.tsx
@@ -18,7 +18,7 @@ export const HoneyTokenParametersFields = () => {
return (
<>
- <p className="mb-4 text-sm text-bunker-300">
+ <p className="mb-4 text-sm text-muted">
Configure the required parameters for this Honey Token.
</p>
<Component />
diff --git a/frontend/src/components/honey-tokens/forms/HoneyTokenReviewFields/HoneyTokenReviewSection.tsx b/frontend/src/components/honey-tokens/forms/HoneyTokenReviewFields/HoneyTokenReviewSection.tsx
index 663f3e1db3..04bc11fba4 100644
--- a/frontend/src/components/honey-tokens/forms/HoneyTokenReviewFields/HoneyTokenReviewSection.tsx
+++ b/frontend/src/components/honey-tokens/forms/HoneyTokenReviewFields/HoneyTokenReviewSection.tsx
@@ -8,8 +8,8 @@ type Props = {
export const HoneyTokenReviewSection = ({ label, children }: Props) => {
return (
<div className="flex flex-col gap-3">
- <div className="w-full border-b border-mineshaft-600">
- <span className="text-sm text-mineshaft-300">{label}</span>
+ <div className="w-full border-b border-border">
+ <span className="text-sm text-muted">{label}</span>
</div>
<div className="flex flex-wrap gap-x-8 gap-y-2">{children}</div>
</div>
diff --git a/frontend/src/components/honey-tokens/index.ts b/frontend/src/components/honey-tokens/index.ts
index 490e13dd17..ad990f627d 100644
--- a/frontend/src/components/honey-tokens/index.ts
+++ b/frontend/src/components/honey-tokens/index.ts
@@ -2,4 +2,3 @@ export * from "./CreateHoneyTokenModal";
export * from "./EditHoneyTokenModal";
export * from "./HoneyTokenDetailsDrawer";
export * from "./RevokeHoneyTokenModal";
-export * from "./ViewHoneyTokenCredentialsModal";
diff --git a/frontend/src/components/v3/generic/Badge/Badge.tsx b/frontend/src/components/v3/generic/Badge/Badge.tsx
index d6883dc445..7bd2f1f913 100644
--- a/frontend/src/components/v3/generic/Badge/Badge.tsx
+++ b/frontend/src/components/v3/generic/Badge/Badge.tsx
@@ -31,7 +31,8 @@ const badgeVariants = cva(
variant: {
ghost: "text-foreground border-none [a&,button&]:hover:bg-foreground/10",
default: "bg-label text-background border-label [a&,button&]:hover:bg-primary/35",
- outline: "text-label border-label border",
+ outline: "border border-border text-muted",
+ shaded: "bg-border text-foreground/60 border-none",
neutral: "bg-neutral/15 border-neutral/10 text-neutral [a&,button&]:hover:bg-neutral/35",
success: "bg-success/15 border-success/10 text-success [a&,button&]:hover:bg-success/35",
info: "bg-info/15 border-info/10 border text-info [a&,button&]:hover:bg-info/35",
diff --git a/frontend/src/components/v3/generic/CopyButton/CopyButton.tsx b/frontend/src/components/v3/generic/CopyButton/CopyButton.tsx
index 7058e819bb..e2c3ea2c42 100644
--- a/frontend/src/components/v3/generic/CopyButton/CopyButton.tsx
+++ b/frontend/src/components/v3/generic/CopyButton/CopyButton.tsx
@@ -1,38 +1,38 @@
-import { ComponentProps } from "react";
+import { ComponentProps, forwardRef } from "react";
import { Check, Copy } from "lucide-react";
import { useTimedReset } from "@app/hooks";
import { IconButton } from "../IconButton";
-type CopyButtonProps = {
+type CopyButtonProps = Omit<ComponentProps<"button">, "value" | "children"> & {
value: string;
ariaLabel: string;
-} & Pick<ComponentProps<typeof IconButton>, "variant" | "size" | "className">;
+} & Pick<ComponentProps<typeof IconButton>, "variant" | "size">;
-export const CopyButton = ({
- value,
- ariaLabel,
- variant = "ghost",
- size = "xs",
- className
-}: CopyButtonProps) => {
- const [, isCopying, setCopyText] = useTimedReset<string>({
- initialState: "Copy to clipboard"
- });
+export const CopyButton = forwardRef<HTMLButtonElement, CopyButtonProps>(
+ ({ value, ariaLabel, variant = "ghost", size = "xs", onClick, ...props }, ref): JSX.Element => {
+ const [, isCopying, setCopyText] = useTimedReset<string>({
+ initialState: "Copy to clipboard"
+ });
- return (
- <IconButton
- variant={variant}
- size={size}
- className={className}
- aria-label={ariaLabel}
- onClick={() => {
- navigator.clipboard.writeText(value);
- setCopyText("Copied");
- }}
- >
- {isCopying ? <Check /> : <Copy />}
- </IconButton>
- );
-};
+ return (
+ <IconButton
+ {...props}
+ ref={ref}
+ variant={variant}
+ size={size}
+ aria-label={ariaLabel}
+ onClick={(event) => {
+ navigator.clipboard.writeText(value);
+ setCopyText("Copied");
+ onClick?.(event);
+ }}
+ >
+ {isCopying ? <Check /> : <Copy />}
+ </IconButton>
+ );
+ }
+);
+
+CopyButton.displayName = "CopyButton";
diff --git a/frontend/src/components/v3/generic/Dropdown/Dropdown.stories.tsx b/frontend/src/components/v3/generic/Dropdown/Dropdown.stories.tsx
index 5e7d8905d3..9a4e2c3c35 100644
--- a/frontend/src/components/v3/generic/Dropdown/Dropdown.stories.tsx
+++ b/frontend/src/components/v3/generic/Dropdown/Dropdown.stories.tsx
@@ -37,7 +37,8 @@ import {
* DropdownMenu renders a contextual menu that opens from a trigger — use it for
* row / card actions, segmented triggers, and any grouped list of actions that
* don't warrant a dedicated panel. Composable subcomponents cover labels,
- * separators, shortcuts, checkbox / radio items, and nested submenus.
+ * separators, shortcuts, checkbox / radio items, and nested submenus. Menu
+ * content and nested submenus preserve an 8px viewport gutter by default.
*/
const meta = {
title: "Generic/Dropdown",
diff --git a/frontend/src/components/v3/generic/Dropdown/Dropdown.tsx b/frontend/src/components/v3/generic/Dropdown/Dropdown.tsx
index 55ce7b2d55..3837a06848 100644
--- a/frontend/src/components/v3/generic/Dropdown/Dropdown.tsx
+++ b/frontend/src/components/v3/generic/Dropdown/Dropdown.tsx
@@ -26,6 +26,7 @@ const DropdownMenuTrigger = React.forwardRef<
function DropdownMenuContent({
className,
sideOffset = 4,
+ collisionPadding = 8,
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.Content>) {
return (
@@ -33,6 +34,7 @@ function DropdownMenuContent({
<DropdownMenuPrimitive.Content
data-slot="dropdown-menu-content"
sideOffset={sideOffset}
+ collisionPadding={collisionPadding}
className={cn(
"max-h-(--radix-dropdown-menu-content-available-height) origin-(--radix-dropdown-menu-content-transform-origin)",
"data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
@@ -217,6 +219,7 @@ function DropdownMenuSubTrigger({
function DropdownMenuSubContent({
className,
sideOffset = 8,
+ collisionPadding = 8,
...props
}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {
return (
@@ -227,6 +230,7 @@ function DropdownMenuSubContent({
className
)}
sideOffset={sideOffset}
+ collisionPadding={collisionPadding}
{...props}
/>
);
diff --git a/frontend/src/components/v3/generic/HoverCard/HoverCard.stories.tsx b/frontend/src/components/v3/generic/HoverCard/HoverCard.stories.tsx
index c6dc173259..b4e26c7476 100644
--- a/frontend/src/components/v3/generic/HoverCard/HoverCard.stories.tsx
+++ b/frontend/src/components/v3/generic/HoverCard/HoverCard.stories.tsx
@@ -18,7 +18,8 @@ import { HoverCard, HoverCardContent, HoverCardTrigger } from "./HoverCard";
* forward props onto an inline link, badge, or button rather than rendering
* an extra wrapper.
* - `HoverCardContent` — the floating panel. Accepts `align`, `side`, and
- * `sideOffset`, just like `Popover`.
+ * `sideOffset`, just like `Popover`, and preserves an 8px viewport gutter
+ * by default.
*
* **Don't** put interactive controls (form fields, primary actions) inside a
* hover card — the hover-then-click flow is fragile, and the panel is
diff --git a/frontend/src/components/v3/generic/HoverCard/HoverCard.tsx b/frontend/src/components/v3/generic/HoverCard/HoverCard.tsx
index 046400cb14..0edb6d69d0 100644
--- a/frontend/src/components/v3/generic/HoverCard/HoverCard.tsx
+++ b/frontend/src/components/v3/generic/HoverCard/HoverCard.tsx
@@ -15,6 +15,7 @@ function HoverCardContent({
className,
align = "center",
sideOffset = 4,
+ collisionPadding = 8,
...props
}: React.ComponentProps<typeof HoverCardPrimitive.Content>) {
return (
@@ -23,6 +24,7 @@ function HoverCardContent({
data-slot="hover-card-content"
align={align}
sideOffset={sideOffset}
+ collisionPadding={collisionPadding}
className={cn(
"z-50 w-64 origin-(--radix-hover-card-content-transform-origin) rounded-lg bg-popover p-2.5",
"border border-border text-sm text-foreground/90 shadow-md outline-hidden",
diff --git a/frontend/src/components/v3/generic/Select/Select.stories.tsx b/frontend/src/components/v3/generic/Select/Select.stories.tsx
index 03407bd95e..7e248284e5 100644
--- a/frontend/src/components/v3/generic/Select/Select.stories.tsx
+++ b/frontend/src/components/v3/generic/Select/Select.stories.tsx
@@ -21,6 +21,8 @@ import {
* `SelectTrigger` (the clickable surface, contains a `SelectValue`) →
* `SelectContent` (the portalled menu) → `SelectItem`s, optionally grouped with
* `SelectGroup` + `SelectLabel` and divided with `SelectSeparator`.
+ * Popper-positioned `SelectContent` preserves an 8px viewport gutter by
+ * default. Radix's item-aligned mode retains its built-in 10px viewport margin.
*
* The trigger sizes to its content by default — let the parent container
* (`Field`, a sidebar, a toolbar) decide width via layout constraints. For
diff --git a/frontend/src/components/v3/generic/Select/Select.tsx b/frontend/src/components/v3/generic/Select/Select.tsx
index 576f02c798..d1e69f7a5a 100644
--- a/frontend/src/components/v3/generic/Select/Select.tsx
+++ b/frontend/src/components/v3/generic/Select/Select.tsx
@@ -112,6 +112,7 @@ function SelectContent({
children,
position = "item-aligned",
align = "center",
+ collisionPadding = 8,
...props
}: React.ComponentProps<typeof SelectPrimitive.Content>) {
return (
@@ -127,6 +128,7 @@ function SelectContent({
)}
position={position}
align={align}
+ collisionPadding={collisionPadding}
{...props}
>
<SelectScrollUpButton />
diff --git a/frontend/src/components/v3/generic/Table/Table.tsx b/frontend/src/components/v3/generic/Table/Table.tsx
index 91f33b9b91..08461e74aa 100644
--- a/frontend/src/components/v3/generic/Table/Table.tsx
+++ b/frontend/src/components/v3/generic/Table/Table.tsx
@@ -68,7 +68,7 @@ const TableRow = React.forwardRef<HTMLTableRowElement, React.ComponentProps<"tr"
data-slot="table-row"
className={cn(
"border-b border-border transition-colors duration-75 hover:bg-container-hover data-[state=selected]:bg-container-hover",
- props.onClick && "cursor-pointer",
+ props.onClick && "cursor-pointer select-none",
className
)}
{...props}
diff --git a/frontend/src/components/v3/generic/Tooltip/Tooltip.stories.tsx b/frontend/src/components/v3/generic/Tooltip/Tooltip.stories.tsx
index 4130eb072a..d02e9b4c54 100644
--- a/frontend/src/components/v3/generic/Tooltip/Tooltip.stories.tsx
+++ b/frontend/src/components/v3/generic/Tooltip/Tooltip.stories.tsx
@@ -22,7 +22,8 @@ import { Tooltip, TooltipContent, TooltipTrigger } from "./Tooltip";
* content disappears the moment the cursor leaves the trigger, so any link or
* action inside is fragile; `HoverCard` keeps the panel open as the cursor
* moves into it. Reach for `Popover` instead when the user must click to
- * commit an interaction (forms, pickers, action menus).
+ * commit an interaction (forms, pickers, action menus). Tooltip content
+ * preserves an 8px viewport gutter by default.
*/
const meta = {
title: "Generic/Tooltip",
diff --git a/frontend/src/components/v3/generic/Tooltip/Tooltip.tsx b/frontend/src/components/v3/generic/Tooltip/Tooltip.tsx
index ad2dacce04..4404ba80ef 100644
--- a/frontend/src/components/v3/generic/Tooltip/Tooltip.tsx
+++ b/frontend/src/components/v3/generic/Tooltip/Tooltip.tsx
@@ -33,6 +33,7 @@ function TooltipTrigger({ ...props }: React.ComponentProps<typeof TooltipPrimiti
function TooltipContent({
className,
sideOffset = 0,
+ collisionPadding = 8,
children,
...props
}: React.ComponentProps<typeof TooltipPrimitive.Content>) {
@@ -41,6 +42,7 @@ function TooltipContent({
<TooltipPrimitive.Content
data-slot="tooltip-content"
sideOffset={sideOffset}
+ collisionPadding={collisionPadding}
className={cn(
"!pointer-events-none z-[70] w-fit origin-(--radix-tooltip-content-transform-origin) animate-in rounded-sm bg-border px-3 py-1.5 text-xs text-pretty text-foreground shadow-md fade-in-0 select-none zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95",
className
diff --git a/frontend/src/components/v3/platform/SecretInput/InfisicalSecretInput.tsx b/frontend/src/components/v3/platform/SecretInput/InfisicalSecretInput.tsx
index 4691749831..e338133a5a 100644
--- a/frontend/src/components/v3/platform/SecretInput/InfisicalSecretInput.tsx
+++ b/frontend/src/components/v3/platform/SecretInput/InfisicalSecretInput.tsx
@@ -248,6 +248,7 @@ export const InfisicalSecretInput = forwardRef<HTMLTextAreaElement, Props>(
<PopoverPrimitive.Portal>
<PopoverPrimitive.Content
align="start"
+ collisionPadding={8}
onOpenAutoFocus={(e) => e.preventDefault()}
onMouseDown={(e) => e.preventDefault()}
className="relative top-2 z-[100] max-h-80 thin-scrollbar overflow-auto rounded-md border border-border bg-popover text-foreground shadow-md"
diff --git a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/honey-token-config/HoneyTokenModal.tsx b/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/honey-token-config/HoneyTokenModal.tsx
index df69eef3cd..f30278156f 100644
--- a/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/honey-token-config/HoneyTokenModal.tsx
+++ b/frontend/src/pages/organization/ProductSettingsPage/SecretsManagement/honey-token-config/HoneyTokenModal.tsx
@@ -334,19 +334,19 @@ export const HoneyTokenModal = ({ isOpen, onOpenChange }: Props) => {
{hasSavedConfig && (
<div className="mt-4 rounded-md border border-border bg-container p-4">
- <div className="mb-3 flex items-center gap-2 text-sm text-mineshaft-300">
- <Terminal className="size-4 text-mineshaft-400" />
+ <div className="mb-3 flex items-center gap-2 text-sm text-foreground">
+ <Terminal className="size-4 text-muted" />
<span className="font-medium tracking-wide uppercase">
Deploy CloudFormation Stack
</span>
</div>
- <p className="mb-3 text-sm text-mineshaft-400">
+ <p className="mb-3 text-sm text-muted">
Run this command to create the CloudFormation stack that provisions the decoy IAM
user and wires CloudTrail alerts back to Infisical.
</p>
<div className="relative">
- <pre className="rounded-md border border-border bg-card p-4 pr-12 font-mono text-xs leading-relaxed break-all whitespace-pre-wrap text-mineshaft-300">
- <span className="text-mineshaft-400 select-none">$ </span>
+ <pre className="rounded-md border border-border bg-card p-4 pr-12 font-mono text-xs leading-relaxed break-all whitespace-pre-wrap text-foreground">
+ <span className="text-muted select-none">$ </span>
{cfCommand}
</pre>
<IconButton
diff --git a/frontend/src/pages/secret-manager/InsightsPage/InsightsPage.tsx b/frontend/src/pages/secret-manager/InsightsPage/InsightsPage.tsx
index 7e317bd22b..57e9eafbee 100644
--- a/frontend/src/pages/secret-manager/InsightsPage/InsightsPage.tsx
+++ b/frontend/src/pages/secret-manager/InsightsPage/InsightsPage.tsx
@@ -88,7 +88,7 @@ export const InsightsPage = withProjectPermission(
{
label: "honey tokens",
value: counts.honeyTokenCount,
- icon: <HexagonIcon className="size-3.5 text-yellow-700" />
+ icon: <HexagonIcon className="size-3.5 text-warning" />
}
]
: [])
diff --git a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
index e4482fd624..8a92fea503 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/OverviewPage.tsx
@@ -31,8 +31,7 @@ import {
CreateHoneyTokenModal,
EditHoneyTokenModal,
HoneyTokenDetailsDrawer,
- RevokeHoneyTokenModal,
- ViewHoneyTokenCredentialsModal
+ RevokeHoneyTokenModal
} from "@app/components/honey-tokens";
import { UpgradePlanModal } from "@app/components/license/UpgradePlanModal";
import { createNotification } from "@app/components/notifications";
@@ -274,8 +273,7 @@ type TSecOverwriteOpt = { update: TParsedEnv; create: TParsedEnv };
export enum EntryType {
FOLDER = "folder",
SECRET = "secret",
- SECRET_ROTATION = "secretRotation",
- HONEY_TOKEN = "honeyToken"
+ SECRET_ROTATION = "secretRotation"
}
export enum RowType {
@@ -393,12 +391,10 @@ const OverviewPageContent = () => {
[EntryType.FOLDER]: Record<string, Record<string, TSecretFolder>>;
[EntryType.SECRET]: Record<string, Record<string, SecretV3RawSanitized>>;
[EntryType.SECRET_ROTATION]: Record<string, Record<string, TSecretRotationV2>>;
- [EntryType.HONEY_TOKEN]: Record<string, Record<string, TDashboardHoneyToken>>;
}>({
[EntryType.FOLDER]: {},
[EntryType.SECRET]: {},
- [EntryType.SECRET_ROTATION]: {},
- [EntryType.HONEY_TOKEN]: {}
+ [EntryType.SECRET_ROTATION]: {}
});
const {
@@ -424,8 +420,7 @@ const OverviewPageContent = () => {
setSelectedEntries({
[EntryType.FOLDER]: {},
[EntryType.SECRET]: {},
- [EntryType.SECRET_ROTATION]: {},
- [EntryType.HONEY_TOKEN]: {}
+ [EntryType.SECRET_ROTATION]: {}
});
}, []);
@@ -1007,7 +1002,6 @@ const OverviewPageContent = () => {
"confirmDisableBatchMode",
"editHoneyToken",
"revokeHoneyToken",
- "viewHoneyTokenCredentials",
"createEnvironment"
] as const);
@@ -2353,14 +2347,12 @@ const OverviewPageContent = () => {
[filter, navigate, tagFilter]
);
+ const hasSelectableRows = Boolean(
+ secrets?.length || folders?.length || secretRotationNames?.length
+ );
+
const allRowsSelectedOnPage = useMemo(() => {
- if (
- !secrets?.length &&
- !folders?.length &&
- !secretRotationNames?.length &&
- !honeyTokenNames?.length
- )
- return { isChecked: false, isIndeterminate: false };
+ if (!hasSelectableRows) return { isChecked: false, isIndeterminate: false };
if (
(!secrets?.length ||
@@ -2368,22 +2360,19 @@ const OverviewPageContent = () => {
(!folders?.length ||
folders?.every((folder) => selectedEntries[EntryType.FOLDER][folder.name])) &&
(!secretRotationNames?.length ||
- secretRotationNames?.every((name) => selectedEntries[EntryType.SECRET_ROTATION][name])) &&
- (!honeyTokenNames?.length ||
- honeyTokenNames?.every((name) => selectedEntries[EntryType.HONEY_TOKEN][name]))
+ secretRotationNames?.every((name) => selectedEntries[EntryType.SECRET_ROTATION][name]))
)
return { isChecked: true, isIndeterminate: false };
if (
secrets?.some((secret) => selectedEntries[EntryType.SECRET][secret.key]) ||
folders?.some((folder) => selectedEntries[EntryType.FOLDER][folder.name]) ||
- secretRotationNames?.some((name) => selectedEntries[EntryType.SECRET_ROTATION][name]) ||
- honeyTokenNames?.some((name) => selectedEntries[EntryType.HONEY_TOKEN][name])
+ secretRotationNames?.some((name) => selectedEntries[EntryType.SECRET_ROTATION][name])
)
return { isChecked: true, isIndeterminate: true };
return { isChecked: false, isIndeterminate: false };
- }, [selectedEntries, secrets, folders, secretRotationNames, honeyTokenNames]);
+ }, [selectedEntries, secrets, folders, secretRotationNames, hasSelectableRows]);
const toggleSelectedEntry = useCallback(
(type: EntryType, key: string) => {
@@ -2401,8 +2390,6 @@ const OverviewPageContent = () => {
resource = getSecretByKey(env.slug, key);
} else if (type === EntryType.FOLDER) {
resource = getFolderByNameAndEnv(key, env.slug);
- } else if (type === EntryType.HONEY_TOKEN) {
- resource = getHoneyTokenByName(env.slug, key);
} else {
resource = getSecretRotationByName(env.slug, key);
}
@@ -2413,13 +2400,7 @@ const OverviewPageContent = () => {
setSelectedEntries(newChecks);
},
- [
- selectedEntries,
- getFolderByNameAndEnv,
- getSecretByKey,
- getSecretRotationByName,
- getHoneyTokenByName
- ]
+ [selectedEntries, getFolderByNameAndEnv, getSecretByKey, getSecretRotationByName]
);
// folders move one at a time from the inline row action. build the per-env record (same shape the
@@ -2479,19 +2460,6 @@ const OverviewPageContent = () => {
if (resource) newChecks[EntryType.SECRET_ROTATION][rotationName][env.slug] = resource;
}
});
-
- honeyTokenNames?.forEach((honeyTokenName) => {
- if (allRowsSelectedOnPage.isChecked) {
- delete newChecks[EntryType.HONEY_TOKEN][honeyTokenName];
- } else {
- if (!newChecks[EntryType.HONEY_TOKEN][honeyTokenName])
- newChecks[EntryType.HONEY_TOKEN][honeyTokenName] = {};
-
- const resource = getHoneyTokenByName(env.slug, honeyTokenName);
-
- if (resource) newChecks[EntryType.HONEY_TOKEN][honeyTokenName][env.slug] = resource;
- }
- });
});
setSelectedEntries(newChecks);
@@ -3080,7 +3048,7 @@ const OverviewPageContent = () => {
>
<Checkbox
variant="project"
- isDisabled={totalCount === 0 || hasPendingBatchChanges}
+ isDisabled={!hasSelectableRows || hasPendingBatchChanges}
id="checkbox-select-all-rows"
isChecked={allRowsSelectedOnPage.isChecked}
isIndeterminate={allRowsSelectedOnPage.isIndeterminate}
@@ -3504,17 +3472,10 @@ const OverviewPageContent = () => {
getHoneyTokenByName={getHoneyTokenByName}
tableWidth={tableWidth}
key={`overview-ht-${honeyTokenName}-${index + 1}`}
- isSelected={Boolean(selectedEntries.honeyToken[honeyTokenName])}
- onToggleHoneyTokenSelect={() =>
- toggleSelectedEntry(EntryType.HONEY_TOKEN, honeyTokenName)
- }
onEdit={(honeyToken) => handlePopUpOpen("editHoneyToken", honeyToken)}
onRevoke={(honeyToken) =>
handlePopUpOpen("revokeHoneyToken", honeyToken)
}
- onViewCredentials={(honeyToken) =>
- handlePopUpOpen("viewHoneyTokenCredentials", honeyToken)
- }
onViewDetails={(honeyToken) =>
setDetailsDrawerHoneyTokenId(honeyToken.id)
}
@@ -3947,12 +3908,6 @@ const OverviewPageContent = () => {
honeyToken={popUp.revokeHoneyToken.data as TDashboardHoneyToken}
onOpenChange={(isOpen) => handlePopUpToggle("revokeHoneyToken", isOpen)}
/>
- <ViewHoneyTokenCredentialsModal
- isOpen={popUp.viewHoneyTokenCredentials.isOpen}
- honeyToken={popUp.viewHoneyTokenCredentials.data as TDashboardHoneyToken}
- projectId={projectId}
- onOpenChange={(isOpen) => handlePopUpToggle("viewHoneyTokenCredentials", isOpen)}
- />
{commitHistoryEnv && (
<CommitHistorySheet
isOpen
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/AddResourceButtons/AddResourceButtons.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/AddResourceButtons/AddResourceButtons.tsx
index 2f6862fde0..8ca84ab23a 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/AddResourceButtons/AddResourceButtons.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/AddResourceButtons/AddResourceButtons.tsx
@@ -141,7 +141,7 @@ export function AddResourceButtons({
onClick={onAddHoneyToken}
isDisabled={!isHoneyTokenAvailable || !canCreateHoneyTokens}
>
- <HexagonIcon className="text-yellow" />
+ <HexagonIcon className="text-warning" />
Add Honey Token
</DropdownMenuItem>
</TooltipTrigger>
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/HoneyTokenTableRow/HoneyTokenTableRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/HoneyTokenTableRow/HoneyTokenTableRow.tsx
index 2cd93c2260..8823c19287 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/HoneyTokenTableRow/HoneyTokenTableRow.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/HoneyTokenTableRow/HoneyTokenTableRow.tsx
@@ -1,19 +1,24 @@
import { subject } from "@casl/ability";
import {
- AsteriskIcon,
BanIcon,
ChevronDownIcon,
+ ClipboardCheckIcon,
+ CopyIcon,
EditIcon,
- ExternalLinkIcon,
+ EllipsisIcon,
HexagonIcon,
- InfoIcon
+ InfoIcon,
+ ListIcon
} from "lucide-react";
import { twMerge } from "tailwind-merge";
import { ProjectPermissionCan } from "@app/components/permissions";
import {
Badge,
- Checkbox,
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger,
IconButton,
Table,
TableBody,
@@ -30,7 +35,7 @@ import {
ProjectPermissionSub
} from "@app/context/ProjectPermissionContext/types";
import { HONEY_TOKEN_MAP } from "@app/helpers/honeyTokens";
-import { useToggle } from "@app/hooks";
+import { useTimedReset, useToggle } from "@app/hooks";
import { HoneyTokenStatus, HoneyTokenType } from "@app/hooks/api/honeyTokens/enums";
import { TDashboardHoneyToken } from "@app/hooks/api/honeyTokens/types";
@@ -42,6 +47,9 @@ const STATUS_BADGE_VARIANT: Record<string, "success" | "danger" | "neutral"> = {
[HoneyTokenStatus.Revoked]: "neutral"
};
+const ACTION_BUTTON_CLASS_NAME =
+ "overflow-hidden border-0 transition-all duration-300 motion-reduce:transition-none [@media(hover:hover)]:w-0 [@media(hover:hover)]:group-hover:w-7 [@media(hover:hover)]:group-focus-within:w-7";
+
type Props = {
honeyTokenName: string;
environments: { name: string; slug: string }[];
@@ -50,10 +58,7 @@ type Props = {
tableWidth: number;
onEdit: (honeyToken: TDashboardHoneyToken) => void;
onRevoke: (honeyToken: TDashboardHoneyToken) => void;
- onViewCredentials: (honeyToken: TDashboardHoneyToken) => void;
onViewDetails: (honeyToken: TDashboardHoneyToken) => void;
- isSelected: boolean;
- onToggleHoneyTokenSelect: (honeyTokenName: string) => void;
};
export const HoneyTokenTableRow = ({
@@ -64,12 +69,10 @@ export const HoneyTokenTableRow = ({
tableWidth,
onEdit,
onRevoke,
- onViewCredentials,
- onViewDetails,
- isSelected,
- onToggleHoneyTokenSelect
+ onViewDetails
}: Props) => {
const [isExpanded, setIsExpanded] = useToggle(false);
+ const [, isNameCopied, setIsNameCopied] = useTimedReset({ initialState: false });
const isSingleEnvView = environments.length === 1;
const totalCols = environments.length + 2;
@@ -95,99 +98,91 @@ export const HoneyTokenTableRow = ({
return (
<div
className={twMerge(
- "flex items-center rounded-md border border-border bg-container-hover px-0.5 py-0.5 shadow-md",
- "pointer-events-none opacity-0 transition-all duration-300",
- "group-hover:pointer-events-auto group-hover:gap-1 group-hover:opacity-100"
+ "pointer-events-auto flex items-center gap-1 rounded-md border border-border bg-container-hover p-0.5 opacity-100 transition-all duration-300 motion-reduce:transition-none",
+ "[@media(hover:hover)]:pointer-events-none [@media(hover:hover)]:gap-0 [@media(hover:hover)]:opacity-0",
+ "[@media(hover:hover)]:group-hover:pointer-events-auto [@media(hover:hover)]:group-hover:gap-1 [@media(hover:hover)]:group-hover:opacity-100",
+ "[@media(hover:hover)]:group-focus-within:pointer-events-auto [@media(hover:hover)]:group-focus-within:gap-1 [@media(hover:hover)]:group-focus-within:opacity-100"
)}
>
<Tooltip>
- <TooltipTrigger>
+ <TooltipTrigger asChild>
<IconButton
variant="ghost"
size="xs"
- className="w-0 overflow-hidden border-0 transition-all duration-300 group-hover:w-7"
+ className={ACTION_BUTTON_CLASS_NAME}
+ aria-label={`View details for ${honeyToken.name}`}
onClick={() => onViewDetails(honeyToken)}
>
- <ExternalLinkIcon />
+ <ListIcon />
</IconButton>
</TooltipTrigger>
<TooltipContent>View details</TooltipContent>
</Tooltip>
- <ProjectPermissionCan
- I={ProjectPermissionHoneyTokenActions.ReadCredentials}
- a={subject(ProjectPermissionSub.HoneyTokens, {
- environment: honeyToken.environment.slug,
- secretPath: honeyToken.folder.path
- })}
- >
- {(isAllowed) => (
- <Tooltip>
- <TooltipTrigger>
- <IconButton
- variant="ghost"
- size="xs"
- className="w-0 overflow-hidden border-0 transition-all duration-300 group-hover:w-7"
- isDisabled={!isAllowed || isRevoked}
- onClick={() => onViewCredentials(honeyToken)}
- >
- <AsteriskIcon />
- </IconButton>
- </TooltipTrigger>
- <TooltipContent>View credentials</TooltipContent>
- </Tooltip>
- )}
- </ProjectPermissionCan>
- <ProjectPermissionCan
- I={ProjectPermissionHoneyTokenActions.Edit}
- a={subject(ProjectPermissionSub.HoneyTokens, {
- environment: honeyToken.environment.slug,
- secretPath: honeyToken.folder.path
- })}
- renderTooltip
- allowedLabel="Edit"
- >
- {(isAllowed) => (
- <Tooltip>
- <TooltipTrigger>
- <IconButton
- variant="ghost"
- size="xs"
- className="w-0 overflow-hidden border-0 transition-all duration-300 group-hover:w-7"
- isDisabled={!isAllowed || isRevoked}
- onClick={() => onEdit(honeyToken)}
- >
- <EditIcon />
- </IconButton>
- </TooltipTrigger>
- <TooltipContent>Edit</TooltipContent>
- </Tooltip>
- )}
- </ProjectPermissionCan>
- {honeyToken.status !== HoneyTokenStatus.Revoked && (
- <ProjectPermissionCan
- I={ProjectPermissionHoneyTokenActions.Revoke}
- a={subject(ProjectPermissionSub.HoneyTokens, {
- environment: honeyToken.environment.slug,
- secretPath: honeyToken.folder.path
- })}
- >
- {(isAllowed) => (
- <Tooltip>
- <TooltipTrigger>
- <IconButton
- variant="ghost"
- size="xs"
- className="w-0 overflow-hidden border-0 transition-all duration-300 group-hover:w-7 hover:text-danger"
- onClick={() => onRevoke(honeyToken)}
+ {isRevoked ? (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <IconButton
+ variant="ghost"
+ size="xs"
+ className={twMerge(
+ ACTION_BUTTON_CLASS_NAME,
+ "cursor-not-allowed opacity-50 hover:bg-transparent"
+ )}
+ aria-label={`More actions unavailable for ${honeyToken.name}`}
+ aria-disabled
+ >
+ <EllipsisIcon />
+ </IconButton>
+ </TooltipTrigger>
+ <TooltipContent>Revoked honey tokens cannot be edited.</TooltipContent>
+ </Tooltip>
+ ) : (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton
+ variant="ghost"
+ size="xs"
+ className={ACTION_BUTTON_CLASS_NAME}
+ aria-label={`More actions for ${honeyToken.name}`}
+ >
+ <EllipsisIcon />
+ </IconButton>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <ProjectPermissionCan
+ I={ProjectPermissionHoneyTokenActions.Edit}
+ a={subject(ProjectPermissionSub.HoneyTokens, {
+ environment: honeyToken.environment.slug,
+ secretPath: honeyToken.folder.path
+ })}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem isDisabled={!isAllowed} onSelect={() => onEdit(honeyToken)}>
+ <EditIcon />
+ Edit
+ </DropdownMenuItem>
+ )}
+ </ProjectPermissionCan>
+ <ProjectPermissionCan
+ I={ProjectPermissionHoneyTokenActions.Revoke}
+ a={subject(ProjectPermissionSub.HoneyTokens, {
+ environment: honeyToken.environment.slug,
+ secretPath: honeyToken.folder.path
+ })}
+ >
+ {(isAllowed) => (
+ <DropdownMenuItem
+ variant="danger"
isDisabled={!isAllowed}
+ onSelect={() => onRevoke(honeyToken)}
>
<BanIcon />
- </IconButton>
- </TooltipTrigger>
- <TooltipContent>Revoke</TooltipContent>
- </Tooltip>
- )}
- </ProjectPermissionCan>
+ Revoke
+ </DropdownMenuItem>
+ )}
+ </ProjectPermissionCan>
+ </DropdownMenuContent>
+ </DropdownMenu>
)}
</div>
);
@@ -200,7 +195,10 @@ export const HoneyTokenTableRow = ({
return (
<>
{tokenInfo && (
- <Badge variant="neutral" className="mx-2.5">
+ <Badge
+ variant="neutral"
+ className="mx-2.5 bg-[color-mix(in_srgb,var(--color-neutral)_15%,var(--color-container))]"
+ >
<img
src={`/images/integrations/${tokenInfo.image}`}
style={{ width: "11px" }}
@@ -233,39 +231,27 @@ export const HoneyTokenTableRow = ({
<>
<TableRow
onClick={isSingleEnvView ? undefined : setIsExpanded.toggle}
- className="group hover:z-10"
+ className={twMerge(
+ "group hover:z-10",
+ isTriggered && !isExpanded && "bg-danger/5 hover:bg-danger/10"
+ )}
>
<TableCell
className={twMerge(
!isSingleEnvView && "sticky left-0 z-10",
"bg-container transition-colors duration-75 group-hover:bg-container-hover",
+ isTriggered && !isExpanded && "bg-danger/5 group-hover:bg-danger/10",
!isSingleEnvView && isExpanded && "border-b-0 bg-container-hover"
)}
>
- <Checkbox
- variant="project"
- id={`checkbox-${honeyTokenName}`}
- isChecked={isSelected}
- onCheckedChange={() => {
- onToggleHoneyTokenSelect(honeyTokenName);
- }}
- onClick={(e) => {
- e.stopPropagation();
- }}
- className={twMerge("hidden group-hover:flex", isSelected && "flex")}
- />
{!isSingleEnvView && isExpanded ? (
- <ChevronDownIcon
- className={twMerge("block", "group-hover:!hidden", isSelected && "!hidden")}
- />
+ <ChevronDownIcon className="block" />
) : (
<HexagonIcon
className={twMerge(
- "group-hover:!hidden",
- isSelected && "!hidden",
- isTriggered && "text-red",
- !isTriggered && !isAllRevoked && "text-yellow",
- isAllRevoked && "text-mineshaft-400"
+ isTriggered && "text-danger",
+ !isTriggered && !isAllRevoked && "text-warning",
+ isAllRevoked && "text-muted"
)}
/>
)}
@@ -274,6 +260,7 @@ export const HoneyTokenTableRow = ({
className={twMerge(
!isSingleEnvView && "sticky left-10 z-10 border-r",
"bg-container transition-colors duration-75 group-hover:bg-container-hover",
+ isTriggered && !isExpanded && "bg-danger/5 group-hover:bg-danger/10",
!isSingleEnvView && isExpanded && "border-r-0 border-b-0 bg-container-hover"
)}
isTruncatable
@@ -281,12 +268,19 @@ export const HoneyTokenTableRow = ({
>
{isSingleEnvView && singleEnvToken ? (
<div className="relative flex w-full items-center">
- <span className="truncate">{honeyTokenName}</span>
+ <span
+ className={twMerge(
+ "truncate",
+ singleEnvToken.status === HoneyTokenStatus.Revoked && "text-muted"
+ )}
+ >
+ {honeyTokenName}
+ </span>
{renderHoneyTokenInlineDetails(singleEnvToken)}
<div
className={twMerge(
- "ml-auto flex items-center transition-[margin] duration-300",
- "group-hover:mr-32"
+ "ml-auto flex items-center transition-[margin] duration-300 motion-reduce:transition-none [@media(hover:hover)]:mr-0",
+ "mr-16 [@media(hover:hover)]:group-focus-within:mr-16 [@media(hover:hover)]:group-hover:mr-16"
)}
>
{renderStatusBadge(singleEnvToken)}
@@ -296,7 +290,38 @@ export const HoneyTokenTableRow = ({
</div>
</div>
) : (
- honeyTokenName
+ <span className={twMerge(isAllRevoked && "text-muted")}>{honeyTokenName}</span>
+ )}
+ {!isSingleEnvView && (
+ <div
+ className={twMerge(
+ "absolute top-1/2 right-[3px] z-20 -translate-y-1/2",
+ "flex items-center rounded-md border border-border bg-container-hover p-0.5 shadow-md",
+ "pointer-events-auto opacity-100 transition-all duration-300 motion-reduce:transition-none",
+ "[@media(hover:hover)]:pointer-events-none [@media(hover:hover)]:opacity-0",
+ "[@media(hover:hover)]:group-focus-within:pointer-events-auto [@media(hover:hover)]:group-focus-within:opacity-100",
+ "[@media(hover:hover)]:group-hover:pointer-events-auto [@media(hover:hover)]:group-hover:opacity-100"
+ )}
+ >
+ <Tooltip disableHoverableContent>
+ <TooltipTrigger asChild>
+ <IconButton
+ variant="ghost"
+ size="xs"
+ aria-label={`Copy honey token name ${honeyTokenName}`}
+ className={ACTION_BUTTON_CLASS_NAME}
+ onClick={(event) => {
+ event.stopPropagation();
+ navigator.clipboard.writeText(honeyTokenName);
+ setIsNameCopied(true);
+ }}
+ >
+ {isNameCopied ? <ClipboardCheckIcon /> : <CopyIcon />}
+ </IconButton>
+ </TooltipTrigger>
+ <TooltipContent>Copy Honey Token Name</TooltipContent>
+ </Tooltip>
+ </div>
)}
</TableCell>
{environments.length > 1 &&
@@ -343,15 +368,28 @@ export const HoneyTokenTableRow = ({
const honeyToken = getHoneyTokenByName(slug, honeyTokenName)!;
return (
- <TableRow key={slug} className="group relative hover:z-10">
+ <TableRow
+ key={slug}
+ className={twMerge(
+ "group relative hover:z-10",
+ honeyToken.status === HoneyTokenStatus.Triggered &&
+ "bg-danger/5 hover:bg-danger/10"
+ )}
+ >
<TableCell colSpan={2}>
<div className="relative flex w-full items-center">
- <span>{envName}</span>
+ <span
+ className={twMerge(
+ honeyToken.status === HoneyTokenStatus.Revoked && "text-muted"
+ )}
+ >
+ {envName}
+ </span>
{renderHoneyTokenInlineDetails(honeyToken)}
<div
className={twMerge(
- "ml-auto flex items-center transition-[margin] duration-300",
- "group-hover:mr-32"
+ "ml-auto flex items-center transition-[margin] duration-300 motion-reduce:transition-none [@media(hover:hover)]:mr-0",
+ "mr-16 [@media(hover:hover)]:group-focus-within:mr-16 [@media(hover:hover)]:group-hover:mr-16"
)}
>
{renderStatusBadge(honeyToken)}
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/ResourceFilter/ResourceFilter.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/ResourceFilter/ResourceFilter.tsx
index 74174f8d9b..612fcb6c2b 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/ResourceFilter/ResourceFilter.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/ResourceFilter/ResourceFilter.tsx
@@ -44,7 +44,7 @@ const OVERVIEW_RESOURCE_TYPES: ResourceTypeOption[] = [
{
type: "honeyToken",
label: "Honey Tokens",
- icon: <HexagonIcon className="text-yellow-700" />
+ icon: <HexagonIcon className="text-warning" />
},
{
type: "proxiedService",
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/SecretEditRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/SecretEditRow.tsx
deleted file mode 100644
index 9acdcd32f2..0000000000
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/SecretEditRow.tsx
+++ /dev/null
@@ -1,474 +0,0 @@
-import { useCallback, useEffect, useState } from "react";
-import { Controller, useForm } from "react-hook-form";
-import { subject } from "@casl/ability";
-import {
- faCheck,
- faCopy,
- faEyeSlash,
- faProjectDiagram,
- faTrash,
- faXmark
-} from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { twMerge } from "tailwind-merge";
-
-import { createNotification } from "@app/components/notifications";
-import { ProjectPermissionCan } from "@app/components/permissions";
-import { SecretReferenceTree } from "@app/components/secrets/SecretReferenceDetails";
-import { DeleteActionModal, IconButton, Modal, ModalContent, Tooltip } from "@app/components/v2";
-import { InfisicalSecretInput } from "@app/components/v2/InfisicalSecretInput";
-import {
- ProjectPermissionActions,
- ProjectPermissionSub,
- useProject,
- useProjectPermission
-} from "@app/context";
-import { ProjectPermissionSecretActions } from "@app/context/ProjectPermissionContext/types";
-import { usePopUp, useToggle } from "@app/hooks";
-import { useGetSecretValue } from "@app/hooks/api/dashboard/queries";
-import { ProjectEnv, SecretType, SecretV3RawSanitized } from "@app/hooks/api/types";
-import { hasSecretReadValueOrDescribePermission } from "@app/lib/fn/permission";
-import { CollapsibleSecretImports } from "@app/pages/secret-manager/SecretDashboardPage/components/SecretListView/CollapsibleSecretImports";
-import { HIDDEN_SECRET_VALUE } from "@app/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem";
-
-type Props = {
- defaultValue?: string | null;
- secretName: string;
- secretId?: string;
- isOverride?: boolean;
- isCreatable?: boolean;
- isVisible?: boolean;
- isImportedSecret: boolean;
- environment: string;
- secretValueHidden: boolean;
- secretPath: string;
- onSecretCreate: (env: string, key: string, value: string) => Promise<void>;
- onSecretUpdate: (params: {
- env: string;
- key: string;
- value: string | undefined;
- secretValueHidden: boolean;
- type?: SecretType;
- secretId?: string;
- newSecretName?: string;
- secretComment?: string;
- tags?: { id: string; slug: string }[];
- secretMetadata?: { key: string; value: string; isEncrypted?: boolean }[];
- skipMultilineEncoding?: boolean | null;
- originalValue?: string;
- }) => Promise<void>;
- onSecretDelete: (env: string, key: string, secretId?: string) => Promise<void>;
- isRotatedSecret?: boolean;
- isHoneyTokenSecret?: boolean;
- isEmpty?: boolean;
- importedSecret?:
- | {
- secretPath: string;
- secret?: SecretV3RawSanitized;
- environmentInfo?: ProjectEnv;
- environment: string;
- }
- | undefined;
- importedBy?: {
- environment: { name: string; slug: string };
- project?: { name: string; slug: string; id: string };
- folders: {
- name: string;
- secrets?: { secretId: string; referencedSecretKey: string; referencedSecretEnv: string }[];
- isImported: boolean;
- }[];
- }[];
- isSecretPresent?: boolean;
-};
-
-export const SecretEditRow = ({
- defaultValue,
- isCreatable,
- isOverride,
- isImportedSecret,
- onSecretUpdate,
- secretName,
- secretValueHidden,
- onSecretCreate,
- onSecretDelete,
- environment,
- secretPath,
- isVisible,
- secretId,
- isRotatedSecret,
- isHoneyTokenSecret,
- importedBy,
- importedSecret,
- isEmpty,
- isSecretPresent
-}: Props) => {
- const isManagedSecret = isRotatedSecret || isHoneyTokenSecret;
-
- let deleteTooltipContent = "Delete";
- if (isHoneyTokenSecret) deleteTooltipContent = "Cannot Delete Honey Token Secret";
- else if (isRotatedSecret) deleteTooltipContent = "Cannot Delete Rotated Secret";
-
- const { handlePopUpOpen, handlePopUpToggle, handlePopUpClose, popUp } = usePopUp([
- "editSecret",
- "secretReferenceTree"
- ] as const);
-
- const { currentProject } = useProject();
-
- const [isFieldFocused, setIsFieldFocused] = useToggle();
-
- const fetchSecretValueParams =
- importedSecret && !isSecretPresent
- ? {
- environment: importedSecret.environment,
- secretPath: importedSecret.secretPath,
- secretKey: importedSecret.secret?.key ?? "",
- projectId: currentProject.id
- }
- : {
- environment,
- secretPath,
- secretKey: secretName,
- projectId: currentProject.id,
- isOverride
- };
-
- // scott: only fetch value if secret exists, has non-empty value and user has permission
- const canFetchValue = Boolean(importedSecret ?? secretId) && !isEmpty && !secretValueHidden;
-
- const {
- data: secretValueData,
- isPending: isPendingSecretValueData,
- isError: isErrorFetchingSecretValue,
- refetch: refetchSecretValue
- } = useGetSecretValue(fetchSecretValueParams, {
- enabled: canFetchValue && (isVisible || isFieldFocused)
- });
-
- const isFetchingSecretValue = canFetchValue && isPendingSecretValueData;
-
- const {
- handleSubmit,
- control,
- reset,
- setValue,
- formState: { isDirty, isSubmitting }
- } = useForm({
- defaultValues: {
- value: secretValueData?.valueOverride ?? secretValueData?.value ?? (defaultValue || null)
- }
- });
-
- useEffect(() => {
- if (secretValueData && !isDirty) {
- setValue("value", secretValueData.valueOverride ?? secretValueData.value);
- }
- }, [secretValueData]);
-
- const { permission } = useProjectPermission();
-
- const [isDeleting, setIsDeleting] = useToggle();
- const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
-
- const toggleModal = useCallback(() => {
- setIsModalOpen((prev) => !prev);
- }, []);
-
- const handleFormReset = () => {
- reset();
- };
-
- const handleCopySecretToClipboard = async () => {
- try {
- const { data } = await refetchSecretValue();
-
- await window.navigator.clipboard.writeText(data?.valueOverride ?? data?.value ?? "");
- createNotification({ type: "success", text: "Copied secret to clipboard" });
- } catch (e) {
- console.error(e);
- createNotification({
- type: "error",
- text: "Failed to fetch secret value."
- });
- }
- };
-
- const handleFormSubmit = async ({ value }: { value?: string | null }) => {
- if ((value || value === "") && secretName) {
- if (isCreatable) {
- await onSecretCreate(environment, secretName, value);
- } else {
- if (
- importedBy &&
- importedBy.some(({ folders }) =>
- folders?.some(({ secrets }) =>
- secrets?.some(
- ({ referencedSecretKey, referencedSecretEnv }) =>
- referencedSecretKey === secretName && referencedSecretEnv === environment
- )
- )
- )
- ) {
- handlePopUpOpen("editSecret", { secretValue: value });
- return;
- }
- await onSecretUpdate({
- env: environment,
- key: secretName,
- value,
- secretValueHidden,
- type: isOverride ? SecretType.Personal : SecretType.Shared,
- secretId
- });
- }
- }
- if (secretValueHidden && !isOverride) {
- setTimeout(() => {
- reset({ value: defaultValue || null });
- }, 50);
- } else {
- reset({ value });
- }
- };
-
- const handleEditSecret = async ({ secretValue }: { secretValue: string }) => {
- await onSecretUpdate({
- env: environment,
- key: secretName,
- value: secretValue,
- secretValueHidden,
- type: isOverride ? SecretType.Personal : SecretType.Shared,
- secretId
- });
- reset({ value: secretValue });
- handlePopUpClose("editSecret");
- };
-
- const canReadSecretValue = hasSecretReadValueOrDescribePermission(
- permission,
- ProjectPermissionSecretActions.ReadValue
- );
-
- const canEditSecretValue = permission.can(
- ProjectPermissionSecretActions.Edit,
- subject(ProjectPermissionSub.Secrets, {
- environment,
- secretPath,
- secretName,
- secretTags: ["*"]
- })
- );
-
- const handleDeleteSecret = useCallback(async () => {
- setIsDeleting.on();
- setIsModalOpen(false);
-
- try {
- await onSecretDelete(environment, secretName, secretId);
- reset({ value: null });
- } finally {
- setIsDeleting.off();
- }
- }, [onSecretDelete, environment, secretName, secretId, reset, setIsDeleting]);
-
- return (
- <div className="group flex w-full cursor-text items-center space-x-2">
- <DeleteActionModal
- isOpen={isModalOpen}
- onClose={toggleModal}
- title="Do you want to delete the selected secret?"
- deleteKey={secretName}
- onDeleteApproved={handleDeleteSecret}
- />
- {secretValueHidden && !isOverride && (
- <Tooltip
- content={`You do not have access to view the current value${canEditSecretValue && !isManagedSecret ? ", but you can set a new one" : "."}`}
- >
- <FontAwesomeIcon className="pl-2" size="sm" icon={faEyeSlash} />
- </Tooltip>
- )}
- <div className="grow border-r border-r-mineshaft-600 pr-2 pl-1">
- <Controller
- control={control}
- name="value"
- render={({ field }) => (
- <InfisicalSecretInput
- {...field}
- isReadOnly={
- isImportedSecret ||
- (isManagedSecret && !isOverride) ||
- isFetchingSecretValue ||
- isErrorFetchingSecretValue
- }
- value={
- // eslint-disable-next-line no-nested-ternary
- isFetchingSecretValue
- ? HIDDEN_SECRET_VALUE
- : isErrorFetchingSecretValue
- ? "Error fetching secret value..."
- : (field.value as string)
- }
- key="secret-input"
- isVisible={isVisible && !secretValueHidden}
- secretPath={secretPath}
- environment={environment}
- isImport={isImportedSecret}
- defaultValue={secretValueHidden ? "" : undefined}
- canEditButNotView={secretValueHidden && !isOverride && !isManagedSecret}
- onFocus={() => setIsFieldFocused.on()}
- onBlur={() => {
- field.onBlur();
- setIsFieldFocused.off();
- }}
- />
- )}
- />
- </div>
-
- <div
- className={twMerge(
- "flex w-24 justify-center space-x-3 pl-2 transition-all",
- isImportedSecret && "pointer-events-none opacity-0"
- )}
- >
- {isDirty ? (
- <>
- <ProjectPermissionCan
- I={isCreatable ? ProjectPermissionActions.Create : ProjectPermissionActions.Edit}
- a={subject(ProjectPermissionSub.Secrets, {
- environment,
- secretPath,
- secretName,
- secretTags: ["*"]
- })}
- >
- {(isAllowed) => (
- <div>
- <Tooltip content="Save">
- <IconButton
- variant="plain"
- ariaLabel="submit-value"
- className="h-full"
- isDisabled={isSubmitting || !isAllowed}
- onClick={handleSubmit(handleFormSubmit)}
- >
- <FontAwesomeIcon icon={faCheck} />
- </IconButton>
- </Tooltip>
- </div>
- )}
- </ProjectPermissionCan>
- <div>
- <Tooltip content="cancel">
- <IconButton
- variant="plain"
- colorSchema="danger"
- ariaLabel="reset-value"
- className="h-full"
- onClick={handleFormReset}
- isDisabled={isSubmitting}
- >
- <FontAwesomeIcon icon={faXmark} className="hover:text-red" />
- </IconButton>
- </Tooltip>
- </div>
- </>
- ) : (
- <>
- <div className="opacity-0 group-hover:opacity-100">
- <Tooltip content="Copy Secret">
- <IconButton
- isDisabled={secretValueHidden}
- ariaLabel="copy-value"
- onClick={handleCopySecretToClipboard}
- variant="plain"
- className="h-full"
- >
- <FontAwesomeIcon icon={faCopy} />
- </IconButton>
- </Tooltip>
- </div>
-
- <div className="opacity-0 group-hover:opacity-100">
- <Tooltip content="Secret Reference Tree">
- <IconButton
- variant="plain"
- ariaLabel="reference-tree"
- className="h-full"
- isDisabled={!canReadSecretValue || !secretId || isEmpty}
- onClick={() => handlePopUpOpen("secretReferenceTree")}
- >
- <FontAwesomeIcon icon={faProjectDiagram} />
- </IconButton>
- </Tooltip>
- </div>
- <Modal
- isOpen={popUp.secretReferenceTree.isOpen}
- onOpenChange={(isOpen) => handlePopUpToggle("secretReferenceTree", isOpen)}
- >
- <ModalContent
- className="max-w-3xl"
- title="Secret Reference Details"
- subTitle="Visual breakdown of secrets referenced by this secret."
- onOpenAutoFocus={(e) => e.preventDefault()} // prevents secret input from displaying value on open
- >
- <SecretReferenceTree
- secretPath={secretPath}
- environment={environment}
- secretKey={secretName}
- onClose={() => handlePopUpToggle("secretReferenceTree", false)}
- />
- </ModalContent>
- </Modal>
-
- <ProjectPermissionCan
- I={ProjectPermissionActions.Delete}
- a={subject(ProjectPermissionSub.Secrets, {
- environment,
- secretPath,
- secretName,
- secretTags: ["*"]
- })}
- >
- {(isAllowed) => (
- <div className="opacity-0 group-hover:opacity-100">
- <Tooltip content={deleteTooltipContent}>
- <IconButton
- variant="plain"
- ariaLabel="delete-value"
- className="h-full"
- onClick={toggleModal}
- isDisabled={isDeleting || !isAllowed || isManagedSecret}
- >
- <FontAwesomeIcon icon={faTrash} />
- </IconButton>
- </Tooltip>
- </div>
- )}
- </ProjectPermissionCan>
- </>
- )}
- </div>
- <DeleteActionModal
- isOpen={popUp.editSecret.isOpen}
- deleteKey="confirm"
- buttonColorSchema="secondary"
- buttonText="Save"
- subTitle=""
- title="Do you want to edit this secret?"
- onChange={(isOpen) => handlePopUpToggle("editSecret", isOpen)}
- onDeleteApproved={() => handleEditSecret(popUp?.editSecret?.data)}
- formContent={
- importedBy &&
- importedBy.length > 0 && (
- <CollapsibleSecretImports
- importedBy={importedBy}
- secretsToDelete={[secretName]}
- onlyReferences
- />
- )
- }
- />
- </div>
- );
-};
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/SecretNoAccessOverviewTableRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/SecretNoAccessOverviewTableRow.tsx
deleted file mode 100644
index 2bc2bc29ec..0000000000
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/SecretNoAccessOverviewTableRow.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-import { faCircle } from "@fortawesome/free-regular-svg-icons";
-import { faLock } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-
-import { Td, Tooltip, Tr } from "@app/components/v2";
-import { Blur } from "@app/components/v2/Blur";
-
-type Props = {
- environments: { name: string; slug: string }[];
- count: number;
-};
-
-export const SecretNoAccessOverviewTableRow = ({ environments = [], count }: Props) => {
- return (
- <>
- {Array.from(Array(count)).map((_, j) => (
- <Tr key={`no-access-secret-overview-${j + 1}`} isHoverable isSelectable className="group">
- <Td className="sticky left-0 z-10 bg-mineshaft-800 bg-clip-padding px-0 py-0 group-hover:bg-mineshaft-700">
- <div className="h-full w-full border-r border-mineshaft-600 px-5 py-2.5">
- <Tooltip
- asChild
- content="You do not have permission to view this secret"
- className="max-w-sm"
- >
- <div className="flex items-center space-x-5">
- <div className="text-bunker-300">
- <FontAwesomeIcon className="block" icon={faLock} />
- </div>
- <Blur />
- </div>
- </Tooltip>
- </div>
- </Td>
- {environments.map(({ slug }, i) => {
- return (
- <Td
- key={`sec-overview-${slug}-${i + 1}-value`}
- className="px-0 py-0 group-hover:bg-mineshaft-700"
- >
- <div className="h-full w-full border-r border-mineshaft-600 px-5 py-[0.85rem]">
- <div className="flex justify-center">
- <FontAwesomeIcon icon={faCircle} />
- </div>
- </div>
- </Td>
- );
- })}
- </Tr>
- ))}
- </>
- );
-};
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/SecretOverviewTableRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/SecretOverviewTableRow.tsx
deleted file mode 100644
index 91cfa25728..0000000000
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/SecretOverviewTableRow.tsx
+++ /dev/null
@@ -1,315 +0,0 @@
-import { subject } from "@casl/ability";
-import { faCircle } from "@fortawesome/free-regular-svg-icons";
-import {
- faAngleDown,
- faCheck,
- faCodeBranch,
- faEye,
- faEyeSlash,
- faFileImport,
- faKey,
- faRotate,
- faShieldHalved,
- faXmark
-} from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { twMerge } from "tailwind-merge";
-
-import { Button, Checkbox, TableContainer, Td, Tooltip, Tr } from "@app/components/v2";
-import { useProjectPermission } from "@app/context";
-import {
- ProjectPermissionSecretActions,
- ProjectPermissionSub
-} from "@app/context/ProjectPermissionContext/types";
-import { useToggle } from "@app/hooks";
-import { SecretType, SecretV3RawSanitized } from "@app/hooks/api/secrets/types";
-import { ProjectEnv } from "@app/hooks/api/types";
-import { getExpandedRowStyle } from "@app/pages/secret-manager/OverviewPage/components/utils";
-import { HIDDEN_SECRET_VALUE } from "@app/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem";
-
-import { SecretEditRow } from "./SecretEditRow";
-import SecretRenameRow from "./SecretRenameRow";
-
-type Props = {
- secretKey: string;
- secretPath: string;
- environments: { name: string; slug: string }[];
- isSelected: boolean;
- onToggleSecretSelect: (key: string) => void;
- getSecretByKey: (slug: string, key: string) => SecretV3RawSanitized | undefined;
- onSecretCreate: (env: string, key: string, value: string) => Promise<void>;
- onSecretUpdate: (params: {
- env: string;
- key: string;
- value: string | undefined;
- secretValueHidden: boolean;
- type?: SecretType;
- secretId?: string;
- newSecretName?: string;
- secretComment?: string;
- tags?: { id: string; slug: string }[];
- secretMetadata?: { key: string; value: string; isEncrypted?: boolean }[];
- skipMultilineEncoding?: boolean | null;
- originalValue?: string;
- }) => Promise<void>;
- onSecretDelete: (env: string, key: string, secretId?: string) => Promise<void>;
- isImportedSecretPresentInEnv: (env: string, secretName: string) => boolean;
- getImportedSecretByKey: (
- env: string,
- secretName: string
- ) =>
- | {
- secret?: SecretV3RawSanitized;
- secretPath: string;
- environment: string;
- environmentInfo?: ProjectEnv;
- }
- | undefined;
- scrollOffset: number;
- importedBy?: {
- environment: { name: string; slug: string };
- folders: {
- name: string;
- secrets?: { secretId: string; referencedSecretKey: string; referencedSecretEnv: string }[];
- isImported: boolean;
- }[];
- }[];
-};
-
-export const SecretOverviewTableRow = ({
- secretKey,
- environments = [],
- secretPath,
- getSecretByKey,
- onSecretUpdate,
- onSecretCreate,
- onSecretDelete,
- isImportedSecretPresentInEnv,
- getImportedSecretByKey,
- scrollOffset,
- onToggleSecretSelect,
- isSelected,
- importedBy
-}: Props) => {
- const [isFormExpanded, setIsFormExpanded] = useToggle();
- const totalCols = environments.length + 1; // secret key row
- const [isSecretVisible, setIsSecretVisible] = useToggle();
-
- const { permission } = useProjectPermission();
-
- const getDefaultValue = (
- secret: SecretV3RawSanitized | undefined,
- importedSecret: { secret?: SecretV3RawSanitized } | undefined
- ) => {
- const canEditSecretValue = permission.can(
- ProjectPermissionSecretActions.Edit,
- subject(ProjectPermissionSub.Secrets, {
- environment: secret?.env || "",
- secretPath: secret?.path || "",
- secretName: secret?.key || "",
- secretTags: ["*"]
- })
- );
-
- if (secret?.secretValueHidden && !secret?.valueOverride) {
- return canEditSecretValue ? HIDDEN_SECRET_VALUE : "";
- }
- return secret?.valueOverride || secret?.value || importedSecret?.secret?.value || "";
- };
-
- return (
- <>
- <Tr isHoverable isSelectable onClick={() => setIsFormExpanded.toggle()} className="group">
- <Td
- className={`sticky left-0 z-10 bg-mineshaft-800 bg-clip-padding px-0 py-0 group-hover:bg-mineshaft-700 ${
- isFormExpanded && "border-t-2 border-mineshaft-500"
- }`}
- >
- <div className="h-full w-full border-r border-mineshaft-600 px-5 py-2.5">
- <div className="flex items-center space-x-5">
- <div className="text-bunker-300">
- <Checkbox
- id={`checkbox-${secretKey}`}
- isChecked={isSelected}
- onCheckedChange={() => {
- onToggleSecretSelect(secretKey);
- }}
- onClick={(e) => {
- e.stopPropagation();
- }}
- className={twMerge("hidden group-hover:flex", isSelected && "flex")}
- />
- <FontAwesomeIcon
- className={twMerge("block group-hover:!hidden", isSelected && "!hidden")}
- icon={isFormExpanded ? faAngleDown : faKey}
- />
- </div>
- <div title={secretKey}>{secretKey}</div>
- </div>
- </div>
- </Td>
- {environments.map(({ slug }, i) => {
- const secret = getSecretByKey(slug, secretKey);
-
- const isSecretImported = isImportedSecretPresentInEnv(slug, secretKey);
-
- const isSecretPresent = Boolean(secret);
- const isSecretEmpty = secret?.isEmpty;
- return (
- <Td
- key={`sec-overview-${slug}-${i + 1}-value`}
- className={twMerge(
- "border-r border-mineshaft-600 px-0 py-3 group-hover:bg-mineshaft-700",
- isFormExpanded && "border-t-2 border-mineshaft-500",
- (isSecretPresent && !isSecretEmpty) || isSecretImported ? "text-green-600" : "",
- isSecretPresent && isSecretEmpty && !isSecretImported ? "text-mineshaft-400" : "",
- !isSecretPresent && !isSecretEmpty && !isSecretImported ? "text-red-600" : ""
- )}
- >
- <div className="mx-auto flex w-[0.03rem] justify-center">
- <div className="flex justify-center">
- {!isSecretEmpty && (
- <Tooltip
- center
- content={
- // eslint-disable-next-line no-nested-ternary
- isSecretPresent
- ? "Present secret"
- : isSecretImported
- ? "Imported secret"
- : "Missing secret"
- }
- >
- <FontAwesomeIcon
- // eslint-disable-next-line no-nested-ternary
- icon={isSecretPresent ? faCheck : isSecretImported ? faFileImport : faXmark}
- />
- </Tooltip>
- )}
- {isSecretEmpty && (
- <Tooltip content="Empty value">
- <FontAwesomeIcon size="sm" icon={faCircle} className="text-yellow" />
- </Tooltip>
- )}
- </div>
- </div>
- </Td>
- );
- })}
- </Tr>
- {isFormExpanded && (
- <Tr>
- <Td
- colSpan={totalCols}
- className={`bg-bunker-600 px-0 py-0 ${
- isFormExpanded && "border-b-2 border-mineshaft-500"
- }`}
- >
- <div className="ml-2 p-2" style={getExpandedRowStyle(scrollOffset)}>
- <SecretRenameRow
- secretKey={secretKey}
- environments={environments}
- secretPath={secretPath}
- getSecretByKey={getSecretByKey}
- />
- <TableContainer>
- <table className="secret-table">
- <thead>
- <tr className="h-10 border-b-2 border-mineshaft-600">
- <th style={{ padding: "0.5rem 1rem" }} className="min-table-row min-w-44">
- Environment
- </th>
- <th style={{ padding: "0.5rem 1rem" }} className="border-none">
- Value
- </th>
- <div className="absolute top-0 right-0 mt-1 mr-1 ml-auto w-min">
- <Button
- variant="outline_bg"
- className="p-1"
- leftIcon={<FontAwesomeIcon icon={isSecretVisible ? faEyeSlash : faEye} />}
- onClick={() => setIsSecretVisible.toggle()}
- >
- {isSecretVisible ? "Hide Values" : "Reveal Values"}
- </Button>
- </div>
- </tr>
- </thead>
- <tbody className="border-t-2 border-mineshaft-600">
- {environments.map(({ name, slug }) => {
- const secret = getSecretByKey(slug, secretKey);
- const isCreatable = !secret;
-
- const isImportedSecret = isImportedSecretPresentInEnv(slug, secretKey);
- const importedSecret = getImportedSecretByKey(slug, secretKey);
-
- return (
- <tr
- key={`secret-expanded-${slug}-${secretKey}`}
- className="hover:bg-mineshaft-700"
- >
- <td
- className="flex h-full items-center"
- style={{ padding: "0.25rem 1rem" }}
- >
- <div title={name} className="flex h-8 w-32 items-center space-x-2">
- <span className="truncate">{name}</span>
- {isImportedSecret && (
- <Tooltip
- content={`Imported secret from the '${importedSecret?.environmentInfo?.name}' environment`}
- >
- <FontAwesomeIcon icon={faFileImport} />
- </Tooltip>
- )}
- {secret?.isRotatedSecret && (
- <Tooltip content="Rotated Secret">
- <FontAwesomeIcon icon={faRotate} />
- </Tooltip>
- )}
- {secret?.isHoneyTokenSecret && (
- <Tooltip content="Honey Token Secret">
- <FontAwesomeIcon icon={faShieldHalved} className="text-yellow" />
- </Tooltip>
- )}
- {secret?.idOverride && (
- <Tooltip content="Personal Override">
- <FontAwesomeIcon icon={faCodeBranch} />
- </Tooltip>
- )}
- </div>
- </td>
- <td className="col-span-2 h-8 w-full">
- <SecretEditRow
- secretPath={secretPath}
- isVisible={isSecretVisible}
- secretName={secretKey}
- isEmpty={secret?.isEmpty}
- secretValueHidden={secret?.secretValueHidden || false}
- defaultValue={getDefaultValue(secret, importedSecret)}
- secretId={secret?.id}
- isOverride={Boolean(secret?.idOverride)}
- isImportedSecret={isImportedSecret}
- importedSecret={importedSecret}
- isCreatable={isCreatable}
- onSecretDelete={onSecretDelete}
- onSecretCreate={onSecretCreate}
- onSecretUpdate={onSecretUpdate}
- environment={slug}
- isRotatedSecret={secret?.isRotatedSecret}
- isHoneyTokenSecret={secret?.isHoneyTokenSecret}
- importedBy={importedBy}
- isSecretPresent={Boolean(secret)}
- />
- </td>
- </tr>
- );
- })}
- </tbody>
- </table>
- </TableContainer>
- </div>
- </Td>
- </Tr>
- )}
- </>
- );
-};
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/SecretRenameRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/SecretRenameRow.tsx
deleted file mode 100644
index 38d259cd71..0000000000
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/SecretRenameRow.tsx
+++ /dev/null
@@ -1,284 +0,0 @@
-import { useEffect } from "react";
-import { Controller, useForm } from "react-hook-form";
-import { subject } from "@casl/ability";
-import { faCheck, faClose, faCopy, faWarning } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import { zodResolver } from "@hookform/resolvers/zod";
-import { AnimatePresence, motion } from "framer-motion";
-import { twMerge } from "tailwind-merge";
-import { z } from "zod";
-
-import { createNotification } from "@app/components/notifications";
-import { IconButton, Input, Spinner, Tooltip } from "@app/components/v2";
-import { ProjectPermissionSub, useProject, useProjectPermission } from "@app/context";
-import { ProjectPermissionSecretActions } from "@app/context/ProjectPermissionContext/types";
-import { useToggle } from "@app/hooks";
-import { useUpdateSecretV3 } from "@app/hooks/api";
-import { SecretType, SecretV3RawSanitized } from "@app/hooks/api/types";
-import { hasSecretReadValueOrDescribePermission } from "@app/lib/fn/permission";
-
-enum SecretActionType {
- Created = "created",
- Modified = "modified",
- Deleted = "deleted"
-}
-
-type Props = {
- secretKey: string;
- secretPath: string;
- environments: { name: string; slug: string }[];
- getSecretByKey: (slug: string, key: string) => SecretV3RawSanitized | undefined;
-};
-
-export const formSchema = z.object({
- key: z.string().trim().min(1, { message: "Secret key is required" })
-});
-
-type TFormSchema = z.infer<typeof formSchema>;
-
-function SecretRenameRow({ environments, getSecretByKey, secretKey, secretPath }: Props) {
- const { currentProject, projectId } = useProject();
- const { permission } = useProjectPermission();
-
- const secrets = environments.map((env) => getSecretByKey(env.slug, secretKey));
-
- const isReadOnly = environments.some((env) => {
- const environment = env.slug;
- const secretDetails = getSecretByKey(environment, secretKey);
- const secretPermissionSubject = subject(ProjectPermissionSub.Secrets, {
- environment,
- secretPath,
- secretName: secretKey,
- secretTags: (secretDetails?.tags || []).map((i) => i.slug)
- });
- const isSecretInEnvReadOnly =
- hasSecretReadValueOrDescribePermission(
- permission,
- ProjectPermissionSecretActions.DescribeSecret,
- secretPermissionSubject
- ) && permission.cannot(ProjectPermissionSecretActions.Edit, secretPermissionSubject);
- if (isSecretInEnvReadOnly) {
- return true;
- }
- return false;
- });
-
- const isOverriden = secrets.some(
- (secret) =>
- secret?.overrideAction === SecretActionType.Created ||
- secret?.overrideAction === SecretActionType.Modified
- );
-
- const isManagedSecret = secrets.some(
- (secret) => secret?.isRotatedSecret || secret?.isHoneyTokenSecret
- );
-
- const [isSecNameCopied, setIsSecNameCopied] = useToggle(false);
-
- const { mutateAsync: updateSecretV3 } = useUpdateSecretV3();
-
- const {
- handleSubmit,
- control,
- reset,
- trigger,
- watch,
- getValues,
- formState: { isDirty, isSubmitting, errors }
- } = useForm<TFormSchema>({
- defaultValues: { key: secretKey },
- values: { key: secretKey },
- resolver: zodResolver(formSchema)
- });
-
- useEffect(() => {
- let timer: NodeJS.Timeout;
- if (isSecNameCopied) {
- timer = setTimeout(() => setIsSecNameCopied.off(), 2000);
- }
- return () => clearTimeout(timer);
- }, [isSecNameCopied]);
-
- const handleFormSubmit = async (data: TFormSchema) => {
- if (!data.key) {
- createNotification({
- type: "error",
- text: "Secret name cannot be empty"
- });
- return;
- }
-
- const promises = secrets
- .filter((secret) => !!secret)
- .map((secret) => {
- if (!secret) return null;
-
- return updateSecretV3({
- environment: secret?.env,
- projectId,
- secretPath,
- secretKey: secret.key,
- type: SecretType.Shared,
- newSecretName: data.key
- });
- });
-
- await Promise.all(promises)
- .then(() => {
- createNotification({
- type: "success",
- text: "Successfully renamed the secret"
- });
- })
- .catch(() => {
- createNotification({
- type: "error",
- text: "Error renaming the secret"
- });
- });
- };
-
- const copyTokenToClipboard = () => {
- const [key] = getValues(["key"]);
- navigator.clipboard.writeText(key as string);
- setIsSecNameCopied.on();
- };
-
- const currentSecretValue = watch("key");
-
- return (
- <form
- onSubmit={handleSubmit(handleFormSubmit)}
- className="relative mb-2 flex secret-table w-full flex-row items-center justify-between overflow-hidden rounded-lg border border-solid border-mineshaft-700 bg-mineshaft-800 font-inter"
- >
- <div className="flex h-11 flex-1 shrink-0 items-center">
- <span className="flex h-full min-w-44 items-center justify-between gap-2 border-r-2 border-mineshaft-600 px-4">
- Key
- {currentSecretValue?.trim()?.includes(" ") &&
- currentSecretValue?.trim() !== secretKey && (
- <Tooltip
- className="w-full max-w-72"
- content={
- <div>
- Secret key contains whitespaces.
- <br />
- <br /> If this is the desired format, you need to provide it as{" "}
- <code className="rounded-md bg-mineshaft-500 px-1 py-0.5">
- {encodeURIComponent(secretKey.trim())}
- </code>{" "}
- when making API requests.
- </div>
- }
- >
- <FontAwesomeIcon icon={faWarning} className="text-yellow-600" />
- </Tooltip>
- )}
- </span>
-
- <Controller
- name="key"
- control={control}
- render={({ field, fieldState: { error } }) => (
- <Input
- autoComplete="off"
- isReadOnly={isReadOnly || isManagedSecret || secrets.filter(Boolean).length === 0}
- autoCapitalization={currentProject?.autoCapitalization}
- variant="plain"
- isDisabled={isOverriden}
- placeholder={error?.message}
- onKeyUp={() => trigger("key")}
- isError={Boolean(error)}
- {...field}
- className="w-full px-2 placeholder:text-red-500 focus:text-bunker-100 focus:ring-transparent"
- />
- )}
- />
- </div>
-
- {isReadOnly || isOverriden || isManagedSecret ? (
- <span className="mr-5 rounded-md bg-mineshaft-500 px-2">Read Only</span>
- ) : (
- <div className="group flex w-20 items-center justify-center border-l border-mineshaft-500 py-1">
- <AnimatePresence mode="wait">
- {!isDirty ? (
- <motion.div
- key="options"
- className="flex shrink-0 items-center space-x-4 px-3"
- initial={{ x: 0, opacity: 0 }}
- animate={{ x: 0, opacity: 1 }}
- exit={{ x: 10, opacity: 0 }}
- >
- <div className="relative">
- <Tooltip content="Copy secret name">
- <IconButton
- ariaLabel="copy-value"
- variant="plain"
- size="sm"
- className="p-0 opacity-100"
- onClick={copyTokenToClipboard}
- >
- <FontAwesomeIcon icon={isSecNameCopied ? faCheck : faCopy} />
- </IconButton>
- </Tooltip>
- </div>
- </motion.div>
- ) : (
- <motion.div
- key="options-save"
- className="flex shrink-0 items-center space-x-4 px-3"
- initial={{ x: -10, opacity: 0 }}
- animate={{ x: 0, opacity: 1 }}
- exit={{ x: -10, opacity: 0 }}
- >
- <div className="relative">
- <Tooltip content={errors.key ? errors.key.message : "Save"}>
- <IconButton
- ariaLabel="more"
- variant="plain"
- type="submit"
- size="md"
- className={twMerge(
- "p-0 text-primary opacity-0 group-hover:opacity-100",
- isDirty && "opacity-100"
- )}
- isDisabled={isSubmitting || Boolean(errors.key)}
- >
- {isSubmitting ? (
- <Spinner className="m-0 h-4 w-4 p-0" />
- ) : (
- <FontAwesomeIcon
- icon={faCheck}
- size="lg"
- className={twMerge("text-primary", errors.key && "text-mineshaft-400")}
- />
- )}
- </IconButton>
- </Tooltip>
- </div>
- <div className="relative">
- <Tooltip content="Cancel">
- <IconButton
- ariaLabel="more"
- variant="plain"
- size="md"
- className={twMerge(
- "p-0 opacity-0 group-hover:opacity-100",
- isDirty && "opacity-100"
- )}
- onClick={() => reset()}
- isDisabled={isSubmitting}
- >
- <FontAwesomeIcon icon={faClose} size="lg" />
- </IconButton>
- </Tooltip>
- </div>
- </motion.div>
- )}
- </AnimatePresence>
- </div>
- )}
- </form>
- );
-}
-
-export default SecretRenameRow;
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/index.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/index.tsx
deleted file mode 100644
index 5b7f3847fa..0000000000
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretOverviewTableRow/index.tsx
+++ /dev/null
@@ -1,2 +0,0 @@
-export { SecretNoAccessOverviewTableRow } from "./SecretNoAccessOverviewTableRow";
-export { SecretOverviewTableRow } from "./SecretOverviewTableRow";
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretTableRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretTableRow.tsx
index 1902443010..443882481f 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretTableRow.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SecretTableRow/SecretTableRow.tsx
@@ -280,7 +280,7 @@ export const SecretTableRow = ({
{singleEnvSecret?.isHoneyTokenSecret && isSingleEnvView && (
<HexagonIcon
className={twMerge(
- "absolute right-2 bottom-2 !size-2.5 text-yellow",
+ "absolute right-2 bottom-2 !size-2.5 text-warning",
!isSelectionDisabled && "group-hover:!hidden",
isSelected && "!hidden"
)}
@@ -571,7 +571,7 @@ export const SecretTableRow = ({
{secret?.isHoneyTokenSecret && (
<Tooltip>
<TooltipTrigger asChild>
- <HexagonIcon className="size-4 text-yellow" />
+ <HexagonIcon className="size-4 text-warning" />
</TooltipTrigger>
<TooltipContent>Honey Token secret</TooltipContent>
</Tooltip>
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/SelectionPanel.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/SelectionPanel.tsx
index 1e5c0f129d..daa4fffbdf 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/SelectionPanel.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/SelectionPanel.tsx
@@ -21,7 +21,6 @@ import { ProjectPermissionSecretActions } from "@app/context/ProjectPermissionCo
import { usePopUp } from "@app/hooks";
import { useDeleteSecretBatch } from "@app/hooks/api";
import { ProjectSecretsImportedBy, UsedBySecretSyncs } from "@app/hooks/api/dashboard/types";
-import { TDashboardHoneyToken } from "@app/hooks/api/honeyTokens/types";
import { ProjectEnv } from "@app/hooks/api/projects/types";
import { PendingAction } from "@app/hooks/api/secretFolders/types";
import { TSecretRotationV2 } from "@app/hooks/api/secretRotationsV2";
@@ -42,8 +41,7 @@ import {
export enum EntryType {
FOLDER = "folder",
SECRET = "secret",
- SECRET_ROTATION = "secretRotation",
- HONEY_TOKEN = "honeyToken"
+ SECRET_ROTATION = "secretRotation"
}
type Props = {
@@ -53,7 +51,6 @@ type Props = {
[EntryType.FOLDER]: Record<string, Record<string, TSecretFolder>>;
[EntryType.SECRET]: Record<string, Record<string, SecretV3RawSanitized>>;
[EntryType.SECRET_ROTATION]: Record<string, Record<string, TSecretRotationV2>>;
- [EntryType.HONEY_TOKEN]: Record<string, Record<string, TDashboardHoneyToken>>;
};
importedBy?: ProjectSecretsImportedBy[] | null;
usedBySecretSyncs?: UsedBySecretSyncs[];
@@ -83,7 +80,6 @@ export const SelectionPanel = ({
const selectedFolderCount = Object.keys(selectedEntries.folder).length;
const selectedKeysCount = Object.keys(selectedEntries.secret).length;
const selectedRotationCount = Object.keys(selectedEntries.secretRotation).length;
- const selectedHoneyTokenCount = Object.keys(selectedEntries.honeyToken).length;
const isManagedSecretSelected = Object.values(selectedEntries.secret).some((record) =>
Object.values(record).some((secret) => secret.isRotatedSecret || secret.isHoneyTokenSecret)
);
@@ -91,8 +87,7 @@ export const SelectionPanel = ({
Object.values(record).some((secret) => secret.isHoneyTokenSecret)
);
- const selectedCount =
- selectedFolderCount + selectedKeysCount + selectedRotationCount + selectedHoneyTokenCount;
+ const selectedCount = selectedFolderCount + selectedKeysCount + selectedRotationCount;
const { currentProject, projectId } = useProject();
const userAvailableEnvs = currentProject?.environments || [];
@@ -305,16 +300,14 @@ export const SelectionPanel = ({
const areFoldersSelected = Boolean(Object.keys(selectedEntries[EntryType.FOLDER]).length);
const areRotationsSelected = selectedRotationCount > 0;
- const hasHoneyTokenSelected = isHoneyTokenSelected || Boolean(selectedHoneyTokenCount);
-
// folders are moved one at a time from the inline row action, so bulk move only handles
// secrets and rotations
const hasMovableSelection = selectedKeysCount > 0 || selectedRotationCount > 0;
const shouldShowMove = shouldShowDelete && hasMovableSelection;
- const isMoveDisabled = hasHoneyTokenSelected || areFoldersSelected;
+ const isMoveDisabled = isHoneyTokenSelected || areFoldersSelected;
let moveDisabledReason = "";
- if (hasHoneyTokenSelected) {
+ if (isHoneyTokenSelected) {
moveDisabledReason = "Moving honey tokens is not supported";
} else if (areFoldersSelected) {
moveDisabledReason = "Folders cannot be moved via multi-select";
@@ -335,13 +328,12 @@ export const SelectionPanel = ({
const isDuplicateDisabled =
areFoldersSelected ||
isHoneyTokenSelected ||
- Boolean(selectedHoneyTokenCount) ||
areRotationsSelected ||
isManagedSecretSelected ||
duplicateSourceEnvSlugs.size > 1;
let duplicateDisabledReason = "Folders cannot be duplicated";
- if (isHoneyTokenSelected || Boolean(selectedHoneyTokenCount)) {
+ if (isHoneyTokenSelected) {
duplicateDisabledReason = "Honey token secrets cannot be duplicated";
} else if (areRotationsSelected || isManagedSecretSelected) {
duplicateDisabledReason = "Rotated secrets cannot be duplicated";
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem.tsx
index 83fff18296..e6f3bd2ca4 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretItem.tsx
@@ -43,13 +43,8 @@ import { twMerge } from "tailwind-merge";
import { ProjectPermissionSecretActions } from "@app/context/ProjectPermissionContext/types";
import { hasSecretReadValueOrDescribePermission } from "@app/lib/fn/permission";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-import {
- faEyeSlash,
- faKey,
- faRotate,
- faShieldHalved,
- faWarning
-} from "@fortawesome/free-solid-svg-icons";
+import { faEyeSlash, faKey, faRotate, faWarning } from "@fortawesome/free-solid-svg-icons";
+import { HexagonIcon } from "lucide-react";
import { PendingAction } from "@app/hooks/api/secretFolders/types";
import { format } from "date-fns";
import { CreateReminderForm } from "@app/pages/secret-manager/SecretDashboardPage/components/SecretListView/CreateReminderForm";
@@ -449,14 +444,15 @@ export const SecretItem = memo(
{isManagedSecret ? (
<div className="relative">
<FontAwesomeIcon icon={faKey} size="xs" className={twMerge("ml-3 h-3.5 w-3.5")} />
- <FontAwesomeIcon
- icon={isHoneyTokenSecret ? faShieldHalved : faRotate}
- size="xs"
- className={twMerge(
- "absolute -right-[0.2rem] -bottom-[0.05rem]",
- isHoneyTokenSecret ? "text-yellow" : "text-mineshaft-400"
- )}
- />
+ {isHoneyTokenSecret ? (
+ <HexagonIcon className="absolute -right-[0.2rem] -bottom-[0.05rem] size-3 text-warning" />
+ ) : (
+ <FontAwesomeIcon
+ icon={faRotate}
+ size="xs"
+ className="absolute -right-[0.2rem] -bottom-[0.05rem] text-mineshaft-400"
+ />
+ )}
</div>
) : (
<>