From c601ea643180e0e259c8e665818900ef2d4fee74 Mon Sep 17 00:00:00 2001 From: Luann Moreira Date: Tue, 26 May 2026 16:05:19 -0300 Subject: [PATCH] fix(ui-react): migrate raw overlay wrappers to Main Dialog Components MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Five components were implementing dialogs with `fixed inset-0` div wrappers instead of using the shared BaseDialog/ConfirmDialog primitives. This meant no focus trap, no native ESC handling, and no backdrop-click semantics — each component reinvented the wheel differently. Migrate: - MfaDisableDialog → BaseDialog (size="sm") - MfaRecoveryCodesModal → BaseDialog (size="md") - MfaRecoveryTimeoutModal → BaseDialog (canClose={() => false}) to block both ESC and backdrop click — user must use the explicit Close button - Profile (DeleteAccountWarningDialog) → BaseDialog (size="md") - SessionDetails (Delete Recording, Close Session) → ConfirmDialog with per-dialog error state so errors are cleared on re-open Update tests: - Add HTMLDialogElement.showModal/close stubs to global test/setup.ts so all BaseDialog-using components work under jsdom - Mock useFocusTrap in MfaDisableDialog, MfaRecoveryTimeoutModal, and MfaRecover test files - Replace old DOM-traversal backdrop tests (`.relative`/previousSibling) with fireEvent on the native element --- .../src/components/ManageTagsDrawer.tsx | 4 + .../src/components/common/CreateNamespace.tsx | 2 + .../common/CreateNamespaceDialog.tsx | 2 + .../src/components/mfa/MfaDisableDialog.tsx | 18 +- .../components/mfa/MfaRecoveryCodesModal.tsx | 19 ++- .../mfa/MfaRecoveryTimeoutModal.tsx | 20 ++- .../mfa/__tests__/MfaDisableDialog.test.tsx | 19 +-- .../MfaRecoveryTimeoutModal.test.tsx | 23 +-- .../components/vault/VaultSettingsSection.tsx | 3 + .../console/src/pages/ContainerDetails.tsx | 1 - ui-react/apps/console/src/pages/Profile.tsx | 26 ++- .../apps/console/src/pages/SessionDetails.tsx | 160 ++++++------------ ui-react/apps/console/src/pages/Settings.tsx | 4 + .../src/pages/__tests__/MfaRecover.test.tsx | 2 + .../admin/namespaces/EditNamespaceDrawer.tsx | 1 + .../pages/admin/users/CreateUserDrawer.tsx | 1 + .../src/pages/admin/users/EditUserDrawer.tsx | 1 + .../src/pages/team/AddMemberDrawer.tsx | 1 + .../src/pages/team/GenerateKeyDrawer.tsx | 2 + .../src/pages/team/InvitationDrawer.tsx | 2 + ui-react/apps/console/src/test/setup.ts | 8 + 21 files changed, 148 insertions(+), 171 deletions(-) diff --git a/ui-react/apps/console/src/components/ManageTagsDrawer.tsx b/ui-react/apps/console/src/components/ManageTagsDrawer.tsx index 66abd6f6d3d..cf9938f9e33 100644 --- a/ui-react/apps/console/src/components/ManageTagsDrawer.tsx +++ b/ui-react/apps/console/src/components/ManageTagsDrawer.tsx @@ -133,6 +133,7 @@ export default function ManageTagsDrawer({ bodyClassName="flex-1 flex flex-col overflow-hidden" footer={( ) : ( - - - - - )} + { + setShowDeleteLogs(false); + setDeleteLogsError(null); + }} + onConfirm={handleDeleteLogs} + title="Delete Recording" + description="Are you sure you want to delete the session recording? The recording will be permanently removed." + confirmLabel="Delete Recording" + variant="danger" + errorMessage={deleteLogsError} + /> {/* Close Session Dialog */} - {showClose && ( -
-
setShowClose(false)} - /> -
-
-
- -
-
-

- Close Session -

-

- This will terminate the SSH connection -

-
-
-

- Are you sure you want to close the session for{" "} - - {session.username} - {" "} - on{" "} - - {session.device?.name ?? - (session.device_uid ?? "").substring(0, 8)} - - ? -

- {closeSession.error != null && ( -

- Failed to close session. Check your permissions. -

- )} -
- - -
-
-
- )} + { + setShowClose(false); + setCloseError(null); + }} + onConfirm={handleClose} + title="Close Session" + description={ + <> + Are you sure you want to close the session for{" "} + + {session.username} + {" "} + on{" "} + + {session.device?.name ?? (session.device_uid ?? "").substring(0, 8)} + + ? + + } + confirmLabel="Close Session" + variant="danger" + errorMessage={closeError} + /> {/* Recording error banner */} {logsError && ( diff --git a/ui-react/apps/console/src/pages/Settings.tsx b/ui-react/apps/console/src/pages/Settings.tsx index cdc1d4d1708..a157b0ddacc 100644 --- a/ui-react/apps/console/src/pages/Settings.tsx +++ b/ui-react/apps/console/src/pages/Settings.tsx @@ -154,6 +154,7 @@ function EditNameDrawer({ Cancel