Skip to content

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

improvement(ui): migrate project service tokens to v3 (#7661)

Andrew Huang3e32d0469321
diff --git a/.gitignore b/.gitignore
index bed5cdc34f..b90ecb360e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,7 @@ node_modules
# dependencies
/node_modules
+/.pnpm-store/
/.pnp
.pnp.js
diff --git a/frontend/src/components/v3/generic/AlertDialog/AlertDialog.stories.tsx b/frontend/src/components/v3/generic/AlertDialog/AlertDialog.stories.tsx
index 909c611286..696ad83bee 100644
--- a/frontend/src/components/v3/generic/AlertDialog/AlertDialog.stories.tsx
+++ b/frontend/src/components/v3/generic/AlertDialog/AlertDialog.stories.tsx
@@ -3,12 +3,14 @@ import type { Meta, StoryObj } from "@storybook/react-vite";
import { LogOutIcon, TrashIcon } from "lucide-react";
import { Button } from "../Button";
+import { Field } from "../Field";
import { Input } from "../Input";
-import { Label } from "../Label";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
+ AlertDialogConfirmationField,
+ AlertDialogConfirmationLabel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
@@ -189,14 +191,23 @@ export const SmallSize: Story = {
)
};
-const CONFIRMATION_KEYWORD = "delete";
+const PROJECT_NAME = "production-api";
const TypedConfirmationStory = () => {
+ const [isOpen, setIsOpen] = useState(false);
+ const [isPending, setIsPending] = useState(false);
const [confirmation, setConfirmation] = useState("");
- const isConfirmed = confirmation === CONFIRMATION_KEYWORD;
+ const isConfirmed = confirmation === PROJECT_NAME;
return (
- <AlertDialog onOpenChange={(open) => !open && setConfirmation("")}>
+ <AlertDialog
+ open={isOpen}
+ onOpenChange={(open) => {
+ if (isPending) return;
+ setIsOpen(open);
+ if (!open) setConfirmation("");
+ }}
+ >
<AlertDialogTrigger asChild>
<Button variant="danger">
<TrashIcon />
@@ -211,18 +222,39 @@ const TypedConfirmationStory = () => {
history. This action cannot be undone.
</AlertDialogDescription>
</AlertDialogHeader>
- <div className="flex flex-col gap-2">
- <Label htmlFor="alert-dialog-confirmation">Type &quot;delete&quot; to confirm</Label>
- <Input
- id="alert-dialog-confirmation"
- value={confirmation}
- onChange={(e) => setConfirmation(e.target.value)}
- autoComplete="off"
- />
- </div>
+ <AlertDialogConfirmationField>
+ <Field>
+ <AlertDialogConfirmationLabel
+ htmlFor="alert-dialog-confirmation"
+ confirmationValue={PROJECT_NAME}
+ />
+ <Input
+ id="alert-dialog-confirmation"
+ value={confirmation}
+ onChange={(e) => setConfirmation(e.target.value)}
+ placeholder={PROJECT_NAME}
+ autoComplete="off"
+ autoFocus
+ />
+ </Field>
+ </AlertDialogConfirmationField>
<AlertDialogFooter>
- <AlertDialogCancel>Cancel</AlertDialogCancel>
- <AlertDialogAction variant="danger" disabled={!isConfirmed}>
+ <AlertDialogCancel isDisabled={isPending}>Cancel</AlertDialogCancel>
+ <AlertDialogAction
+ variant="danger"
+ isPending={isPending}
+ isDisabled={!isConfirmed}
+ onClick={async (event) => {
+ event.preventDefault();
+ setIsPending(true);
+ await new Promise((resolve) => {
+ setTimeout(resolve, 800);
+ });
+ setIsPending(false);
+ setIsOpen(false);
+ setConfirmation("");
+ }}
+ >
Delete project
</AlertDialogAction>
</AlertDialogFooter>
@@ -237,7 +269,7 @@ export const TypedConfirmation: Story = {
docs: {
description: {
story:
- "Add an `Input` between the header and footer that requires the user to type a keyword before the destructive action is enabled. Use this pattern for tier-two destructive actions (delete account, delete project) where an extra deliberate step reduces accidental loss. The input clears whenever the dialog closes."
+ "Require the resource name for high-consequence deletion. Pass it to `confirmationValue`, mirror it in the input placeholder, focus the input when the dialog opens, and clear it on close. During an asynchronous action, prevent the default close, show `isPending`, and disable cancellation until the operation completes. A fixed keyword can be used when no stable resource name is available."
}
}
},
diff --git a/frontend/src/components/v3/generic/AlertDialog/AlertDialog.tsx b/frontend/src/components/v3/generic/AlertDialog/AlertDialog.tsx
index d484f6902a..64696a0c97 100644
--- a/frontend/src/components/v3/generic/AlertDialog/AlertDialog.tsx
+++ b/frontend/src/components/v3/generic/AlertDialog/AlertDialog.tsx
@@ -4,6 +4,7 @@ import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
import { cn } from "../../utils";
import { Button } from "../Button";
import { DIALOG_CONTENT_WIDTH_CLASSNAME } from "../Dialog";
+import { FieldLabel } from "../Field";
function AlertDialog({ ...props }: React.ComponentProps<typeof AlertDialogPrimitive.Root>) {
return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />;
@@ -77,7 +78,7 @@ function AlertDialogFooter({ className, ...props }: React.ComponentProps<"div">)
<div
data-slot="alert-dialog-footer"
className={cn(
- "-mx-4 -mb-4 flex flex-row flex-wrap justify-end gap-2 rounded-b-xl border-t border-border p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2",
+ "-mx-4 -mb-4 flex flex-row flex-wrap justify-end gap-2 rounded-b-xl border-t border-border bg-container p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2",
className
)}
{...props}
@@ -136,6 +137,28 @@ function AlertDialogConfirmationField({ className, ...props }: React.ComponentPr
);
}
+function AlertDialogConfirmationLabel({
+ className,
+ confirmationValue,
+ ...props
+}: Omit<React.ComponentProps<typeof FieldLabel>, "children"> & {
+ confirmationValue: React.ReactNode;
+}) {
+ return (
+ <FieldLabel
+ data-slot="alert-dialog-confirmation-label"
+ size="sm"
+ className={cn("gap-0", className)}
+ {...props}
+ >
+ <span>
+ Type &quot;<span className="font-medium text-foreground">{confirmationValue}</span>&quot; to
+ confirm.
+ </span>
+ </FieldLabel>
+ );
+}
+
function AlertDialogAction({
className,
variant = "outline",
@@ -193,6 +216,7 @@ export {
AlertDialogAction,
AlertDialogCancel,
AlertDialogConfirmationField,
+ AlertDialogConfirmationLabel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
diff --git a/frontend/src/components/v3/generic/Table/Table.stories.tsx b/frontend/src/components/v3/generic/Table/Table.stories.tsx
index 9031abb3e9..3224559bd1 100644
--- a/frontend/src/components/v3/generic/Table/Table.stories.tsx
+++ b/frontend/src/components/v3/generic/Table/Table.stories.tsx
@@ -3,7 +3,6 @@ import type { Meta, StoryObj } from "@storybook/react-vite";
import {
BoxIcon as ProjectIcon,
ChevronDownIcon,
- ChevronsUpDownIcon,
CopyIcon,
EditIcon,
MoreHorizontalIcon,
@@ -21,6 +20,7 @@ import {
Pagination
} from "@app/components/v3/generic";
+import { cn } from "../../utils";
import {
Table,
TableBody,
@@ -29,7 +29,8 @@ import {
TableFooter,
TableHead,
TableHeader,
- TableRow
+ TableRow,
+ type TableSortDirection
} from "./Table";
type Identity = {
@@ -90,8 +91,9 @@ const identities: Identity[] = [
* ellipsis instead of letting the column blow out the row width.
* - **`data-state="selected"`** on a `TableRow` paints the selected highlight
* for row-checkbox patterns.
- * - A `TableHead` with a child icon flips to a sortable look — clickable
- * cursor and inline icon — without any extra wiring.
+ * - **`onSortChange`** on `TableHead` renders an accessible, full-cell sort button.
+ * Control it with `sortDirection`; each activation cycles none → ascending →
+ * descending → none.
*
* For datasets that don't fit on a single screen, pair the `Table` with the
* `Pagination` component as a sibling below it — see *Example: With
@@ -260,36 +262,74 @@ export const WithSelection: Story = {
)
};
-export const SortableHeaders: Story = {
- name: "Example: Sortable Headers",
- parameters: {
- docs: {
- description: {
- story:
- "Drop a sort-indicator icon as a child of `TableHead` and the cell automatically picks up a clickable cursor and an inline icon slot. Wire `onClick` to your sort handler; rotate or fade the icon to reflect the active column and direction."
- }
- }
- },
- render: () => (
+type SortableColumn = "managedBy" | "name" | "role";
+
+const SortableHeadersExample = () => {
+ const [sort, setSort] = useState<{
+ column: SortableColumn;
+ direction: Exclude<TableSortDirection, "none">;
+ } | null>(null);
+
+ const getSortDirection = (column: SortableColumn): TableSortDirection =>
+ sort?.column === column ? sort.direction : "none";
+
+ const handleSortChange = (column: SortableColumn, direction: TableSortDirection) => {
+ setSort(direction === "none" ? null : { column, direction });
+ };
+
+ const getSortIconClassName = (column: SortableColumn) => {
+ const direction = getSortDirection(column);
+
+ return cn(
+ "transition-transform",
+ direction === "descending" && "rotate-180",
+ direction === "none" && "opacity-30"
+ );
+ };
+
+ const sortedIdentities = identities.slice(0, 4);
+
+ if (sort) {
+ sortedIdentities.sort((a, b) => {
+ const getValue = (identity: Identity) => {
+ if (sort.column === "managedBy") return identity.managedBy?.name ?? "";
+ return identity[sort.column];
+ };
+
+ const comparison = getValue(a).localeCompare(getValue(b));
+ return sort.direction === "ascending" ? comparison : -comparison;
+ });
+ }
+
+ return (
<Table>
<TableHeader>
<TableRow>
- <TableHead onClick={() => {}}>
+ <TableHead
+ sortDirection={getSortDirection("name")}
+ onSortChange={(direction) => handleSortChange("name", direction)}
+ >
Name
- <ChevronDownIcon />
+ <ChevronDownIcon className={getSortIconClassName("name")} />
</TableHead>
- <TableHead onClick={() => {}}>
+ <TableHead
+ sortDirection={getSortDirection("role")}
+ onSortChange={(direction) => handleSortChange("role", direction)}
+ >
Role
- <ChevronsUpDownIcon className="opacity-30" />
+ <ChevronDownIcon className={getSortIconClassName("role")} />
</TableHead>
- <TableHead onClick={() => {}}>
+ <TableHead
+ sortDirection={getSortDirection("managedBy")}
+ onSortChange={(direction) => handleSortChange("managedBy", direction)}
+ >
Managed by
- <ChevronsUpDownIcon className="opacity-30" />
+ <ChevronDownIcon className={getSortIconClassName("managedBy")} />
</TableHead>
</TableRow>
</TableHeader>
<TableBody>
- {identities.slice(0, 4).map((id) => (
+ {sortedIdentities.map((id) => (
<TableRow key={id.name}>
<TableCell className="font-medium">{id.name}</TableCell>
<TableCell>{id.role}</TableCell>
@@ -298,7 +338,20 @@ export const SortableHeaders: Story = {
))}
</TableBody>
</Table>
- )
+ );
+};
+
+export const SortableHeaders: Story = {
+ name: "Example: Sortable Headers",
+ parameters: {
+ docs: {
+ description: {
+ story:
+ "Pass `onSortChange` to render a keyboard-operable, full-cell sort button. Control it with `sortDirection`; each activation cycles from none to ascending, descending, and back to none."
+ }
+ }
+ },
+ render: () => <SortableHeadersExample />
};
export const TruncatedCells: Story = {
diff --git a/frontend/src/components/v3/generic/Table/Table.tsx b/frontend/src/components/v3/generic/Table/Table.tsx
index e2b8e26355..f453e22334 100644
--- a/frontend/src/components/v3/generic/Table/Table.tsx
+++ b/frontend/src/components/v3/generic/Table/Table.tsx
@@ -79,22 +79,53 @@ const TableRow = React.forwardRef<HTMLTableRowElement, React.ComponentProps<"tr"
TableRow.displayName = "TableRow";
+type TableSortDirection = "ascending" | "descending" | "none";
+
+const nextTableSortDirection: Record<TableSortDirection, TableSortDirection> = {
+ none: "ascending",
+ ascending: "descending",
+ descending: "none"
+};
+
function TableHead({
className,
+ children,
isTruncatable,
+ "aria-sort": ariaSort,
+ onSortChange,
+ sortDirection = "none",
...props
-}: React.ComponentProps<"th"> & { isTruncatable?: boolean }) {
+}: React.ComponentProps<"th"> & {
+ isTruncatable?: boolean;
+ onSortChange?: (direction: TableSortDirection) => void;
+ sortDirection?: TableSortDirection;
+}) {
return (
<th
data-slot="table-head"
className={cn(
"h-[30px] border-x-0 border-t-0 border-b border-border px-3 text-left align-middle text-xs whitespace-nowrap text-accent select-none [&:has([role=checkbox])]:pr-0",
"has-[>svg]:cursor-pointer [&>svg]:ml-1 [&>svg]:inline-block [&>svg:not([class*='size-'])]:size-4",
+ onSortChange && "p-0",
isTruncatable && "truncate",
className
)}
+ aria-sort={onSortChange ? sortDirection : ariaSort}
{...props}
- />
+ >
+ {onSortChange ? (
+ <button
+ type="button"
+ data-slot="table-head-sort-trigger"
+ className="flex h-[30px] w-full cursor-pointer items-center gap-1 px-3 text-left text-xs text-accent outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset [&>svg]:shrink-0 [&>svg:not([class*='size-'])]:size-4"
+ onClick={() => onSortChange(nextTableSortDirection[sortDirection])}
+ >
+ {children}
+ </button>
+ ) : (
+ children
+ )}
+ </th>
);
}
@@ -156,5 +187,6 @@ export {
TableHead,
TableHeader,
TableHeadLabel,
- TableRow
+ TableRow,
+ type TableSortDirection
};
diff --git a/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayPageHeader/GatewayPageHeader.tsx b/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayPageHeader/GatewayPageHeader.tsx
index c252e4af03..9c10eb7022 100644
--- a/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayPageHeader/GatewayPageHeader.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/GatewayDetailsByIDPage/components/GatewayPageHeader/GatewayPageHeader.tsx
@@ -12,6 +12,7 @@ import {
AlertDialogAction,
AlertDialogCancel,
AlertDialogConfirmationField,
+ AlertDialogConfirmationLabel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
@@ -23,7 +24,6 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
Field,
- FieldLabel,
Input
} from "@app/components/v3";
import {
@@ -164,12 +164,10 @@ export const GatewayPageHeader = ({ gateway, orgId }: { gateway: TGatewayV2; org
</AlertDialogHeader>
<AlertDialogConfirmationField>
<Field>
- <FieldLabel htmlFor="delete-gateway-confirmation" size="sm">
- <span>
- Type &quot;<span className="text-foreground">{gateway.name}</span>&quot; to
- confirm.
- </span>
- </FieldLabel>
+ <AlertDialogConfirmationLabel
+ htmlFor="delete-gateway-confirmation"
+ confirmationValue={gateway.name}
+ />
<Input
id="delete-gateway-confirmation"
value={deleteConfirmation}
diff --git a/frontend/src/pages/organization/NetworkingPage/RelayDetailsByIDPage/components/RelayPageHeader/RelayPageHeader.tsx b/frontend/src/pages/organization/NetworkingPage/RelayDetailsByIDPage/components/RelayPageHeader/RelayPageHeader.tsx
index 49a75df337..a41ae4356c 100644
--- a/frontend/src/pages/organization/NetworkingPage/RelayDetailsByIDPage/components/RelayPageHeader/RelayPageHeader.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/RelayDetailsByIDPage/components/RelayPageHeader/RelayPageHeader.tsx
@@ -12,6 +12,7 @@ import {
AlertDialogAction,
AlertDialogCancel,
AlertDialogConfirmationField,
+ AlertDialogConfirmationLabel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
@@ -23,7 +24,6 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
Field,
- FieldLabel,
Input
} from "@app/components/v3";
import {
@@ -152,11 +152,10 @@ export const RelayPageHeader = ({
</AlertDialogHeader>
<AlertDialogConfirmationField>
<Field>
- <FieldLabel htmlFor="delete-relay-confirmation" size="sm">
- <span>
- Type &quot;<span className="text-foreground">{relay.name}</span>&quot; to confirm.
- </span>
- </FieldLabel>
+ <AlertDialogConfirmationLabel
+ htmlFor="delete-relay-confirmation"
+ confirmationValue={relay.name}
+ />
<Input
id="delete-relay-confirmation"
value={deleteConfirmation}
diff --git a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx
index 5290bfb2e4..8b8dc72cdb 100644
--- a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/GatewayTab.tsx
@@ -23,6 +23,7 @@ import {
AlertDialogAction,
AlertDialogCancel,
AlertDialogConfirmationField,
+ AlertDialogConfirmationLabel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
@@ -50,7 +51,6 @@ import {
EmptyMedia,
EmptyTitle,
Field,
- FieldLabel,
IconButton,
Input,
InputGroup,
@@ -486,15 +486,12 @@ export const GatewayTab = withPermission(
</AlertDialogHeader>
<AlertDialogConfirmationField>
<Field>
- <FieldLabel htmlFor="delete-gateway-confirmation" size="sm">
- <span>
- Type &quot;
- <span className="text-foreground">
- {(popUp.deleteGateway.data as { name?: string })?.name || "gateway"}
- </span>
- &quot; to confirm.
- </span>
- </FieldLabel>
+ <AlertDialogConfirmationLabel
+ htmlFor="delete-gateway-confirmation"
+ confirmationValue={
+ (popUp.deleteGateway.data as { name?: string })?.name || "gateway"
+ }
+ />
<Input
id="delete-gateway-confirmation"
value={deleteConfirmation}
diff --git a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayPoolsContent.tsx b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayPoolsContent.tsx
index 0a086b41c1..e3cfa86732 100644
--- a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayPoolsContent.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/GatewayPoolsContent.tsx
@@ -17,6 +17,7 @@ import {
AlertDialogAction,
AlertDialogCancel,
AlertDialogConfirmationField,
+ AlertDialogConfirmationLabel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
@@ -31,7 +32,6 @@ import {
EmptyMedia,
EmptyTitle,
Field,
- FieldLabel,
IconButton,
Input,
Skeleton,
@@ -246,15 +246,10 @@ export const GatewayPoolsContent = ({ search }: Props) => {
</AlertDialogHeader>
<AlertDialogConfirmationField>
<Field>
- <FieldLabel htmlFor="delete-pool-confirmation" size="sm">
- <span>
- Type &quot;
- <span className="text-foreground">
- {(popUp.deletePool.data as TGatewayPool)?.name}
- </span>
- &quot; to confirm.
- </span>
- </FieldLabel>
+ <AlertDialogConfirmationLabel
+ htmlFor="delete-pool-confirmation"
+ confirmationValue={(popUp.deletePool.data as TGatewayPool)?.name}
+ />
<Input
id="delete-pool-confirmation"
value={deleteConfirmation}
diff --git a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/PoolDetailSheet.tsx b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/PoolDetailSheet.tsx
index fc07b200ff..7462251d17 100644
--- a/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/PoolDetailSheet.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/components/GatewayTab/components/PoolDetailSheet.tsx
@@ -12,6 +12,7 @@ import {
AlertDialogAction,
AlertDialogCancel,
AlertDialogConfirmationField,
+ AlertDialogConfirmationLabel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
@@ -24,7 +25,6 @@ import {
DropdownMenuItem,
DropdownMenuTrigger,
Field,
- FieldLabel,
FilterableSelect,
IconButton,
Input,
@@ -308,15 +308,12 @@ export const PoolDetailSheet = ({ isOpen, onOpenChange, pool }: Props) => {
</AlertDialogHeader>
<AlertDialogConfirmationField>
<Field>
- <FieldLabel htmlFor="remove-gateway-confirmation" size="sm">
- <span>
- Type &quot;
- <span className="text-foreground">
- {(popUp.removeGateway.data as { name: string } | undefined)?.name}
- </span>
- &quot; to confirm.
- </span>
- </FieldLabel>
+ <AlertDialogConfirmationLabel
+ htmlFor="remove-gateway-confirmation"
+ confirmationValue={
+ (popUp.removeGateway.data as { name: string } | undefined)?.name
+ }
+ />
<Input
id="remove-gateway-confirmation"
value={removeConfirmation}
diff --git a/frontend/src/pages/organization/NetworkingPage/components/RelayTab/RelayTab.tsx b/frontend/src/pages/organization/NetworkingPage/components/RelayTab/RelayTab.tsx
index 122f54da33..e98ee4253e 100644
--- a/frontend/src/pages/organization/NetworkingPage/components/RelayTab/RelayTab.tsx
+++ b/frontend/src/pages/organization/NetworkingPage/components/RelayTab/RelayTab.tsx
@@ -20,6 +20,7 @@ import {
AlertDialogAction,
AlertDialogCancel,
AlertDialogConfirmationField,
+ AlertDialogConfirmationLabel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
@@ -43,7 +44,6 @@ import {
EmptyMedia,
EmptyTitle,
Field,
- FieldLabel,
IconButton,
Input,
InputGroup,
@@ -318,15 +318,12 @@ export const RelayTab = withPermission(
</AlertDialogHeader>
<AlertDialogConfirmationField>
<Field>
- <FieldLabel htmlFor="delete-relay-confirmation" size="sm">
- <span>
- Type &quot;
- <span className="text-foreground">
- {(popUp.deleteRelay.data as { name?: string })?.name || "relay"}
- </span>
- &quot; to confirm.
- </span>
- </FieldLabel>
+ <AlertDialogConfirmationLabel
+ htmlFor="delete-relay-confirmation"
+ confirmationValue={
+ (popUp.deleteRelay.data as { name?: string })?.name || "relay"
+ }
+ />
<Input
id="delete-relay-confirmation"
value={deleteConfirmation}
diff --git a/frontend/src/pages/project/AccessControlPage/AccessControlPage.tsx b/frontend/src/pages/project/AccessControlPage/AccessControlPage.tsx
index 5730738b3e..038a5b70b6 100644
--- a/frontend/src/pages/project/AccessControlPage/AccessControlPage.tsx
+++ b/frontend/src/pages/project/AccessControlPage/AccessControlPage.tsx
@@ -3,7 +3,8 @@ import { useTranslation } from "react-i18next";
import { Link, useNavigate, useSearch } from "@tanstack/react-router";
import { InfoIcon } from "lucide-react";
-import { PageHeader, Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
+import { Tab, TabList, TabPanel, Tabs } from "@app/components/v2";
+import { PageHeader } from "@app/components/v3";
import { useOrganization, useProject } from "@app/context";
import { getProjectBaseURL } from "@app/helpers/project";
import { ProjectType } from "@app/hooks/api/projects/types";
diff --git a/frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/ServiceTokenTab.tsx b/frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/ServiceTokenTab.tsx
index 8327b8322f..018b5098bb 100644
--- a/frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/ServiceTokenTab.tsx
+++ b/frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/ServiceTokenTab.tsx
@@ -1,39 +1,8 @@
-// import { faWarning } from "@fortawesome/free-solid-svg-icons";
-// import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
-
import { ServiceTokenSection } from "./components";
export const ServiceTokenTab = () => {
return (
<div className="space-y-3">
- {/* <div className="flex w-full flex-row items-center rounded-md border border-primary-600/70 bg-primary/[.07] p-4 text-base text-white">
- <FontAwesomeIcon icon={faWarning} className="pr-6 text-4xl text-white/80" />
- <div className="flex w-full flex-col text-sm">
- <span className="mb-4 text-lg font-medium">Deprecation Notice</span>
- <p>
- Service Tokens are being deprecated in favor of Machine Identities.
- <br />
- They will be removed in the future in accordance with the deprecation notice and
- timeline stated{" "}
- <a
- href="https://infisical.com/blog/deprecating-api-keys"
- target="_blank"
- className="font-medium text-primary-400" rel="noreferrer"
- >
- here
- </a>
- .
- <br />
- <a
- href="https://infisical.com/docs/documentation/platform/identities/overview"
- target="_blank"
- className="font-medium text-primary-400" rel="noreferrer"
- >
- Learn more about Machine Identities
- </a>
- </p>
- </div>
- </div> */}
<ServiceTokenSection />
</div>
);
diff --git a/frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/components/ServiceTokenSection/AddServiceTokenModal.tsx b/frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/components/ServiceTokenSection/AddServiceTokenModal.tsx
index 08071b5d96..4ec37335ca 100644
--- a/frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/components/ServiceTokenSection/AddServiceTokenModal.tsx
+++ b/frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/components/ServiceTokenSection/AddServiceTokenModal.tsx
@@ -1,6 +1,6 @@
import crypto from "crypto";
-import { useState } from "react";
+import { useId, useState } from "react";
import { Controller, useFieldArray, useForm } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { zodResolver } from "@hookform/resolvers/zod";
@@ -93,6 +93,7 @@ type Props = {
const ServiceTokenForm = () => {
const { t } = useTranslation();
+ const fieldId = useId();
const { currentProject } = useProject();
const {
@@ -162,9 +163,12 @@ const ServiceTokenForm = () => {
{hasServiceToken ? (
<>
<Field>
- <FieldLabel>{t("section.token.add-dialog.copy-service-token")}</FieldLabel>
+ <FieldLabel htmlFor={`${fieldId}-token`}>
+ {t("section.token.add-dialog.copy-service-token")}
+ </FieldLabel>
<ButtonGroup className="w-full">
<Input
+ id={`${fieldId}-token`}
value={newToken}
readOnly
aria-label="Service token"
@@ -200,10 +204,13 @@ const ServiceTokenForm = () => {
defaultValue=""
render={({ field, fieldState: { error } }) => (
<Field>
- <FieldLabel>{t("section.token.add-dialog.name")}</FieldLabel>
+ <FieldLabel htmlFor={`${fieldId}-name`}>
+ {t("section.token.add-dialog.name")}
+ </FieldLabel>
<FieldContent>
<Input
{...field}
+ id={`${fieldId}-name`}
autoFocus
isError={Boolean(error)}
placeholder="Type your token name"
@@ -222,10 +229,19 @@ const ServiceTokenForm = () => {
defaultValue={currentProject?.environments?.[0]?.slug}
render={({ field: { value, onChange }, fieldState: { error } }) => (
<Field className="min-w-0 flex-1">
- {index === 0 && <FieldLabel>Environment</FieldLabel>}
+ <FieldLabel
+ htmlFor={`${fieldId}-scope-${index}-environment`}
+ className={index === 0 ? undefined : "sr-only"}
+ >
+ Environment
+ </FieldLabel>
<FieldContent>
<Select value={value} onValueChange={onChange}>
- <SelectTrigger isError={Boolean(error)} className="w-full">
+ <SelectTrigger
+ id={`${fieldId}-scope-${index}-environment`}
+ isError={Boolean(error)}
+ className="w-full"
+ >
<SelectValue placeholder="Select environment">
<span className="truncate">
{
@@ -254,10 +270,16 @@ const ServiceTokenForm = () => {
defaultValue="/"
render={({ field, fieldState: { error } }) => (
<Field className="min-w-0 flex-1">
- {index === 0 && <FieldLabel>Secrets Path</FieldLabel>}
+ <FieldLabel
+ htmlFor={`${fieldId}-scope-${index}-secret-path`}
+ className={index === 0 ? undefined : "sr-only"}
+ >
+ Secrets Path
+ </FieldLabel>
<FieldContent>
<Input
{...field}
+ id={`${fieldId}-scope-${index}-secret-path`}
isError={Boolean(error)}
placeholder="can be /, /nested/**, /**/deep"
/>
@@ -313,10 +335,14 @@ const ServiceTokenForm = () => {
defaultValue={String(apiTokenExpiry?.[0]?.value)}
render={({ field: { value, onChange }, fieldState: { error } }) => (
<Field>
- <FieldLabel>Expiration</FieldLabel>
+ <FieldLabel htmlFor={`${fieldId}-expiration`}>Expiration</FieldLabel>
<FieldContent>
<Select value={value} onValueChange={onChange}>
- <SelectTrigger isError={Boolean(error)} className="w-full">
+ <SelectTrigger
+ id={`${fieldId}-expiration`}
+ isError={Boolean(error)}
+ className="w-full"
+ >
<SelectValue placeholder="Select expiration" />
</SelectTrigger>
<SelectContent>
diff --git a/frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/components/ServiceTokenSection/ServiceTokenSection.tsx b/frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/components/ServiceTokenSection/ServiceTokenSection.tsx
index 0ea96d35f0..41265a18b1 100644
--- a/frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/components/ServiceTokenSection/ServiceTokenSection.tsx
+++ b/frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/components/ServiceTokenSection/ServiceTokenSection.tsx
@@ -1,10 +1,22 @@
+import { useState } from "react";
import { useTranslation } from "react-i18next";
import { PlusIcon } from "lucide-react";
import { createNotification } from "@app/components/notifications";
import { ProjectPermissionCan } from "@app/components/permissions";
-import { DeleteActionModal } from "@app/components/v2";
import {
+ Alert,
+ AlertDescription,
+ AlertDialog,
+ AlertDialogAction,
+ AlertDialogCancel,
+ AlertDialogConfirmationField,
+ AlertDialogConfirmationLabel,
+ AlertDialogContent,
+ AlertDialogDescription,
+ AlertDialogFooter,
+ AlertDialogHeader,
+ AlertDialogTitle,
Button,
Card,
CardAction,
@@ -12,7 +24,9 @@ import {
CardDescription,
CardHeader,
CardTitle,
- DocumentationLinkBadge
+ DocumentationLinkBadge,
+ Field,
+ Input
} from "@app/components/v3";
import { ProjectPermissionActions, ProjectPermissionSub } from "@app/context";
import { withProjectPermission } from "@app/hoc";
@@ -29,22 +43,33 @@ export const ServiceTokenSection = withProjectPermission(
const { t } = useTranslation();
const deleteServiceToken = useDeleteServiceToken();
+ const [deleteConfirmation, setDeleteConfirmation] = useState("");
const { popUp, handlePopUpToggle, handlePopUpClose, handlePopUpOpen } = usePopUp([
"createAPIToken",
"deleteAPITokenConfirmation"
] as const);
+ const deleteModalData = popUp.deleteAPITokenConfirmation.data as DeleteModalData | undefined;
+ const deleteConfirmationText = deleteModalData?.name.trim() || "service token";
+ const isDeleteConfirmed =
+ Boolean(deleteModalData) && deleteConfirmation === deleteConfirmationText;
+
const onDeleteApproved = async () => {
- await deleteServiceToken.mutateAsync(
- (popUp?.deleteAPITokenConfirmation?.data as DeleteModalData)?.id
- );
- createNotification({
- text: "Successfully deleted service token",
- type: "success"
- });
+ if (!deleteModalData?.id) return;
+
+ try {
+ await deleteServiceToken.mutateAsync(deleteModalData.id);
+ createNotification({
+ text: "Successfully deleted service token",
+ type: "success"
+ });
- handlePopUpClose("deleteAPITokenConfirmation");
+ setDeleteConfirmation("");
+ handlePopUpClose("deleteAPITokenConfirmation");
+ } catch {
+ // MutationCache reports request errors globally; keep the dialog available for another attempt.
+ }
};
return (
@@ -81,16 +106,59 @@ export const ServiceTokenSection = withProjectPermission(
</CardContent>
</Card>
<AddServiceTokenModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
- <DeleteActionModal
- isOpen={popUp.deleteAPITokenConfirmation.isOpen}
- title={`Delete ${
- (popUp?.deleteAPITokenConfirmation?.data as DeleteModalData)?.name || " "
- } service token?`}
- onChange={(isOpen) => handlePopUpToggle("deleteAPITokenConfirmation", isOpen)}
- deleteKey={(popUp?.deleteAPITokenConfirmation?.data as DeleteModalData)?.name}
- onClose={() => handlePopUpClose("deleteAPITokenConfirmation")}
- onDeleteApproved={onDeleteApproved}
- />
+ <AlertDialog
+ open={popUp.deleteAPITokenConfirmation.isOpen}
+ onOpenChange={(isOpen) => {
+ if (deleteServiceToken.isPending) return;
+ if (!isOpen) setDeleteConfirmation("");
+ handlePopUpToggle("deleteAPITokenConfirmation", isOpen);
+ }}
+ >
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogTitle>Delete token?</AlertDialogTitle>
+ <AlertDialogDescription asChild>
+ <Alert variant="danger" appearance="borderless">
+ <AlertDescription>
+ This permanently revokes the service token and cannot be undone.
+ </AlertDescription>
+ </Alert>
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogConfirmationField>
+ <Field>
+ <AlertDialogConfirmationLabel
+ htmlFor="delete-service-token-confirmation"
+ confirmationValue={deleteConfirmationText}
+ />
+ <Input
+ id="delete-service-token-confirmation"
+ value={deleteConfirmation}
+ onChange={(event) => setDeleteConfirmation(event.target.value)}
+ placeholder={deleteConfirmationText}
+ autoComplete="off"
+ autoFocus
+ />
+ </Field>
+ </AlertDialogConfirmationField>
+ <AlertDialogFooter>
+ <AlertDialogCancel isDisabled={deleteServiceToken.isPending}>
+ Cancel
+ </AlertDialogCancel>
+ <AlertDialogAction
+ variant="danger"
+ isPending={deleteServiceToken.isPending}
+ isDisabled={!isDeleteConfirmed}
+ onClick={(event) => {
+ event.preventDefault();
+ onDeleteApproved();
+ }}
+ >
+ Delete Token
+ </AlertDialogAction>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
</>
);
},
diff --git a/frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/components/ServiceTokenSection/ServiceTokenTable.tsx b/frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/components/ServiceTokenSection/ServiceTokenTable.tsx
index fe341dc37f..227aae0e32 100644
--- a/frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/components/ServiceTokenSection/ServiceTokenTable.tsx
+++ b/frontend/src/pages/project/AccessControlPage/components/ServiceTokenTab/components/ServiceTokenSection/ServiceTokenTable.tsx
@@ -1,4 +1,4 @@
-import { useMemo } from "react";
+import { useMemo, useState } from "react";
import { format } from "date-fns";
import {
ChevronDownIcon,
@@ -64,6 +64,7 @@ enum TokensOrderBy {
export const ServiceTokenTable = ({ handlePopUpOpen }: Props) => {
const { currentProject } = useProject();
+ const [activeSort, setActiveSort] = useState<TokensOrderBy | null>(TokensOrderBy.Name);
const { data, isPending } = useGetUserWsServiceTokens({
workspaceID: currentProject?.id || ""
});
@@ -77,8 +78,6 @@ export const ServiceTokenTable = ({ handlePopUpOpen }: Props) => {
setPerPage,
offset,
orderDirection,
- toggleOrderDirection,
- orderBy,
setOrderDirection,
setOrderBy
} = usePagination<TokensOrderBy>(TokensOrderBy.Name, {
@@ -109,9 +108,11 @@ export const ServiceTokenTable = ({ handlePopUpOpen }: Props) => {
);
})
.sort((a, b) => {
+ if (!activeSort) return 0;
+
const [tokenOne, tokenTwo] = orderDirection === OrderByDirection.ASC ? [a, b] : [b, a];
- switch (orderBy) {
+ switch (activeSort) {
case TokensOrderBy.Expiration:
if (!tokenOne.expiresAt && !tokenTwo.expiresAt) return 0;
if (!tokenOne.expiresAt) return 1;
@@ -126,7 +127,7 @@ export const ServiceTokenTable = ({ handlePopUpOpen }: Props) => {
return tokenOne.name.toLowerCase().localeCompare(tokenTwo.name.toLowerCase());
}
}) ?? [],
- [data, orderDirection, search, orderBy]
+ [activeSort, data, orderDirection, search]
);
useResetPageHelper({
@@ -135,14 +136,20 @@ export const ServiceTokenTable = ({ handlePopUpOpen }: Props) => {
setPage
});
- const handleSort = (column: TokensOrderBy) => {
- if (column === orderBy) {
- toggleOrderDirection();
+ const handleSort = (column: TokensOrderBy, direction: "ascending" | "descending" | "none") => {
+ if (direction === "none") {
+ setActiveSort(null);
return;
}
+ setActiveSort(column);
setOrderBy(column);
- setOrderDirection(OrderByDirection.ASC);
+ setOrderDirection(direction === "ascending" ? OrderByDirection.ASC : OrderByDirection.DESC);
+ };
+
+ const getAriaSort = (column: TokensOrderBy) => {
+ if (activeSort !== column) return "none";
+ return orderDirection === OrderByDirection.ASC ? "ascending" : "descending";
};
return (
@@ -155,6 +162,7 @@ export const ServiceTokenTable = ({ handlePopUpOpen }: Props) => {
<InputGroupInput
value={search}
onChange={(e) => setSearch(e.target.value)}
+ aria-label="Search service tokens"
placeholder="Search service tokens by name, environment or secret path..."
/>
</InputGroup>
@@ -175,32 +183,40 @@ export const ServiceTokenTable = ({ handlePopUpOpen }: Props) => {
<Table>
<TableHeader>
<TableRow>
- <TableHead onClick={() => handleSort(TokensOrderBy.Name)}>
+ <TableHead
+ sortDirection={getAriaSort(TokensOrderBy.Name)}
+ onSortChange={(direction) => handleSort(TokensOrderBy.Name, direction)}
+ >
Name
<ChevronDownIcon
className={twMerge(
"transition-transform",
orderDirection === OrderByDirection.DESC &&
- orderBy === TokensOrderBy.Name &&
+ activeSort === TokensOrderBy.Name &&
"rotate-180",
- orderBy !== TokensOrderBy.Name && "opacity-30"
+ activeSort !== TokensOrderBy.Name && "opacity-30"
)}
/>
</TableHead>
<TableHead>Environment / Secret Path</TableHead>
- <TableHead onClick={() => handleSort(TokensOrderBy.Expiration)}>
+ <TableHead
+ sortDirection={getAriaSort(TokensOrderBy.Expiration)}
+ onSortChange={(direction) => handleSort(TokensOrderBy.Expiration, direction)}
+ >
Valid Until
<ChevronDownIcon
className={twMerge(
"transition-transform",
orderDirection === OrderByDirection.DESC &&
- orderBy === TokensOrderBy.Expiration &&
+ activeSort === TokensOrderBy.Expiration &&
"rotate-180",
- orderBy !== TokensOrderBy.Expiration && "opacity-30"
+ activeSort !== TokensOrderBy.Expiration && "opacity-30"
)}
/>
</TableHead>
- <TableHead className="w-5" />
+ <TableHead className="w-5">
+ <span className="sr-only">Actions</span>
+ </TableHead>
</TableRow>
</TableHeader>
<TableBody>
@@ -226,11 +242,11 @@ export const ServiceTokenTable = ({ handlePopUpOpen }: Props) => {
<TableRow key={row.id}>
<TableCell isTruncatable>{row.name}</TableCell>
<TableCell>
- <div className="flex flex-row flex-wrap gap-1">
+ <div className="flex flex-row gap-1">
{row?.scopes.map(({ secretPath, environment }) => (
<Badge key={`${row.id}-${environment}-${secretPath}`} variant="neutral">
<span className="border-r border-border pr-1.5">{environment}</span>
- <FolderIcon className="text-yellow" />
+ <FolderIcon className="text-folder" />
<span>{secretPath}</span>
</Badge>
))}
@@ -249,6 +265,7 @@ export const ServiceTokenTable = ({ handlePopUpOpen }: Props) => {
<IconButton
variant="ghost"
size="xs"
+ aria-label={`${row.name} actions`}
onClick={(e) => e.stopPropagation()}
>
<MoreHorizontalIcon />
diff --git a/frontend/src/pages/project/SettingsPage/components/DeleteProjectSection/DeleteProjectSection.tsx b/frontend/src/pages/project/SettingsPage/components/DeleteProjectSection/DeleteProjectSection.tsx
index 86b061d702..615761ef04 100644
--- a/frontend/src/pages/project/SettingsPage/components/DeleteProjectSection/DeleteProjectSection.tsx
+++ b/frontend/src/pages/project/SettingsPage/components/DeleteProjectSection/DeleteProjectSection.tsx
@@ -9,6 +9,7 @@ import {
AlertDialogAction,
AlertDialogCancel,
AlertDialogConfirmationField,
+ AlertDialogConfirmationLabel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
@@ -21,7 +22,6 @@ import {
CardHeader,
CardTitle,
Field,
- FieldLabel,
Input,
Tooltip,
TooltipContent,
@@ -170,10 +170,10 @@ export const DeleteProjectSection = () => {
</AlertDialogHeader>
<AlertDialogConfirmationField>
<Field>
- <FieldLabel htmlFor="delete-project-confirmation">
- Type <span className="font-bold text-foreground">{CONFIRM_KEYWORD}</span> to perform
- this action
- </FieldLabel>
+ <AlertDialogConfirmationLabel
+ htmlFor="delete-project-confirmation"
+ confirmationValue={CONFIRM_KEYWORD}
+ />
<Input
id="delete-project-confirmation"
value={deleteConfirmInput}
@@ -230,10 +230,10 @@ export const DeleteProjectSection = () => {
</AlertDialogHeader>
<AlertDialogConfirmationField>
<Field>
- <FieldLabel htmlFor="leave-project-confirmation">
- Type <span className="font-bold text-foreground">{CONFIRM_KEYWORD}</span> to leave
- the project
- </FieldLabel>
+ <AlertDialogConfirmationLabel
+ htmlFor="leave-project-confirmation"
+ confirmationValue={CONFIRM_KEYWORD}
+ />
<Input
id="leave-project-confirmation"
value={leaveConfirmInput}
diff --git a/frontend/src/views/Alerts/AlertAction.tsx b/frontend/src/views/Alerts/AlertAction.tsx
index 795b4e7f77..b240b26cc9 100644
--- a/frontend/src/views/Alerts/AlertAction.tsx
+++ b/frontend/src/views/Alerts/AlertAction.tsx
@@ -9,6 +9,7 @@ import {
AlertDialogAction,
AlertDialogCancel,
AlertDialogConfirmationField,
+ AlertDialogConfirmationLabel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
@@ -17,7 +18,6 @@ import {
Badge,
Button,
Field,
- FieldLabel,
Input,
Label,
Popover,
@@ -249,12 +249,10 @@ export const AlertAction = ({
</AlertDialogHeader>
<AlertDialogConfirmationField>
<Field>
- <FieldLabel htmlFor="delete-alert-confirmation" size="sm">
- <span>
- Type &quot;<span className="text-foreground">{existingAlert.name}</span>
- &quot; to confirm.
- </span>
- </FieldLabel>
+ <AlertDialogConfirmationLabel
+ htmlFor="delete-alert-confirmation"
+ confirmationValue={existingAlert.name}
+ />
<Input
id="delete-alert-confirmation"
value={deleteConfirmation}