Skip to content

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

improvement(ui): add V3 overlay layer contract and migrate first Modal and DeleteActionModal consumers (#8570)

Andrew Huangdffcd44c149e
diff --git a/frontend/src/components/COMPONENT_LIFECYCLE.md b/frontend/src/components/COMPONENT_LIFECYCLE.md
index 873dfe33c3..66d81c054c 100644
--- a/frontend/src/components/COMPONENT_LIFECYCLE.md
+++ b/frontend/src/components/COMPONENT_LIFECYCLE.md
@@ -11,7 +11,7 @@ The [V3 migration ledger](V3_MIGRATION.md) tracks source removal, coverage, and
| `FilterableSelect` | Deprecated | Use V3 `Combobox` where its contract fits. |
| `Button`, `Card`, `Checkbox`, `EmptyState`, `IconButton`, `Input`, `Pagination`, `Select`, `Switch`, `TextArea`, `Tooltip` | Ready for focused deprecation | Supported V3 replacements exist. Check representative consumers before adding component-specific guidance. |
| `Accordion`, `Alert`, `CopyButton`, `Dropdown`, `HoverCardv2`, `Skeleton`, `Spinner`, `Table`, `Tabs` | Blocked | Composition, interaction, or state parity still needs verification. |
-| `ConfirmActionModal`, `DeleteActionModal`, `Modal` | Blocked | Verify confirmation, menu-item, nested-overlay, and close behavior before directing consumers to V3 overlays. |
+| `ConfirmActionModal`, `DeleteActionModal`, `Modal` | Ready for focused deprecation | Follow the overlay recipe in the [V3 migration ledger](V3_MIGRATION.md#overlay-migration-recipe). |
| `ContentLoader`, `FormControl`, `GenericFieldLabel`, `Tag` | Blocked | The V3 replacements require consumer-specific composition or accessibility changes. |
| `SecretInput`, `SecretPathInput` | Blocked | Security-sensitive or specialist behavior needs workflow-level parity validation. |
| `NoticeBannerV2` | Blocked | Verify that V3 `Alert` covers existing layout and action requirements. |
diff --git a/frontend/src/components/V3_MIGRATION.md b/frontend/src/components/V3_MIGRATION.md
index 46b2c8ed70..c34dff2b8a 100644
--- a/frontend/src/components/V3_MIGRATION.md
+++ b/frontend/src/components/V3_MIGRATION.md
@@ -34,12 +34,12 @@ In the table, E is the number of external consumer files and I is the number of
| `Button/Button.tsx` | 141 / 4 | V3 Button; map intent, disabled/loading, type, refs, and permissions per flow. | `frontend/src/pages/middlewares/restrict-login-signup.tsx:61` |
| `Card/Card.tsx` | 66 / 2 | V3 Card slots; preserve layout and state-bearing children. | `frontend/src/pages/secret-manager/integrations/SelectIntegrationAuthPage/SelectIntegrationAuthPage.tsx:164` |
| `Checkbox/Checkbox.tsx` | 11 / 1 | V3 Checkbox + Field; verify controlled/indeterminate state and labels. | `frontend/src/pages/organization/AccessManagementPage/components/UpgradePrivilegeSystemModal/UpgradePrivilegeSystemModal.tsx:180` |
-| `ConfirmActionModal/ConfirmActionModal.tsx` | 2 / 0 | V3 AlertDialog; verify async confirmation, errors, focus, and close. | `frontend/src/pages/auth/AccountRecoveryResetPage/AccountRecoveryResetPage.tsx:94` |
+| `ConfirmActionModal/ConfirmActionModal.tsx` | 2 / 0 | V3 `DeleteConfirmDialog` with a non-danger `confirmVariant`; follow the overlay recipe. | `frontend/src/pages/auth/AccountRecoveryResetPage/AccountRecoveryResetPage.tsx:94` |
| `ContentLoader/ContentLoader.tsx` | 12 / 0 | V3 Loader/PageLoader composition; preserve pending boundaries. | `frontend/src/pages/auth/SelectOrgPage/SelectOrgPage.tsx:446` |
| `CopyButton/CopyButton.tsx` | 2 / 0 | V3 CopyButton; verify exact copy, failure feedback, and labels. | `frontend/src/pages/cert-manager/CertificateDetailsByIDPage/components/CertificateDetailsSection.tsx:275` |
| `CreatableSelect/CreatableSelect.tsx` | 0 / 0 | Deleted in first wave; no consumer. | No incoming non-export edge or external symbol reference. |
| `DatePicker/DatePicker.tsx` | 0 / 0 | Deleted in first wave; no active date contract replaced. | Only its own barrel exported it. |
-| `DeleteActionModal/DeleteActionModal.tsx` | 56 / 0 | V3 AlertDialog; preserve confirmation gates, mutations, cleanup, and error recovery. | `frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsSection.tsx:121` |
+| `DeleteActionModal/DeleteActionModal.tsx` | 56 / 0 | V3 `DeleteConfirmDialog`; follow the overlay recipe for confirmation gates, mutations, cleanup, and error recovery. | `frontend/src/pages/organization/AccessManagementPage/components/OrgGroupsTab/components/OrgGroupsSection/OrgGroupsSection.tsx:121` |
| `Divider/Divider.tsx` | 0 / 0 | Deleted in first wave; no consumer. | Only its own/root barrels exported it. |
| `Drawer/Drawer.tsx` | 0 / 0 | Deleted in first wave; no consumer. | Only its own/root barrels exported it. |
| `Dropdown/Dropdown.tsx` | 23 / 2 | V3 DropdownMenu; check checkbox/radio, submenu, disabled actions, and focus. | `frontend/src/pages/secret-scanning/SecretScanningFindingsPage/components/SecretScanningFindingRow.tsx:137` |
@@ -57,7 +57,7 @@ In the table, E is the number of external consumer files and I is the number of
| `Input/Input.tsx` | 100 / 4 | V3 Input/InputGroup; preserve refs, validation, type and adornment behavior. | `frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/MetadataForm.tsx:58` |
| `Lottie/Lottie.tsx` | 1 / 0 | V3 Loader; remove entry/barrel chunk-order dependency with a production boot proof. | `frontend/src/main.tsx:83` |
| `Menu/Menu.tsx` | 1 / 0 | One remaining type reference; replace with actual V3 contract, then delete source/exports. | `frontend/src/layouts/OrganizationLayout/components/MenuIconButton/MenuIconButton.tsx:19` |
-| `Modal/Modal.tsx` | 55 / 2 | V3 Dialog/Sheet chosen by form size; verify nested overlays, portal lifetime, close/discard, mutation errors, and focus. | `frontend/src/pages/organization/AccessManagementPage/components/UpgradePrivilegeSystemModal/UpgradePrivilegeSystemModal.tsx:65` |
+| `Modal/Modal.tsx` | 55 / 2 | V3 Dialog/Sheet chosen by form size; follow the overlay recipe for nested overlays, pending close, discard, mutation errors, and focus. | `frontend/src/pages/organization/AccessManagementPage/components/UpgradePrivilegeSystemModal/UpgradePrivilegeSystemModal.tsx:65` |
| `NoticeBanner/NoticeBanner.tsx` | 0 / 0 | Deleted in first wave; no consumer. | Only its own/root barrels exported it. |
| `NoticeBannerV2/NoticeBannerV2.tsx` | 2 / 0 | V3 Alert composition; preserve warnings and associated actions. | `frontend/src/components/secret-rotations-v2/ViewSecretRotationV2GeneratedCredentials/ViewSecretRotationV2GeneratedCredentials.tsx:273` |
| `PageHeader/PageHeader.tsx` | 32 / 0 | V3 PageHeader owns the normal 40px bottom boundary; remove only header-boundary compensation and preserve body spacing, actions, scopes and responsive intent. | `frontend/src/pages/organization/ProjectsPage/ProjectsPage.tsx:53` |
@@ -145,6 +145,157 @@ At mission creation, held/reserved work is UpgradeGate (#8182, INFS-647), secret
Before each wave, record changed source paths, risk, state/security contracts, needed replacements, validation evidence and limits. Escalate real product/policy/security tradeoffs; mechanical migrations do not require redundant permission. Never remove user functionality to meet a source count.
+### Overlay migration recipe
+
+Use this recipe for every V2 `Modal`, `DeleteActionModal`, and `ConfirmActionModal` consumer. The V3 overlays own the shared behavior, so a consumer migration maps props and structure and adds no per-callsite Escape, focus, pending, or stacking code.
+
+**What the V3 contract provides.** `DialogContent`, `SheetContent`, `AlertDialogContent`, and `DeleteConfirmDialog` provide these behaviors without consumer code:
+
+- **Innermost layer first.** Escape or an outside click closes an open nested popup first. The next Escape or outside click reaches the overlay. Radix popups (`Select`, `DropdownMenu`, `Tooltip`, `HoverCard`, `Popover`) do this natively. `Combobox` registers its open popup with the nearest `DialogContent`, `SheetContent`, or `AlertDialogContent` (which includes `DeleteConfirmDialog`), and an event that closed the popup cannot also close the overlay. Inside an overlay, `Combobox` defaults to `modal`.
+- **Pending close.** While `isPending` is true on `DialogContent` or `SheetContent`, Escape, outside clicks, the built-in close button, and every `DialogClose` or `SheetClose` cannot dismiss the overlay. `DeleteConfirmDialog` locks itself while `onConfirm` is in flight, disables Cancel and the input, and shows the pending state on its confirm button.
+- **Focus return.** Closing returns focus to the element that opened the overlay. When a V3 `DropdownMenuItem` opened it, focus returns to that menu's trigger. No refs or `onCloseAutoFocus` handlers are needed. If the opener no longer exists, for example a row removed by a successful delete, Radix's default applies.
+- **Typed confirmation.** `DeleteConfirmDialog` compares the typed value with `confirmKey`, resets it on every open and close, submits on Enter only when it matches, and keeps the dialog open if `onConfirm` rejects. The global mutation error toast reports the failure.
+
+**Choose the target.**
+
+| V2 | V3 target |
+| --- | --- |
+| `Modal` + `ModalContent` with a short form or prompt | `Dialog` + `DialogContent` |
+| `Modal` + `ModalContent` with a large or multi-step form | `Sheet` + `SheetContent` (see `DESIGN.md`) |
+| `DeleteActionModal` | `DeleteConfirmDialog` from `@app/components/v3/platform` |
+| `ConfirmActionModal` | `DeleteConfirmDialog` with a non-danger `confirmVariant` |
+
+**`Modal` and `ModalContent` mapping.**
+
+| V2 | V3 |
+| --- | --- |
+| `<Modal isOpen={x} onOpenChange={fn}>` | `<Dialog open={x} onOpenChange={fn}>`. Keep the existing `usePopUp` handler and any `reset()` call. |
+| `ModalTrigger`, `ModalClose` | `DialogTrigger`, `DialogClose` |
+| `title` | `<DialogHeader><DialogTitle>{title}</DialogTitle></DialogHeader>` |
+| `subTitle` | `<DialogDescription>{subTitle}</DialogDescription>` inside `DialogHeader` |
+| `footerContent`, or the button row at the end of the form | `<DialogFooter>` inside the `<form>`. Cancel is `<DialogClose asChild><Button variant="ghost">Cancel</Button></DialogClose>`. The primary button uses the scope variant (`org`, `sub-org`, `project`, ...) and `isPending={isSubmitting}`. |
+| Submit button `isLoading` / `isDisabled={isSubmitting}` | `isPending={isSubmitting}` on the submit button, and `isPending={isSubmitting}` on `DialogContent` |
+| `bodyClassName="overflow-visible"` | Remove. V3 popups portal out of the dialog. |
+| `className="max-w-2xl"` and wider | Keep the V3 width. If the content needs more room, use `Sheet`. |
+| `overlayClassName`, `showCloseButton` | Same props on `DialogContent` |
+| `onEscapeKeyDown` that only protects a nested popup | Remove. Keep handlers that implement product behavior, such as a discard guard. |
+
+V2 controls rendered inside the overlay move to V3 in the same change. A V2 `Select`, `FilterableSelect`, `Dropdown`, or `Tooltip` inside a V3 overlay does not join the layer contract. `FilterableSelect` becomes `Combobox`. Remove caller-owned `onPopupOpenChange` registries that only guard the parent Escape.
+
+Before:
+
+```tsx
+<Modal
+ isOpen={popUp.orgMembership.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("orgMembership", isOpen);
+ reset();
+ }}
+>
+ <ModalContent bodyClassName="overflow-visible" title="Update Membership">
+ <form onSubmit={handleSubmit(onFormSubmit)}>
+ <FormControl label="Update Organization Role">
+ <FilterableSelect options={roles} value={value} onChange={onChange} />
+ </FormControl>
+ <Button type="submit" isLoading={isSubmitting} isDisabled={isSubmitting}>
+ Update
+ </Button>
+ <Button variant="plain" onClick={() => handlePopUpToggle("orgMembership", false)}>
+ Cancel
+ </Button>
+ </form>
+ </ModalContent>
+</Modal>
+```
+
+After:
+
+```tsx
+<Dialog
+ open={popUp.orgMembership.isOpen}
+ onOpenChange={(isOpen) => {
+ handlePopUpToggle("orgMembership", isOpen);
+ reset();
+ }}
+>
+ <DialogContent isPending={isSubmitting}>
+ <DialogHeader>
+ <DialogTitle>Update Membership</DialogTitle>
+ </DialogHeader>
+ <form className="flex flex-col gap-6" onSubmit={handleSubmit(onFormSubmit)}>
+ <Field>
+ <FieldLabel htmlFor={roleInputId}>Update Organization Role</FieldLabel>
+ <Combobox id={roleInputId} options={roles} value={value} onValueChange={onChange} />
+ </Field>
+ <DialogFooter>
+ <DialogClose asChild>
+ <Button variant="ghost">Cancel</Button>
+ </DialogClose>
+ <Button type="submit" variant="org" isPending={isSubmitting}>
+ Update
+ </Button>
+ </DialogFooter>
+ </form>
+ </DialogContent>
+</Dialog>
+```
+
+**`DeleteActionModal` and `ConfirmActionModal` mapping.**
+
+| V2 | `DeleteConfirmDialog` |
+| --- | --- |
+| `isOpen` | `isOpen` |
+| `onChange` | `onOpenChange` |
+| `onClose` | Fold into `onOpenChange` when it receives `false` |
+| `title` | `title` |
+| `subTitle` | `description`. When V2 omitted it, pass `description="This action is irreversible."` to keep the shown copy. |
+| `deleteKey` / `confirmKey` | `confirmKey` |
+| `onDeleteApproved` / `onConfirmed` | `onConfirm`. Keep the existing close-on-success call inside it. |
+| `buttonText` | `confirmLabel` (default `Delete`) |
+| `buttonColorSchema="danger"` | Omit (default `confirmVariant="danger"`) |
+| `buttonColorSchema="primary"`, or any `ConfirmActionModal` | `confirmVariant` with the scope variant, or `neutral` outside a scope |
+| `children` | `children`, rendered after the confirmation field. Drop top margins that only spaced it from the V2 input. |
+| `formContent` | `description` when it explains the action, otherwise `children` |
+| `deletionMessage` / `confirmationMessage` | No consumer uses it. Raise a contract change before relying on custom label copy. |
+| `isDisabled` | No consumer uses it. Use `isPending` for an external in-flight state. |
+
+Before:
+
+```tsx
+<DeleteActionModal
+ isOpen={popUp.removeMember.isOpen}
+ title={`Are you sure you want to remove member with username ${username}?`}
+ onChange={(isOpen) => handlePopUpToggle("removeMember", isOpen)}
+ deleteKey="confirm"
+ onDeleteApproved={() => onRemoveMemberSubmit(orgMembershipId)}
+ buttonText="Remove"
+/>
+```
+
+After:
+
+```tsx
+<DeleteConfirmDialog
+ isOpen={popUp.removeMember.isOpen}
+ title={`Are you sure you want to remove member with username ${username}?`}
+ description="This action is irreversible."
+ onOpenChange={(isOpen) => handlePopUpToggle("removeMember", isOpen)}
+ confirmKey="confirm"
+ onConfirm={() => onRemoveMemberSubmit(orgMembershipId)}
+ confirmLabel="Remove"
+/>
+```
+
+**Edge cases to check in every sweep.**
+
+- **No `autoFocus` inside V3 overlays.** `autoFocus` moves focus before the overlay records its opener, so focus cannot return on close. The overlay already focuses the first field.
+- **Menu triggers.** Focus returns to a menu trigger only when the menu is a V3 `DropdownMenu`. When the trigger is still a V2 `Dropdown`, migrate that menu in the same change or record that focus returns to the page.
+- **Chained confirmations.** If `onConfirm` opens a second dialog instead of closing, as `IntegrationsDetailsByIDPage` does, keep that control flow and check the second dialog's focus return.
+- **Pending state outside the form.** If the mutation runs in the parent, pass the mutation's `isPending` to `DialogContent` or `DeleteConfirmDialog`. Do not add `onOpenChange` guards.
+- **Reset and discard.** Keep the consumer's `reset()` or state clearing on close. Radix unmounts closed content, so state inside the content subtree resets by itself. Add `useDiscardChangesGuard` only when the product asks for a dirty-form guard; V2 never had one.
+- **Existing AlertDialog compositions** with `confirmationValue` do not lock while pending. New typed confirmations use `DeleteConfirmDialog`.
+- **Proof.** For each sweep, open each migrated overlay once in the preview: Escape with a nested popup open, Escape and an outside click while a mutation is pending, and focus after close.
+
## Completion acceptance
- All implementation PRs have landed through explicitly authorized merges. Refresh latest `origin/main`; report its exact commit and check a clean worktree, not a combined set of open branches.
diff --git a/frontend/src/components/v3/generic/AlertDialog/AlertDialog.tsx b/frontend/src/components/v3/generic/AlertDialog/AlertDialog.tsx
index e33e86ff6e..0aa194c732 100644
--- a/frontend/src/components/v3/generic/AlertDialog/AlertDialog.tsx
+++ b/frontend/src/components/v3/generic/AlertDialog/AlertDialog.tsx
@@ -2,6 +2,7 @@ import * as React from "react";
import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
import { cn } from "../../utils";
+import { OverlayLayerContext, useOverlayLayer } from "../../utils/overlay-layer";
import { Button } from "../Button";
import { DIALOG_CONTENT_WIDTH_CLASSNAME } from "../Dialog";
import { Field, FieldLabel } from "../Field";
@@ -91,11 +92,17 @@ function AlertDialogOverlay({
function AlertDialogContent({
className,
size = "default",
+ children,
onOpenAutoFocus,
+ onCloseAutoFocus,
+ onEscapeKeyDown,
...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Content> & {
size?: "default" | "sm";
}) {
+ const { contextValue, guardDismiss, captureFocusReturn, restoreFocusReturn } =
+ useOverlayLayer(false);
+
return (
<AlertDialogPortal>
<AlertDialogOverlay />
@@ -108,7 +115,7 @@ function AlertDialogContent({
className
)}
onOpenAutoFocus={(event) => {
- onOpenAutoFocus?.(event);
+ captureFocusReturn(event, onOpenAutoFocus);
if (event.defaultPrevented) return;
const inputs = (
@@ -122,8 +129,12 @@ function AlertDialogContent({
if (focusedInput) event.preventDefault();
}}
+ onCloseAutoFocus={(event) => restoreFocusReturn(event, onCloseAutoFocus)}
+ onEscapeKeyDown={(event) => guardDismiss(event, onEscapeKeyDown)}
{...props}
- />
+ >
+ <OverlayLayerContext.Provider value={contextValue}>{children}</OverlayLayerContext.Provider>
+ </AlertDialogPrimitive.Content>
</AlertDialogPortal>
);
}
@@ -316,7 +327,6 @@ function AlertDialogConfirmationField({
/>
<Input
autoComplete="off"
- autoFocus
placeholder={confirmationValue}
{...inputProps}
id={inputProps?.id ?? inputId}
diff --git a/frontend/src/components/v3/generic/Combobox/Combobox.tsx b/frontend/src/components/v3/generic/Combobox/Combobox.tsx
index 185017cb1d..932da8c6c1 100644
--- a/frontend/src/components/v3/generic/Combobox/Combobox.tsx
+++ b/frontend/src/components/v3/generic/Combobox/Combobox.tsx
@@ -3,6 +3,7 @@ import { Combobox as ComboboxPrimitive } from "@base-ui/react/combobox";
import { CheckIcon, ChevronDownIcon, Loader2Icon, PlusIcon, XIcon } from "lucide-react";
import { cn } from "../../utils";
+import { useIsInsideOverlayLayer, useOverlayPopupRegistration } from "../../utils/overlay-layer";
import { useScrollEdges } from "../../utils/useScrollEdges";
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "../Dialog";
import { getComboboxInputAriaLabel } from "./combobox-accessibility";
@@ -184,7 +185,9 @@ const useComboboxOpen = (onPopupOpenChange?: (open: boolean) => void) => {
[]
);
- return [open, setOpen] as const;
+ const markPopupDismissEvent = useOverlayPopupRegistration(open);
+
+ return [open, setOpen, markPopupDismissEvent] as const;
};
const SINGLE_LIST_MAX_HEIGHT = "min(18.75rem, var(--available-height, 50dvh))";
@@ -844,7 +847,7 @@ const SingleCombobox = <TOption,>(props: ComboboxSingleProps<TOption>) => {
isDisabled = false,
isLoading = false,
isError = false,
- modal = false,
+ modal: modalProp,
onPopupOpenChange,
portalContainer: portalContainerProp,
variant = "default",
@@ -860,10 +863,12 @@ const SingleCombobox = <TOption,>(props: ComboboxSingleProps<TOption>) => {
onKeyDown,
...inputProps
} = props;
+ const isInsideOverlayLayer = useIsInsideOverlayLayer();
const inputRef = React.useRef<HTMLInputElement | null>(null);
const listScrollRef = React.useRef<HTMLDivElement>(null);
const highlightedOptionValueRef = React.useRef<string | null>(null);
- const [open, setOpen] = useComboboxOpen(onPopupOpenChange);
+ const [open, setOpen, markPopupDismissEvent] = useComboboxOpen(onPopupOpenChange);
+ const modal = modalProp ?? isInsideOverlayLayer;
const selectedLabel = value == null ? "" : getOptionLabel(value);
const [search, setSearch] = React.useState("");
const searchRef = React.useRef(search);
@@ -1042,6 +1047,7 @@ const SingleCombobox = <TOption,>(props: ComboboxSingleProps<TOption>) => {
eventDetails.reason === "item-press" &&
isDialogCreationConfig(creation) &&
(isDialogCreationActiveRef.current || isComboboxCreateItemEvent(eventDetails.event));
+ if (!nextOpen) markPopupDismissEvent(eventDetails.event);
setOpen(nextOpen);
if (!nextOpen && !isCreationActive() && !isOpeningCreationDialog) {
highlightedOptionValueRef.current = null;
@@ -1235,7 +1241,7 @@ const MultipleCombobox = <TOption,>({
isDisabled = false,
isLoading = false,
isError = false,
- modal = false,
+ modal: modalProp,
onPopupOpenChange,
portalContainer: portalContainerProp,
className,
@@ -1250,13 +1256,15 @@ const MultipleCombobox = <TOption,>({
onKeyDown,
...inputProps
}: ComboboxMultipleProps<TOption>) => {
+ const isInsideOverlayLayer = useIsInsideOverlayLayer();
const inputRef = React.useRef<HTMLInputElement | null>(null);
const listScrollRef = React.useRef<HTMLDivElement>(null);
const chipsRef = React.useRef<HTMLDivElement | null>(null);
const { scrollEdges, setViewportRef } = useScrollEdges<HTMLDivElement>(
singleLine ? "horizontal" : "vertical"
);
- const [open, setOpen] = useComboboxOpen(onPopupOpenChange);
+ const [open, setOpen, markPopupDismissEvent] = useComboboxOpen(onPopupOpenChange);
+ const modal = modalProp ?? isInsideOverlayLayer;
const openRef = React.useRef(open);
openRef.current = open;
const [search, setSearch] = React.useState("");
@@ -1467,6 +1475,7 @@ const MultipleCombobox = <TOption,>({
eventDetails.reason === "item-press" &&
isDialogCreationConfig(creation) &&
(isDialogCreationActiveRef.current || isComboboxCreateItemEvent(eventDetails.event));
+ if (!nextOpen) markPopupDismissEvent(eventDetails.event);
openRef.current = nextOpen;
setOpen(nextOpen);
if (!nextOpen && !isCreationActive() && !isOpeningCreationDialog) {
diff --git a/frontend/src/components/v3/generic/Dialog/Dialog.stories.tsx b/frontend/src/components/v3/generic/Dialog/Dialog.stories.tsx
index 87981cdf76..e998ad496e 100644
--- a/frontend/src/components/v3/generic/Dialog/Dialog.stories.tsx
+++ b/frontend/src/components/v3/generic/Dialog/Dialog.stories.tsx
@@ -1,9 +1,23 @@
+import { useId, useState } from "react";
import type { Meta, StoryObj } from "@storybook/react-vite";
+import { EllipsisIcon } from "lucide-react";
import { Button } from "../Button";
+import { Combobox } from "../Combobox";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuTrigger
+} from "../Dropdown";
+import { Field, FieldLabel } from "../Field";
+import { HoverCard, HoverCardContent, HoverCardTrigger } from "../HoverCard";
+import { IconButton } from "../IconButton";
import { Input } from "../Input";
import { Label } from "../Label";
+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../Select";
import { Separator } from "../Separator";
+import { Tooltip, TooltipContent, TooltipTrigger } from "../Tooltip";
import {
Dialog,
DialogBody,
@@ -267,3 +281,123 @@ export const AlternativeScroll: Story = {
</Dialog>
)
};
+
+const ROLES = [
+ { slug: "admin", name: "Admin" },
+ { slug: "member", name: "Member" },
+ { slug: "no-access", name: "No Access" }
+];
+
+const NestedPopupsAndPendingCloseRender = () => {
+ const [isOpen, setIsOpen] = useState(false);
+ const [isPending, setIsPending] = useState(false);
+ const [role, setRole] = useState<(typeof ROLES)[number] | null>(ROLES[1]);
+ const [environment, setEnvironment] = useState("production");
+ const roleId = useId();
+ const environmentId = useId();
+
+ return (
+ <>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <IconButton aria-label="Member options" variant="outline">
+ <EllipsisIcon />
+ </IconButton>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end">
+ <DropdownMenuItem onClick={() => setIsOpen(true)}>Edit Member</DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ <Dialog open={isOpen} onOpenChange={setIsOpen}>
+ <DialogContent isPending={isPending}>
+ <DialogHeader>
+ <DialogTitle>Edit Member</DialogTitle>
+ <DialogDescription>
+ Escape and outside clicks close the innermost popup first.
+ </DialogDescription>
+ </DialogHeader>
+ <form
+ className="flex flex-col gap-6"
+ onSubmit={(event) => {
+ event.preventDefault();
+ setIsPending(true);
+ setTimeout(() => {
+ setIsPending(false);
+ setIsOpen(false);
+ }, 1500);
+ }}
+ >
+ <Field>
+ <FieldLabel htmlFor={roleId}>Role</FieldLabel>
+ <Combobox
+ id={roleId}
+ options={ROLES}
+ value={role}
+ isClearable={false}
+ onValueChange={setRole}
+ getOptionValue={(option) => option.slug}
+ getOptionLabel={(option) => option.name}
+ />
+ </Field>
+ <Field>
+ <FieldLabel htmlFor={environmentId}>Environment</FieldLabel>
+ <Select value={environment} onValueChange={setEnvironment}>
+ <SelectTrigger id={environmentId}>
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent position="popper">
+ <SelectItem value="development">Development</SelectItem>
+ <SelectItem value="staging">Staging</SelectItem>
+ <SelectItem value="production">Production</SelectItem>
+ </SelectContent>
+ </Select>
+ </Field>
+ <div className="flex items-center gap-4 text-sm">
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Button variant="link">Tooltip</Button>
+ </TooltipTrigger>
+ <TooltipContent>Informational tooltip</TooltipContent>
+ </Tooltip>
+ <HoverCard>
+ <HoverCardTrigger asChild>
+ <Button variant="link">Hover card</Button>
+ </HoverCardTrigger>
+ <HoverCardContent>Supplementary details for this member.</HoverCardContent>
+ </HoverCard>
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button variant="link">Menu</Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent>
+ <DropdownMenuItem>Copy Member ID</DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ <DialogFooter>
+ <DialogClose asChild>
+ <Button variant="ghost">Cancel</Button>
+ </DialogClose>
+ <Button type="submit" variant="org" isPending={isPending}>
+ Save
+ </Button>
+ </DialogFooter>
+ </form>
+ </DialogContent>
+ </Dialog>
+ </>
+ );
+};
+
+export const NestedPopupsAndPendingClose: Story = {
+ name: "Example: Nested Popups and Pending Close",
+ parameters: {
+ docs: {
+ description: {
+ story:
+ "Combobox, Select, Tooltip, HoverCard, and DropdownMenu popups inside a Dialog each own the first Escape or outside click; the next one reaches the Dialog. While `isPending` is true, Escape, outside clicks, the close button, and `DialogClose` cannot dismiss the Dialog. Closing returns focus to the control that opened it, including the trigger of a menu whose item opened it."
+ }
+ }
+ },
+ render: () => <NestedPopupsAndPendingCloseRender />
+};
diff --git a/frontend/src/components/v3/generic/Dialog/Dialog.tsx b/frontend/src/components/v3/generic/Dialog/Dialog.tsx
index 0d92e26bfb..4e54efe10c 100644
--- a/frontend/src/components/v3/generic/Dialog/Dialog.tsx
+++ b/frontend/src/components/v3/generic/Dialog/Dialog.tsx
@@ -3,6 +3,11 @@ import * as DialogPrimitive from "@radix-ui/react-dialog";
import { XIcon } from "lucide-react";
import { cn } from "../../utils";
+import {
+ OverlayLayerContext,
+ useOverlayIsPending,
+ useOverlayLayer
+} from "../../utils/overlay-layer";
const DIALOG_CONTENT_WIDTH_CLASSNAME = "w-[calc(100%-2rem)] max-w-lg";
@@ -26,7 +31,15 @@ function DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.
}
function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>) {
- return <DialogPrimitive.Close data-slot="dialog-close" {...props} />;
+ const isPending = useOverlayIsPending();
+
+ return (
+ <DialogPrimitive.Close
+ data-slot="dialog-close"
+ {...props}
+ {...(isPending && { disabled: true })}
+ />
+ );
}
function DialogOverlay({
@@ -50,6 +63,10 @@ function DialogContent({
children,
showCloseButton = true,
height = "auto",
+ isPending = false,
+ onOpenAutoFocus,
+ onCloseAutoFocus,
+ onEscapeKeyDown,
onPointerDownOutside,
onInteractOutside,
overlayClassName,
@@ -57,8 +74,12 @@ function DialogContent({
}: React.ComponentProps<typeof DialogPrimitive.Content> & {
showCloseButton?: boolean;
height?: "auto" | "fixed";
+ isPending?: boolean;
overlayClassName?: string;
}) {
+ const { contextValue, guardDismiss, captureFocusReturn, restoreFocusReturn } =
+ useOverlayLayer(isPending);
+
return (
<DialogPortal data-slot="dialog-portal">
<DialogOverlay className={overlayClassName} />
@@ -70,26 +91,30 @@ function DialogContent({
height === "fixed" && "h-[40rem] overflow-hidden",
className
)}
+ onOpenAutoFocus={(e) => captureFocusReturn(e, onOpenAutoFocus)}
+ onCloseAutoFocus={(e) => restoreFocusReturn(e, onCloseAutoFocus)}
+ onEscapeKeyDown={(e) => guardDismiss(e, onEscapeKeyDown)}
onPointerDownOutside={(e) => {
if (isAllowedOutsideInteraction(e.target)) {
e.preventDefault();
return;
}
- onPointerDownOutside?.(e);
+ guardDismiss(e, onPointerDownOutside);
}}
onInteractOutside={(e) => {
if (isAllowedOutsideInteraction(e.target)) {
e.preventDefault();
return;
}
- onInteractOutside?.(e);
+ guardDismiss(e, onInteractOutside);
}}
{...props}
>
- {children}
+ <OverlayLayerContext.Provider value={contextValue}>{children}</OverlayLayerContext.Provider>
{showCloseButton && (
<DialogPrimitive.Close
data-slot="dialog-close"
+ disabled={isPending}
className="data-[state=open]:text-muted-foreground absolute top-4 right-4 cursor-pointer rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
>
<XIcon />
diff --git a/frontend/src/components/v3/generic/Dropdown/Dropdown.tsx b/frontend/src/components/v3/generic/Dropdown/Dropdown.tsx
index 6fdc13ba6b..d1e941708e 100644
--- a/frontend/src/components/v3/generic/Dropdown/Dropdown.tsx
+++ b/frontend/src/components/v3/generic/Dropdown/Dropdown.tsx
@@ -4,8 +4,19 @@ import { CheckIcon, ChevronLeftIcon, ChevronRightIcon } from "lucide-react";
import { cn } from "@app/components/v3/utils";
+import { registerMenuItemFocusReturn } from "../../utils/overlay-layer";
+
+const DropdownMenuTriggerRefContext =
+ React.createContext<React.MutableRefObject<HTMLButtonElement | null> | null>(null);
+
function DropdownMenu({ ...props }: React.ComponentProps<typeof DropdownMenuPrimitive.Root>) {
- return <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />;
+ const triggerRef = React.useRef<HTMLButtonElement | null>(null);
+
+ return (
+ <DropdownMenuTriggerRefContext.Provider value={triggerRef}>
+ <DropdownMenuPrimitive.Root data-slot="dropdown-menu" {...props} />
+ </DropdownMenuTriggerRefContext.Provider>
+ );
}
function DropdownMenuPortal({
@@ -17,11 +28,29 @@ function DropdownMenuPortal({
const DropdownMenuTrigger = React.forwardRef<
HTMLButtonElement,
React.ComponentProps<typeof DropdownMenuPrimitive.Trigger>
->(
- ({ ...props }, ref): JSX.Element => (
- <DropdownMenuPrimitive.Trigger ref={ref} data-slot="dropdown-menu-trigger" {...props} />
- )
-);
+>(({ ...props }, ref): JSX.Element => {
+ const triggerRef = React.useContext(DropdownMenuTriggerRefContext);
+ const setTriggerRef = React.useCallback(
+ (node: HTMLButtonElement | null) => {
+ if (triggerRef) triggerRef.current = node;
+ if (typeof ref === "function") {
+ ref(node);
+ } else if (ref) {
+ const mutableRef = ref as React.MutableRefObject<HTMLButtonElement | null>;
+ mutableRef.current = node;
+ }
+ },
+ [ref, triggerRef]
+ );
+
+ return (
+ <DropdownMenuPrimitive.Trigger
+ ref={setTriggerRef}
+ data-slot="dropdown-menu-trigger"
+ {...props}
+ />
+ );
+});
function DropdownMenuContent({
className,
@@ -76,6 +105,7 @@ const DropdownMenuItem = React.forwardRef<HTMLDivElement, DropdownMenuProps>(
ref
): JSX.Element => {
const isFocusableDisabled = Boolean(isDisabled && isDisabledFocusable);
+ const triggerRef = React.useContext(DropdownMenuTriggerRefContext);
return (
<DropdownMenuPrimitive.Item
@@ -103,6 +133,7 @@ const DropdownMenuItem = React.forwardRef<HTMLDivElement, DropdownMenuProps>(
event.stopPropagation();
return;
}
+ registerMenuItemFocusReturn(event.currentTarget, triggerRef?.current ?? null);
onClick?.(event);
}}
onSelect={(event) => {
diff --git a/frontend/src/components/v3/generic/Sheet/Sheet.tsx b/frontend/src/components/v3/generic/Sheet/Sheet.tsx
index 72998c5549..fdcfc63b91 100644
--- a/frontend/src/components/v3/generic/Sheet/Sheet.tsx
+++ b/frontend/src/components/v3/generic/Sheet/Sheet.tsx
@@ -5,6 +5,11 @@ import * as SheetPrimitive from "@radix-ui/react-dialog";
import { XIcon } from "lucide-react";
import { cn } from "../../utils";
+import {
+ OverlayLayerContext,
+ useOverlayIsPending,
+ useOverlayLayer
+} from "../../utils/overlay-layer";
const isAllowedOutsideInteraction = (target: EventTarget | null) =>
Boolean(
@@ -22,7 +27,15 @@ function SheetTrigger({ ...props }: React.ComponentProps<typeof SheetPrimitive.T
}
function SheetClose({ ...props }: React.ComponentProps<typeof SheetPrimitive.Close>) {
- return <SheetPrimitive.Close data-slot="sheet-close" {...props} />;
+ const isPending = useOverlayIsPending();
+
+ return (
+ <SheetPrimitive.Close
+ data-slot="sheet-close"
+ {...props}
+ {...(isPending && { disabled: true })}
+ />
+ );
}
function SheetPortal({ ...props }: React.ComponentProps<typeof SheetPrimitive.Portal>) {
@@ -50,31 +63,42 @@ function SheetContent({
children,
side = "right",
size,
+ isPending = false,
+ onOpenAutoFocus,
+ onCloseAutoFocus,
+ onEscapeKeyDown,
onPointerDownOutside,
onInteractOutside,
...props
}: React.ComponentProps<typeof SheetPrimitive.Content> & {
side?: "top" | "right" | "bottom" | "left";
size?: "form" | "wide" | "workspace";
+ isPending?: boolean;
}) {
+ const { contextValue, guardDismiss, captureFocusReturn, restoreFocusReturn } =
+ useOverlayLayer(isPending);
+
return (
<SheetPortal>
<SheetOverlay />
<SheetPrimitive.Content
data-slot="sheet-content"
+ onOpenAutoFocus={(e) => captureFocusReturn(e, onOpenAutoFocus)}
+ onCloseAutoFocus={(e) => restoreFocusReturn(e, onCloseAutoFocus)}
+ onEscapeKeyDown={(e) => guardDismiss(e, onEscapeKeyDown)}
onPointerDownOutside={(e) => {
if (isAllowedOutsideInteraction(e.target)) {
e.preventDefault();
return;
}
- onPointerDownOutside?.(e);
+ guardDismiss(e, onPointerDownOutside);
}}
onInteractOutside={(e) => {
if (isAllowedOutsideInteraction(e.target)) {
e.preventDefault();
return;
}
- onInteractOutside?.(e);
+ guardDismiss(e, onInteractOutside);
}}
className={cn(
"fixed z-[var(--z-index-modal)] flex thin-scrollbar flex-col border-border bg-popover text-foreground shadow-lg outline-0 transition data-[state=closed]:animate-out data-[state=closed]:duration-150 data-[state=closed]:ease-in data-[state=closed]:fade-out-50 data-[state=open]:animate-in data-[state=open]:duration-200 data-[state=open]:ease-out",
@@ -93,8 +117,11 @@ function SheetContent({
)}
{...props}
>
- {children}
- <SheetPrimitive.Close className="data-[state=open]:bg-secondary absolute top-4 right-4 z-20 cursor-pointer rounded-xs text-foreground opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none">
+ <OverlayLayerContext.Provider value={contextValue}>{children}</OverlayLayerContext.Provider>
+ <SheetPrimitive.Close
+ disabled={isPending}
+ className="data-[state=open]:bg-secondary absolute top-4 right-4 z-20 cursor-pointer rounded-xs text-foreground opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none"
+ >
<XIcon className="size-4" />
<span className="sr-only">Close</span>
</SheetPrimitive.Close>
diff --git a/frontend/src/components/v3/platform/DeleteConfirmDialog/DeleteConfirmDialog.tsx b/frontend/src/components/v3/platform/DeleteConfirmDialog/DeleteConfirmDialog.tsx
index e58f1e4228..535fb73415 100644
--- a/frontend/src/components/v3/platform/DeleteConfirmDialog/DeleteConfirmDialog.tsx
+++ b/frontend/src/components/v3/platform/DeleteConfirmDialog/DeleteConfirmDialog.tsx
@@ -11,7 +11,7 @@ import {
AlertDialogHeader,
AlertDialogTitle
} from "../../generic/AlertDialog";
-import { Button } from "../../generic/Button";
+import { Button, type ButtonProps } from "../../generic/Button";
import { Field } from "../../generic/Field";
import { Input } from "../../generic/Input";
@@ -22,8 +22,10 @@ type Props = {
description?: ReactNode;
confirmKey: string;
confirmLabel?: string;
+ confirmVariant?: ButtonProps["variant"];
isPending?: boolean;
onConfirm: () => void | Promise<void>;
+ children?: ReactNode;
};
export const DeleteConfirmDialog = ({
@@ -33,8 +35,10 @@ export const DeleteConfirmDialog = ({
description,
confirmKey,
confirmLabel = "Delete",
+ confirmVariant = "danger",
isPending,
- onConfirm
+ onConfirm,
+ children
}: Props) => {
const [typedValue, setTypedValue] = useState("");
const [isConfirming, setIsConfirming] = useState(false);
@@ -85,7 +89,6 @@ export const DeleteConfirmDialog = ({
<Input
id={confirmationInputId}
autoComplete="off"
- autoFocus
disabled={isActionPending}
placeholder={confirmKey}
spellCheck={false}
@@ -94,11 +97,12 @@ export const DeleteConfirmDialog = ({
/>
</Field>
</AlertDialogConfirmationField>
+ {children}
<AlertDialogFooter>
<AlertDialogCancel isDisabled={isActionPending}>Cancel</AlertDialogCancel>
<Button
type="submit"
- variant="danger"
+ variant={confirmVariant}
size="sm"
isDisabled={!canConfirm}
isPending={isActionPending}
diff --git a/frontend/src/components/v3/utils/overlay-layer.ts b/frontend/src/components/v3/utils/overlay-layer.ts
new file mode 100644
index 0000000000..5406382a28
--- /dev/null
+++ b/frontend/src/components/v3/utils/overlay-layer.ts
@@ -0,0 +1,99 @@
+import * as React from "react";
+
+type OverlayLayerContextValue = {
+ isPending: boolean;
+ registerPopup: (id: string, open: boolean) => void;
+ markPopupDismissEvent: (event: Event) => void;
+};
+
+const OverlayLayerContext = React.createContext<OverlayLayerContextValue | null>(null);
+
+const menuItemFocusReturnTargets = new WeakMap<Element, HTMLElement>();
+
+const registerMenuItemFocusReturn = (item: Element, trigger: HTMLElement | null) => {
+ if (trigger) menuItemFocusReturnTargets.set(item, trigger);
+};
+
+const getOriginalEvent = (event: Event) =>
+ (event as CustomEvent<{ originalEvent?: Event } | undefined>).detail?.originalEvent ?? event;
+
+const useOverlayLayer = (isPending: boolean) => {
+ const openPopups = React.useRef(new Set<string>());
+ const popupDismissEvents = React.useRef(new WeakSet<Event>());
+ const focusReturnTarget = React.useRef<HTMLElement | null>(null);
+
+ const registerPopup = React.useCallback((id: string, open: boolean) => {
+ if (open) openPopups.current.add(id);
+ else openPopups.current.delete(id);
+ }, []);
+
+ const markPopupDismissEvent = React.useCallback((event: Event) => {
+ popupDismissEvents.current.add(event);
+ }, []);
+
+ const contextValue = React.useMemo(
+ () => ({ isPending, registerPopup, markPopupDismissEvent }),
+ [isPending, registerPopup, markPopupDismissEvent]
+ );
+
+ const guardDismiss = <TEvent extends Event>(event: TEvent, handler?: (event: TEvent) => void) => {
+ if (
+ isPending ||
+ openPopups.current.size > 0 ||
+ popupDismissEvents.current.has(getOriginalEvent(event))
+ ) {
+ event.preventDefault();
+ return;
+ }
+ handler?.(event);
+ };
+
+ const captureFocusReturn = (event: Event, handler?: (event: Event) => void) => {
+ const opener = document.activeElement;
+ focusReturnTarget.current =
+ opener instanceof HTMLElement && opener !== opener.ownerDocument.body
+ ? (menuItemFocusReturnTargets.get(opener) ?? opener)
+ : null;
+ handler?.(event);
+ };
+
+ const restoreFocusReturn = (event: Event, handler?: (event: Event) => void) => {
+ handler?.(event);
+ const target = focusReturnTarget.current;
+ focusReturnTarget.current = null;
+ if (event.defaultPrevented || !target?.isConnected) return;
+ event.preventDefault();
+ target.focus();
+ };
+
+ return { contextValue, guardDismiss, captureFocusReturn, restoreFocusReturn };
+};
+
+const useIsInsideOverlayLayer = () => React.useContext(OverlayLayerContext) !== null;
+
+const useOverlayIsPending = () => Boolean(React.useContext(OverlayLayerContext)?.isPending);
+
+const noop = () => undefined;
+
+const useOverlayPopupRegistration = (open: boolean) => {
+ const layer = React.useContext(OverlayLayerContext);
+ const registerPopup = layer?.registerPopup;
+ const id = React.useId();
+
+ React.useLayoutEffect(() => {
+ if (!open || !registerPopup) return undefined;
+ registerPopup(id, true);
+ return () => registerPopup(id, false);
+ }, [id, open, registerPopup]);
+
+ return layer?.markPopupDismissEvent ?? noop;
+};
+
+export {
+ OverlayLayerContext,
+ registerMenuItemFocusReturn,
+ useIsInsideOverlayLayer,
+ useOverlayIsPending,
+ useOverlayLayer,
+ useOverlayPopupRegistration
+};
diff --git a/frontend/src/pages/auth/AccountRecoveryResetPage/AccountRecoveryResetPage.tsx b/frontend/src/pages/auth/AccountRecoveryResetPage/AccountRecoveryResetPage.tsx
index 3ce7c51a5e..0907b4ef75 100644
--- a/frontend/src/pages/auth/AccountRecoveryResetPage/AccountRecoveryResetPage.tsx
+++ b/frontend/src/pages/auth/AccountRecoveryResetPage/AccountRecoveryResetPage.tsx
@@ -3,7 +3,7 @@ import { useNavigate, useSearch } from "@tanstack/react-router";
import { AuthPageLayout } from "@app/components/auth/AuthPageLayout";
import { createNotification } from "@app/components/notifications";
-import { ConfirmActionModal } from "@app/components/v2";
+import { DeleteConfirmDialog } from "@app/components/v3/platform";
import { ROUTE_PATHS } from "@app/const/routes";
import { usePopUp } from "@app/hooks";
import { useEnableEmailAuthAccountRecovery } from "@app/hooks/api";
@@ -91,14 +91,15 @@ export const AccountRecoveryResetPage = () => {
onBack={() => setStep(Steps.SelectRecoveryMethod)}
/>
)}
- <ConfirmActionModal
+ <DeleteConfirmDialog
isOpen={popUp.confirmEnableEmailAuth.isOpen}
confirmKey="enable"
title="Enable Email Authentication"
- subTitle={`Do you want to enable email authentication for your account (${email})? This will allow you to log in using your email and password in the future.`}
- onChange={(isOpen) => handlePopUpToggle("confirmEnableEmailAuth", isOpen)}
- onConfirmed={handleEnableEmailAuth}
- buttonText="Enable"
+ description={`Do you want to enable email authentication for your account (${email})? This will allow you to log in using your email and password in the future.`}
+ onOpenChange={(isOpen) => handlePopUpToggle("confirmEnableEmailAuth", isOpen)}
+ onConfirm={handleEnableEmailAuth}
+ confirmLabel="Enable"
+ confirmVariant="neutral"
/>
</AuthPageLayout>
);
diff --git a/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx b/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx
index 7debcbfd77..a782d369c6 100644
--- a/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx
+++ b/frontend/src/pages/organization/AccessManagementPage/components/OrgMembersTab/components/OrgMembersSection/OrgMembersSection.tsx
@@ -6,7 +6,6 @@ import { EmailServiceSetupModal } from "@app/components/auth/EmailServiceSetupMo
import { CustomRolesUpgradeIntent, UpgradeGate } from "@app/components/license/UpgradeGate";
import { createNotification } from "@app/components/notifications";
import { OrgPermissionCan } from "@app/components/permissions";
-import { DeleteActionModal, Tooltip } from "@app/components/v2";
import {
Badge,
Button,
@@ -17,8 +16,12 @@ import {
CardHeader,
CardTitle,
DocumentationLinkBadge,
- SelectedActionBar
+ SelectedActionBar,
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger
} from "@app/components/v3";
+import { DeleteConfirmDialog } from "@app/components/v3/platform";
import { ROUTE_PATHS } from "@app/const/routes";
import {
OrgPermissionMemberActions,
@@ -210,76 +213,86 @@ export const OrgMembersSection = () => {
setCompleteInviteLinks={setCompleteInviteLinks}
/>
<AddSubOrgMemberModal popUp={popUp} handlePopUpToggle={handlePopUpToggle} />
- <DeleteActionModal
+ <DeleteConfirmDialog
isOpen={popUp.removeMember.isOpen}
title={`Are you sure you want to remove member with username ${
(popUp?.removeMember?.data as { username: string })?.username || ""
}?`}
- onChange={(isOpen) => handlePopUpToggle("removeMember", isOpen)}
- deleteKey="confirm"
- onDeleteApproved={() =>
+ description="This action is irreversible."
+ onOpenChange={(isOpen) => handlePopUpToggle("removeMember", isOpen)}
+ confirmKey="confirm"
+ onConfirm={() =>
onRemoveMemberSubmit(
(popUp?.removeMember?.data as { orgMembershipId: string })?.orgMembershipId
)
}
/>
- <DeleteActionModal
+ <DeleteConfirmDialog
isOpen={popUp.deactivateMember.isOpen}
title={`Are you sure you want to deactivate member with username ${
(popUp?.deactivateMember?.data as { username: string })?.username || ""
}?`}
- onChange={(isOpen) => handlePopUpToggle("deactivateMember", isOpen)}
- deleteKey="confirm"
- onDeleteApproved={() =>
+ description="This action is irreversible."
+ onOpenChange={(isOpen) => handlePopUpToggle("deactivateMember", isOpen)}
+ confirmKey="confirm"
+ onConfirm={() =>
onDeactivateMemberSubmit(
(popUp?.deactivateMember?.data as { orgMembershipId: string })?.orgMembershipId
)
}
- buttonText="Deactivate"
+ confirmLabel="Deactivate"
/>
- <DeleteActionModal
+ <DeleteConfirmDialog
isOpen={popUp.removeMembers.isOpen}
title="Are you sure you want to remove the following members?"
- onChange={(isOpen) => handlePopUpToggle("removeMembers", isOpen)}
- deleteKey="confirm"
- onDeleteApproved={() =>
+ description="This action is irreversible."
+ onOpenChange={(isOpen) => handlePopUpToggle("removeMembers", isOpen)}
+ confirmKey="confirm"
+ onConfirm={() =>
handleRemoveMembers(popUp.removeMembers.data.selectedOrgMemberships as OrgUser[])
}
- buttonText="Remove"
+ confirmLabel="Remove"
>
- <div className="mt-4 text-sm text-muted">The following members will be removed:</div>
- <div className="mt-2 max-h-80 overflow-y-auto rounded-sm border border-border-control bg-danger/10 p-4 pl-8 text-sm text-danger">
- <ul className="list-disc">
- {(popUp.removeMembers.data?.selectedOrgMemberships as OrgUser[])?.map((member) => {
- const email = member.user.email ?? member.user.username ?? member.inviteEmail;
- return (
- <li key={member.id}>
- <div className="flex items-center">
- <p className={userId === member.user.id ? "line-through" : ""}>
- {member.user.firstName || member.user.lastName ? (
- <>
- {`${`${member.user.firstName ?? ""} ${member.user.lastName ?? ""}`.trim()} `}
- (<span className="break-all">{email}</span>)
- </>
- ) : (
- <span className="break-all">{email}</span>
- )}{" "}
- </p>
- {userId === member.user.id && (
- <Tooltip content="You cannot remove yourself from this organization">
- <Badge variant="danger" className="ml-2">
- <BanIcon />
- Ignored
- </Badge>
- </Tooltip>
- )}
- </div>
- </li>
- );
- })}
- </ul>
+ <div className="text-sm text-muted">
+ The following members will be removed:
+ <div className="mt-2 max-h-80 overflow-y-auto rounded-sm border border-border-control bg-danger/10 p-4 pl-8 text-sm text-danger">
+ <ul className="list-disc">
+ {(popUp.removeMembers.data?.selectedOrgMemberships as OrgUser[])?.map((member) => {
+ const email = member.user.email ?? member.user.username ?? member.inviteEmail;
+ return (
+ <li key={member.id}>
+ <div className="flex items-center">
+ <p className={userId === member.user.id ? "line-through" : ""}>
+ {member.user.firstName || member.user.lastName ? (
+ <>
+ {`${`${member.user.firstName ?? ""} ${member.user.lastName ?? ""}`.trim()} `}
+ (<span className="break-all">{email}</span>)
+ </>
+ ) : (
+ <span className="break-all">{email}</span>
+ )}{" "}
+ </p>
+ {userId === member.user.id && (
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <Badge variant="danger" className="ml-2">
+ <BanIcon />
+ Ignored
+ </Badge>
+ </TooltipTrigger>
+ <TooltipContent>
+ You cannot remove yourself from this organization
+ </TooltipContent>
+ </Tooltip>
+ )}
+ </div>
+ </li>
+ );
+ })}
+ </ul>
+ </div>
</div>
- </DeleteActionModal>
+ </DeleteConfirmDialog>
<UpgradeGate
paywallKey="organization.org-members"
isOpen={popUp.upgradePlan.isOpen}
diff --git a/frontend/src/pages/organization/UserDetailsByIDPage/UserDetailsByIDPage.tsx b/frontend/src/pages/organization/UserDetailsByIDPage/UserDetailsByIDPage.tsx
index ee49e727a9..48c0d6d62c 100644
--- a/frontend/src/pages/organization/UserDetailsByIDPage/UserDetailsByIDPage.tsx
+++ b/frontend/src/pages/organization/UserDetailsByIDPage/UserDetailsByIDPage.tsx
@@ -6,7 +6,6 @@ import { ChevronLeftIcon, EllipsisIcon } from "lucide-react";
import { CustomRolesUpgradeIntent, UpgradeGate } from "@app/components/license/UpgradeGate";
import { createNotification } from "@app/components/notifications";
import { OrgPermissionCan } from "@app/components/permissions";
-import { DeleteActionModal } from "@app/components/v2";
import {
Button,
DropdownMenu,
@@ -14,7 +13,7 @@ import {
DropdownMenuItem,
DropdownMenuTrigger
} from "@app/components/v3";
-import { PageHeader } from "@app/components/v3/platform";
+import { DeleteConfirmDialog, PageHeader } from "@app/components/v3/platform";
import { ROUTE_PATHS } from "@app/const/routes";
import {
OrgPermissionMemberActions,
@@ -226,32 +225,34 @@ const Page = withPermission(
</div>
</>
)}
- <DeleteActionModal
+ <DeleteConfirmDialog
isOpen={popUp.removeMember.isOpen}
title={`Are you sure you want to remove member with username ${
(popUp?.removeMember?.data as { username: string })?.username || ""
}?`}
- onChange={(isOpen) => handlePopUpToggle("removeMember", isOpen)}
- deleteKey="confirm"
- onDeleteApproved={() =>
+ description="This action is irreversible."
+ onOpenChange={(isOpen) => handlePopUpToggle("removeMember", isOpen)}
+ confirmKey="confirm"
+ onConfirm={() =>
onRemoveMemberSubmit(
(popUp?.removeMember?.data as { orgMembershipId: string })?.orgMembershipId
)
}
/>
- <DeleteActionModal
+ <DeleteConfirmDialog
isOpen={popUp.deactivateMember.isOpen}
title={`Are you sure you want to deactivate member with username ${
(popUp?.deactivateMember?.data as { username: string })?.username || ""
}?`}
- onChange={(isOpen) => handlePopUpToggle("deactivateMember", isOpen)}
- deleteKey="confirm"
- onDeleteApproved={() =>
+ description="This action is irreversible."
+ onOpenChange={(isOpen) => handlePopUpToggle("deactivateMember", isOpen)}
+ confirmKey="confirm"
+ onConfirm={() =>
onDeactivateMemberSubmit(
(popUp?.deactivateMember?.data as { orgMembershipId: string })?.orgMembershipId
)
}
- buttonText="Deactivate"
+ confirmLabel="Deactivate"
/>
<UpgradeGate
diff --git a/frontend/src/pages/organization/UserDetailsByIDPage/components/UserOrgMembershipModal.tsx b/frontend/src/pages/organization/UserDetailsByIDPage/components/UserOrgMembershipModal.tsx
index 608202772b..c8d5b2ad64 100644
--- a/frontend/src/pages/organization/UserDetailsByIDPage/components/UserOrgMembershipModal.tsx
+++ b/frontend/src/pages/organization/UserDetailsByIDPage/components/UserOrgMembershipModal.tsx
@@ -1,22 +1,25 @@
-import { useEffect } from "react";
+import { useEffect, useId } from "react";
import { Controller, useFieldArray, useForm } from "react-hook-form";
-import { SingleValue } from "react-select";
-import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons";
-import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { zodResolver } from "@hookform/resolvers/zod";
+import { PlusIcon, TrashIcon } from "lucide-react";
import { z } from "zod";
import { createNotification } from "@app/components/notifications";
import {
Button,
- FilterableSelect,
- FormControl,
- FormLabel,
+ Combobox,
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ Field,
+ FieldError,
+ FieldLabel,
IconButton,
- Input,
- Modal,
- ModalContent
-} from "@app/components/v2";
+ Input
+} from "@app/components/v3";
import { useOrganization, useSubscription } from "@app/context";
import { findOrgMembershipRole, isCustomOrgRole } from "@app/helpers/roles";
import { useGetOrgRoles, useUpdateOrgMembership } from "@app/hooks/api";
@@ -43,7 +46,8 @@ type Props = {
export const UserOrgMembershipModal = ({ popUp, handlePopUpOpen, handlePopUpToggle }: Props) => {
const { subscription } = useSubscription();
- const { currentOrg } = useOrganization();
+ const { currentOrg, isSubOrganization } = useOrganization();
+ const roleInputId = useId();
const orgId = currentOrg?.id || "";
const { data: roles = [] } = useGetOrgRoles(orgId);
@@ -115,32 +119,31 @@ export const UserOrgMembershipModal = ({ popUp, handlePopUpOpen, handlePopUpTogg
};
return (
- <Modal
- isOpen={popUp?.orgMembership?.isOpen}
+ <Dialog
+ open={popUp?.orgMembership?.isOpen}
onOpenChange={(isOpen) => {
handlePopUpToggle("orgMembership", isOpen);
reset();
}}
>
- <ModalContent bodyClassName="overflow-visible" title="Update Membership">
- <form onSubmit={handleSubmit(onFormSubmit)}>
+ <DialogContent isPending={isSubmitting}>
+ <DialogHeader>
+ <DialogTitle>Update Membership</DialogTitle>
+ </DialogHeader>
+ <form className="flex flex-col gap-6" onSubmit={handleSubmit(onFormSubmit)}>
<Controller
control={control}
name="role"
render={({ field: { onChange, value }, fieldState: { error } }) => (
- <FormControl
- label="Update Organization Role"
- errorText={error?.message}
- isError={Boolean(error)}
- >
- <FilterableSelect
+ <Field>
+ <FieldLabel htmlFor={roleInputId}>Update Organization Role</FieldLabel>
+ <Combobox
+ id={roleInputId}
placeholder="Select role..."
options={roles}
- onChange={(newValue) => {
- const role = newValue as SingleValue<(typeof roles)[number]>;
-
- if (!role) return;
-
+ isClearable={false}
+ isError={Boolean(error)}
+ onValueChange={(role) => {
const isCustomRole = isCustomOrgRole(role.slug);
if (isCustomRole && subscription && !subscription?.rbac) {
@@ -153,92 +156,79 @@ export const UserOrgMembershipModal = ({ popUp, handlePopUpOpen, handlePopUpTogg
onChange(role);
}}
- value={value}
+ value={value ?? null}
getOptionValue={(option) => option.slug}
getOptionLabel={(option) => option.name}
/>
- </FormControl>
+ <FieldError>{error?.message}</FieldError>
+ </Field>
)}
/>
- <div>
- <FormLabel label="Metadata" />
- </div>
- <div className="mb-3 flex flex-col space-y-2">
+ <div className="flex flex-col gap-2">
+ <FieldLabel>Metadata</FieldLabel>
{metadataFormFields.fields.map(({ id: metadataFieldId }, i) => (
- <div key={metadataFieldId} className="flex items-end space-x-2">
- <div className="grow">
- {i === 0 && <span className="text-xs text-muted">Key</span>}
+ <div key={metadataFieldId} className="flex items-start gap-2">
+ <Field className="flex-1">
+ {i === 0 && <FieldLabel className="text-xs">Key</FieldLabel>}
<Controller
control={control}
name={`metadata.${i}.key`}
render={({ field, fieldState: { error } }) => (
- <FormControl
- isError={Boolean(error?.message)}
- errorText={error?.message}
- className="mb-0"
- >
- <Input {...field} />
- </FormControl>
+ <>
+ <Input {...field} isError={Boolean(error)} />
+ <FieldError>{error?.message}</FieldError>
+ </>
)}
/>
- </div>
- <div className="grow">
- {i === 0 && <FormLabel label="Value" className="text-xs text-muted" isOptional />}
+ </Field>
+ <Field className="flex-1">
+ {i === 0 && <FieldLabel className="text-xs">Value</FieldLabel>}
<Controller
control={control}
name={`metadata.${i}.value`}
render={({ field, fieldState: { error } }) => (
- <FormControl
- isError={Boolean(error?.message)}
- errorText={error?.message}
- className="mb-0"
- >
- <Input {...field} />
- </FormControl>
+ <>
+ <Input {...field} isError={Boolean(error)} />
+ <FieldError>{error?.message}</FieldError>
+ </>
)}
/>
- </div>
+ </Field>
<IconButton
- ariaLabel="delete key"
- className="bottom-0.5 h-9"
- variant="outline_bg"
+ aria-label="Remove metadata entry"
+ variant="ghost"
+ size="sm"
+ className={i === 0 ? "mt-[27px]" : undefined}
onClick={() => metadataFormFields.remove(i)}
>
- <FontAwesomeIcon icon={faTrash} />
+ <TrashIcon />
</IconButton>
</div>
))}
- <div className="mt-2 flex justify-end">
- <Button
- leftIcon={<FontAwesomeIcon icon={faPlus} />}
- size="xs"
- variant="outline_bg"
- onClick={() => metadataFormFields.append({ key: "", value: "" })}
- >
- Add Key
- </Button>
- </div>
- </div>
- <div className="flex items-center">
<Button
- className="mr-4"
- size="sm"
- type="submit"
- isLoading={isSubmitting}
- isDisabled={isSubmitting}
+ variant="ghost"
+ size="xs"
+ className="self-end"
+ onClick={() => metadataFormFields.append({ key: "", value: "" })}
>
- Update
+ <PlusIcon />
+ Add Key
</Button>
+ </div>
+ <DialogFooter>
+ <DialogClose asChild>
+ <Button variant="ghost">Cancel</Button>
+ </DialogClose>
<Button
- colorSchema="secondary"
- variant="plain"
- onClick={() => handlePopUpToggle("orgMembership", false)}
+ type="submit"
+ variant={isSubOrganization ? "sub-org" : "org"}
+ isPending={isSubmitting}
>
- Cancel
+ Update
</Button>
- </div>
+ </DialogFooter>
</form>
- </ModalContent>
- </Modal>
+ </DialogContent>
+ </Dialog>
);
};