Wrap dialogs with ControlledDialog for consistent modal state management
This commit is contained in:
1 parent
6ac2b9377c
commit
0941ea06f9
16 files changed
+396
-329
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { DataColumn, DataTable, Dialog, Icon, MenuItem, Modal, Row, Text } from '@umami/react-zen';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useState } from 'react';
|
||||
import { ControlledDialog } from '@/components/common/ControlledDialog';
|
||||
import { DateDistance } from '@/components/common/DateDistance';
|
||||
import Link from '@/components/common/Link';
|
||||
import { SortableLabel } from '@/components/common/SortableLabel';
|
||||
@@ -93,11 +94,13 @@ export function AdminTeamsTable({
|
||||
</DataColumn>
|
||||
)}
|
||||
</DataTable>
|
||||
<Modal isOpen={!!deleteTeam}>
|
||||
<Dialog style={{ width: 400 }}>
|
||||
<TeamDeleteForm teamId={deleteTeam} onClose={() => setDeleteTeam(null)} />
|
||||
</Dialog>
|
||||
</Modal>
|
||||
<ControlledDialog>
|
||||
<Modal isOpen={!!deleteTeam}>
|
||||
<Dialog style={{ width: 400 }}>
|
||||
<TeamDeleteForm teamId={deleteTeam} onClose={() => setDeleteTeam(null)} />
|
||||
</Dialog>
|
||||
</Modal>
|
||||
</ControlledDialog>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { DataColumn, DataTable, Icon, MenuItem, Modal, Row, Text } from '@umami/react-zen';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useState } from 'react';
|
||||
import { ControlledDialog } from '@/components/common/ControlledDialog';
|
||||
import { DateDistance } from '@/components/common/DateDistance';
|
||||
import Link from '@/components/common/Link';
|
||||
import { SortableLabel } from '@/components/common/SortableLabel';
|
||||
@@ -84,15 +85,17 @@ export function UsersTable({
|
||||
</DataColumn>
|
||||
)}
|
||||
</DataTable>
|
||||
<Modal isOpen={!!deleteUser}>
|
||||
<UserDeleteForm
|
||||
userId={deleteUser?.id}
|
||||
username={deleteUser?.username}
|
||||
onClose={() => {
|
||||
setDeleteUser(null);
|
||||
}}
|
||||
/>
|
||||
</Modal>
|
||||
<ControlledDialog>
|
||||
<Modal isOpen={!!deleteUser}>
|
||||
<UserDeleteForm
|
||||
userId={deleteUser?.id}
|
||||
username={deleteUser?.username}
|
||||
onClose={() => {
|
||||
setDeleteUser(null);
|
||||
}}
|
||||
/>
|
||||
</Modal>
|
||||
</ControlledDialog>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
} from '@umami/react-zen';
|
||||
import { useState } from 'react';
|
||||
import { Badge } from '@/components/common/Badge';
|
||||
import { ControlledDialog } from '@/components/common/ControlledDialog';
|
||||
import { TypeConfirmationForm } from '@/components/common/TypeConfirmationForm';
|
||||
import {
|
||||
useDeleteQuery,
|
||||
@@ -112,19 +113,21 @@ export function UserTwoFactorSettings({ userId }: { userId: string }) {
|
||||
)}
|
||||
</Column>
|
||||
|
||||
<Modal isOpen={showReset} onOpenChange={open => !open && setShowReset(false)}>
|
||||
<Dialog title={t(labels.twoFactorReset)} style={{ width: 400 }}>
|
||||
<TypeConfirmationForm
|
||||
confirmationValue={CONFIRM_VALUE}
|
||||
onConfirm={handleReset}
|
||||
onClose={() => setShowReset(false)}
|
||||
isLoading={isResetting}
|
||||
error={resetError}
|
||||
buttonLabel={t(labels.reset)}
|
||||
buttonVariant="danger"
|
||||
/>
|
||||
</Dialog>
|
||||
</Modal>
|
||||
<ControlledDialog>
|
||||
<Modal isOpen={showReset} onOpenChange={open => !open && setShowReset(false)}>
|
||||
<Dialog title={t(labels.twoFactorReset)} style={{ width: 400 }}>
|
||||
<TypeConfirmationForm
|
||||
confirmationValue={CONFIRM_VALUE}
|
||||
onConfirm={handleReset}
|
||||
onClose={() => setShowReset(false)}
|
||||
isLoading={isResetting}
|
||||
error={resetError}
|
||||
buttonLabel={t(labels.reset)}
|
||||
buttonVariant="danger"
|
||||
/>
|
||||
</Dialog>
|
||||
</Modal>
|
||||
</ControlledDialog>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import { DataColumn, DataTable, Dialog, Icon, MenuItem, Modal, Row, Text } from
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useState } from 'react';
|
||||
import { WebsiteDeleteForm } from '@/app/(main)/websites/[websiteId]/settings/WebsiteDeleteForm';
|
||||
import { ControlledDialog } from '@/components/common/ControlledDialog';
|
||||
import { DateDistance } from '@/components/common/DateDistance';
|
||||
import Link from '@/components/common/Link';
|
||||
import { SortableLabel } from '@/components/common/SortableLabel';
|
||||
@@ -92,11 +93,13 @@ export function AdminWebsitesTable({ data = [], ...props }: { data: any[] }) {
|
||||
}}
|
||||
</DataColumn>
|
||||
</DataTable>
|
||||
<Modal isOpen={!!deleteWebsite}>
|
||||
<Dialog style={{ width: 400 }}>
|
||||
<WebsiteDeleteForm websiteId={deleteWebsite} onClose={() => setDeleteWebsite(null)} />
|
||||
</Dialog>
|
||||
</Modal>
|
||||
<ControlledDialog>
|
||||
<Modal isOpen={!!deleteWebsite}>
|
||||
<Dialog style={{ width: 400 }}>
|
||||
<WebsiteDeleteForm websiteId={deleteWebsite} onClose={() => setDeleteWebsite(null)} />
|
||||
</Dialog>
|
||||
</Modal>
|
||||
</ControlledDialog>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import {
|
||||
TooltipTrigger,
|
||||
} from '@umami/react-zen';
|
||||
import { useMemo, useState } from 'react';
|
||||
import { ControlledDialog } from '@/components/common/ControlledDialog';
|
||||
import { Panel } from '@/components/common/Panel';
|
||||
import { useBoard, useMessages, useNavigation } from '@/components/hooks';
|
||||
import { Pencil, Plus, X } from '@/components/icons';
|
||||
@@ -121,29 +122,31 @@ export function BoardEditColumn({
|
||||
</Box>
|
||||
</Column>
|
||||
)}
|
||||
<Modal isOpen={showSelect} onOpenChange={setShowSelect}>
|
||||
<Dialog
|
||||
title={t(labels.selectComponent)}
|
||||
style={{
|
||||
width: '1200px',
|
||||
maxWidth: 'calc(100vw - 40px)',
|
||||
maxHeight: 'calc(100dvh - 40px)',
|
||||
padding: '32px',
|
||||
}}
|
||||
>
|
||||
{() => (
|
||||
<BoardComponentSelect
|
||||
teamId={teamId}
|
||||
boardType={boardType}
|
||||
boardEntityType={boardEntityType}
|
||||
boardEntityId={boardEntityId}
|
||||
initialConfig={component}
|
||||
onSelect={handleSelect}
|
||||
onClose={() => setShowSelect(false)}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
</Modal>
|
||||
<ControlledDialog>
|
||||
<Modal isOpen={showSelect} onOpenChange={setShowSelect}>
|
||||
<Dialog
|
||||
title={t(labels.selectComponent)}
|
||||
style={{
|
||||
width: '1200px',
|
||||
maxWidth: 'calc(100vw - 40px)',
|
||||
maxHeight: 'calc(100dvh - 40px)',
|
||||
padding: '32px',
|
||||
}}
|
||||
>
|
||||
{() => (
|
||||
<BoardComponentSelect
|
||||
teamId={teamId}
|
||||
boardType={boardType}
|
||||
boardEntityType={boardEntityType}
|
||||
boardEntityId={boardEntityId}
|
||||
initialConfig={component}
|
||||
onSelect={handleSelect}
|
||||
onClose={() => setShowSelect(false)}
|
||||
/>
|
||||
)}
|
||||
</Dialog>
|
||||
</Modal>
|
||||
</ControlledDialog>
|
||||
</Panel>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Dialog, Modal } from '@umami/react-zen';
|
||||
import { WebsiteExpandedView } from '@/app/(main)/websites/[websiteId]/WebsiteExpandedView';
|
||||
import { ControlledDialog } from '@/components/common/ControlledDialog';
|
||||
import { useMobile, useNavigation } from '@/components/hooks';
|
||||
|
||||
export function ExpandedViewModal({
|
||||
@@ -28,25 +29,27 @@ export function ExpandedViewModal({
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal isOpen={!!view} onOpenChange={handleOpenChange}>
|
||||
<Dialog
|
||||
style={{
|
||||
maxWidth: 1320,
|
||||
width: '100vw',
|
||||
height: isMobile ? '100dvh' : 'calc(100dvh - 40px)',
|
||||
overflow: 'hidden',
|
||||
}}
|
||||
>
|
||||
{({ close }) => {
|
||||
return (
|
||||
<WebsiteExpandedView
|
||||
websiteId={websiteId}
|
||||
excludedIds={excludedIds}
|
||||
onClose={() => handleClose(close)}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
</Dialog>
|
||||
</Modal>
|
||||
<ControlledDialog>
|
||||
<Modal isOpen={!!view} onOpenChange={handleOpenChange}>
|
||||
<Dialog
|
||||
style={{
|
||||
maxWidth: 1320,
|
||||
width: '100vw',
|
||||
height: isMobile ? '100dvh' : 'calc(100dvh - 40px)',
|
||||
overflow: 'hidden',
|
||||
}}
|
||||
>
|
||||
{({ close }) => {
|
||||
return (
|
||||
<WebsiteExpandedView
|
||||
websiteId={websiteId}
|
||||
excludedIds={excludedIds}
|
||||
onClose={() => handleClose(close)}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
</Dialog>
|
||||
</Modal>
|
||||
</ControlledDialog>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
'use client';
|
||||
import { Column, Dialog, Sheet, type SheetProps } from '@umami/react-zen';
|
||||
import { ReplayPlayback } from '@/app/(main)/websites/[websiteId]/replays/[replayId]/ReplayPlayback';
|
||||
import { ControlledDialog } from '@/components/common/ControlledDialog';
|
||||
import { useNavigation } from '@/components/hooks';
|
||||
import { buildPath } from '@/lib/url';
|
||||
import styles from './ReplayModal.module.css';
|
||||
@@ -34,25 +35,27 @@ export function ReplayModal({ websiteId, replayId, className, ...props }: Replay
|
||||
};
|
||||
|
||||
return (
|
||||
<Sheet
|
||||
{...props}
|
||||
side="bottom"
|
||||
size="calc(100dvh - 80px)"
|
||||
className={modalClassName}
|
||||
isOpen={!!activeReplayId}
|
||||
onOpenChange={handleOpenChange}
|
||||
>
|
||||
<Column height="100%">
|
||||
<Dialog className={styles.sheet}>
|
||||
{({ close }) => (
|
||||
<Column padding="6">
|
||||
{activeReplayId && (
|
||||
<ReplayPlayback websiteId={websiteId} replayId={activeReplayId} onClose={close} />
|
||||
)}
|
||||
</Column>
|
||||
)}
|
||||
</Dialog>
|
||||
</Column>
|
||||
</Sheet>
|
||||
<ControlledDialog>
|
||||
<Sheet
|
||||
{...props}
|
||||
side="bottom"
|
||||
size="calc(100dvh - 80px)"
|
||||
className={modalClassName}
|
||||
isOpen={!!activeReplayId}
|
||||
onOpenChange={handleOpenChange}
|
||||
>
|
||||
<Column height="100%">
|
||||
<Dialog className={styles.sheet}>
|
||||
{({ close }) => (
|
||||
<Column padding="6">
|
||||
{activeReplayId && (
|
||||
<ReplayPlayback websiteId={websiteId} replayId={activeReplayId} onClose={close} />
|
||||
)}
|
||||
</Column>
|
||||
)}
|
||||
</Dialog>
|
||||
</Column>
|
||||
</Sheet>
|
||||
</ControlledDialog>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
'use client';
|
||||
import { Column, Dialog, Sheet, type SheetProps } from '@umami/react-zen';
|
||||
import { SessionProfile } from '@/app/(main)/websites/[websiteId]/sessions/SessionProfile';
|
||||
import { ControlledDialog } from '@/components/common/ControlledDialog';
|
||||
import { useNavigation } from '@/components/hooks';
|
||||
import styles from './SessionModal.module.css';
|
||||
|
||||
@@ -23,28 +24,30 @@ export function SessionModal({ websiteId, className, ...props }: SessionModalPro
|
||||
};
|
||||
|
||||
return (
|
||||
<Sheet
|
||||
side="bottom"
|
||||
size="calc(100dvh - 80px)"
|
||||
className={[styles.modal, className].filter(Boolean).join(' ')}
|
||||
isOpen={!!session}
|
||||
onOpenChange={handleOpenChange}
|
||||
{...props}
|
||||
>
|
||||
<Column height="100%">
|
||||
<Dialog className="rounded-lg">
|
||||
{({ close }) => (
|
||||
<Column padding="10">
|
||||
<SessionProfile
|
||||
websiteId={websiteId}
|
||||
sessionId={session}
|
||||
showReplays={!isSharePage}
|
||||
onClose={() => close()}
|
||||
/>
|
||||
</Column>
|
||||
)}
|
||||
</Dialog>
|
||||
</Column>
|
||||
</Sheet>
|
||||
<ControlledDialog>
|
||||
<Sheet
|
||||
side="bottom"
|
||||
size="calc(100dvh - 80px)"
|
||||
className={[styles.modal, className].filter(Boolean).join(' ')}
|
||||
isOpen={!!session}
|
||||
onOpenChange={handleOpenChange}
|
||||
{...props}
|
||||
>
|
||||
<Column height="100%">
|
||||
<Dialog className="rounded-lg">
|
||||
{({ close }) => (
|
||||
<Column padding="10">
|
||||
<SessionProfile
|
||||
websiteId={websiteId}
|
||||
sessionId={session}
|
||||
showReplays={!isSharePage}
|
||||
onClose={() => close()}
|
||||
/>
|
||||
</Column>
|
||||
)}
|
||||
</Dialog>
|
||||
</Column>
|
||||
</Sheet>
|
||||
</ControlledDialog>
|
||||
);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
'use client';
|
||||
import { Column, Dialog, Sheet } from '@umami/react-zen';
|
||||
import { useRouter, useSearchParams } from 'next/navigation';
|
||||
import { ControlledDialog } from '@/components/common/ControlledDialog';
|
||||
import { buildPath } from '@/lib/url';
|
||||
import styles from './SessionModal.module.css';
|
||||
import { SessionProfile } from './SessionProfile';
|
||||
@@ -29,20 +30,22 @@ export function SessionProfileModal({
|
||||
};
|
||||
|
||||
return (
|
||||
<Sheet
|
||||
side="bottom"
|
||||
size="calc(100dvh - 80px)"
|
||||
className={styles.modal}
|
||||
isOpen
|
||||
onOpenChange={handleOpenChange}
|
||||
>
|
||||
<Column height="100%">
|
||||
<Dialog className="rounded-lg">
|
||||
<Column padding="10">
|
||||
<SessionProfile websiteId={websiteId} sessionId={sessionId} onClose={closeModal} />
|
||||
</Column>
|
||||
</Dialog>
|
||||
</Column>
|
||||
</Sheet>
|
||||
<ControlledDialog>
|
||||
<Sheet
|
||||
side="bottom"
|
||||
size="calc(100dvh - 80px)"
|
||||
className={styles.modal}
|
||||
isOpen
|
||||
onOpenChange={handleOpenChange}
|
||||
>
|
||||
<Column height="100%">
|
||||
<Dialog className="rounded-lg">
|
||||
<Column padding="10">
|
||||
<SessionProfile websiteId={websiteId} sessionId={sessionId} onClose={closeModal} />
|
||||
</Column>
|
||||
</Dialog>
|
||||
</Column>
|
||||
</Sheet>
|
||||
</ControlledDialog>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user