Skip to content

Database diagrams editor that allows you to visualize and design your DB with a single query.

fix(dialogs): fix height of dialogs for small screens (#440)

Guy Ben-Aharon667685ed0f6a
diff --git a/src/components/dialog/dialog.tsx b/src/components/dialog/dialog.tsx
index 2a38d96b..ad513c93 100644
--- a/src/components/dialog/dialog.tsx
+++ b/src/components/dialog/dialog.tsx
@@ -3,6 +3,7 @@ import * as DialogPrimitive from '@radix-ui/react-dialog';
import { Cross2Icon } from '@radix-ui/react-icons';
import { cn } from '@/lib/utils';
+import { ScrollArea } from '../scroll-area/scroll-area';
const Dialog = DialogPrimitive.Root;
@@ -110,6 +111,18 @@ const DialogDescription = React.forwardRef<
));
DialogDescription.displayName = DialogPrimitive.Description.displayName;
+const DialogInternalContent = React.forwardRef<
+ React.ElementRef<typeof ScrollArea>,
+ React.ComponentPropsWithoutRef<typeof ScrollArea>
+>(({ className, ...props }, ref) => (
+ <ScrollArea
+ ref={ref}
+ className={cn('flex max-h-screen flex-col overflow-y-auto', className)}
+ {...props}
+ />
+));
+DialogInternalContent.displayName = 'DialogInternalContent';
+
export {
Dialog,
DialogPortal,
@@ -121,4 +134,5 @@ export {
DialogFooter,
DialogTitle,
DialogDescription,
+ DialogInternalContent,
};
diff --git a/src/components/scroll-area/scroll-area.tsx b/src/components/scroll-area/scroll-area.tsx
index 267001dd..afc35370 100644
--- a/src/components/scroll-area/scroll-area.tsx
+++ b/src/components/scroll-area/scroll-area.tsx
@@ -12,7 +12,7 @@ const ScrollArea = React.forwardRef<
className={cn('relative overflow-hidden', className)}
{...props}
>
- <ScrollAreaPrimitive.Viewport className="scrollable-flex size-full rounded-[inherit]">
+ <ScrollAreaPrimitive.Viewport className="size-full rounded-[inherit]">
{children}
</ScrollAreaPrimitive.Viewport>
<ScrollBar />
@@ -40,7 +40,7 @@ const ScrollBar = React.forwardRef<
)}
{...props}
>
- <ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
+ <ScrollAreaPrimitive.ScrollAreaThumb className="relative z-20 flex-1 rounded-full bg-border" />
</ScrollAreaPrimitive.ScrollAreaScrollbar>
));
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
diff --git a/src/dialogs/common/import-database/import-database.tsx b/src/dialogs/common/import-database/import-database.tsx
index 0d92d998..9dc06f87 100644
--- a/src/dialogs/common/import-database/import-database.tsx
+++ b/src/dialogs/common/import-database/import-database.tsx
@@ -5,6 +5,7 @@ import {
DialogDescription,
DialogFooter,
DialogHeader,
+ DialogInternalContent,
DialogTitle,
} from '@/components/dialog/dialog';
import { ToggleGroup, ToggleGroupItem } from '@/components/toggle/toggle-group';
@@ -157,188 +158,201 @@ export const ImportDatabase: React.FC<ImportDatabaseProps> = ({
const renderContent = useCallback(() => {
return (
- <div className="flex w-full flex-1 flex-col gap-6">
- {databaseTypeToEditionMap[databaseType].length > 0 ? (
- <div className="flex flex-col gap-1 md:flex-row">
- <p className="text-sm leading-6 text-muted-foreground">
- {t(
- 'new_diagram_dialog.import_database.database_edition'
- )}
- </p>
- <ToggleGroup
- type="single"
- className="ml-1 flex-wrap gap-2"
- value={
- !databaseEdition ? 'regular' : databaseEdition
- }
- onValueChange={(value) => {
- setDatabaseEdition(
- value === 'regular'
- ? undefined
- : (value as DatabaseEdition)
- );
- }}
- >
- <ToggleGroupItem
- value="regular"
- variant="outline"
- className="h-6 gap-1 p-0 px-2 shadow-none"
+ <DialogInternalContent>
+ <div className="flex w-full flex-1 flex-col gap-6">
+ {databaseTypeToEditionMap[databaseType].length > 0 ? (
+ <div className="flex flex-col gap-1 md:flex-row">
+ <p className="text-sm leading-6 text-muted-foreground">
+ {t(
+ 'new_diagram_dialog.import_database.database_edition'
+ )}
+ </p>
+ <ToggleGroup
+ type="single"
+ className="ml-1 flex-wrap gap-2"
+ value={
+ !databaseEdition
+ ? 'regular'
+ : databaseEdition
+ }
+ onValueChange={(value) => {
+ setDatabaseEdition(
+ value === 'regular'
+ ? undefined
+ : (value as DatabaseEdition)
+ );
+ }}
>
- <Avatar className="size-4 rounded-none">
- <AvatarImage
- src={
- databaseSecondaryLogoMap[
- databaseType
- ]
- }
- alt="Regular"
- />
- <AvatarFallback>Regular</AvatarFallback>
- </Avatar>
- Regular
- </ToggleGroupItem>
- {databaseTypeToEditionMap[databaseType].map(
- (edition) => (
- <ToggleGroupItem
- value={edition}
- key={edition}
- variant="outline"
- className="h-6 gap-1 p-0 px-2 shadow-none"
- >
- <Avatar className="size-4">
- <AvatarImage
- src={
- databaseEditionToImageMap[
- edition
- ]
- }
- alt={
- databaseEditionToLabelMap[
- edition
- ]
- }
- />
- <AvatarFallback>
- {
- databaseEditionToLabelMap[
- edition
- ]
- }
- </AvatarFallback>
- </Avatar>
- {databaseEditionToLabelMap[edition]}
- </ToggleGroupItem>
- )
+ <ToggleGroupItem
+ value="regular"
+ variant="outline"
+ className="h-6 gap-1 p-0 px-2 shadow-none"
+ >
+ <Avatar className="size-4 rounded-none">
+ <AvatarImage
+ src={
+ databaseSecondaryLogoMap[
+ databaseType
+ ]
+ }
+ alt="Regular"
+ />
+ <AvatarFallback>Regular</AvatarFallback>
+ </Avatar>
+ Regular
+ </ToggleGroupItem>
+ {databaseTypeToEditionMap[databaseType].map(
+ (edition) => (
+ <ToggleGroupItem
+ value={edition}
+ key={edition}
+ variant="outline"
+ className="h-6 gap-1 p-0 px-2 shadow-none"
+ >
+ <Avatar className="size-4">
+ <AvatarImage
+ src={
+ databaseEditionToImageMap[
+ edition
+ ]
+ }
+ alt={
+ databaseEditionToLabelMap[
+ edition
+ ]
+ }
+ />
+ <AvatarFallback>
+ {
+ databaseEditionToLabelMap[
+ edition
+ ]
+ }
+ </AvatarFallback>
+ </Avatar>
+ {databaseEditionToLabelMap[edition]}
+ </ToggleGroupItem>
+ )
+ )}
+ </ToggleGroup>
+ </div>
+ ) : null}
+ <div className="flex flex-col gap-1">
+ <div className="flex flex-col gap-1 text-sm text-muted-foreground md:flex-row md:justify-between">
+ <div>
+ 1.{' '}
+ {t('new_diagram_dialog.import_database.step_1')}
+ </div>
+ {databaseType === DatabaseType.SQL_SERVER && (
+ <SSMSInfo />
)}
- </ToggleGroup>
- </div>
- ) : null}
- <div className="flex flex-col gap-1">
- <div className="flex flex-col gap-1 text-sm text-muted-foreground md:flex-row md:justify-between">
- <div>
- 1. {t('new_diagram_dialog.import_database.step_1')}
</div>
- {databaseType === DatabaseType.SQL_SERVER && (
- <SSMSInfo />
- )}
- </div>
- {databaseTypeToClientsMap[databaseType].length > 0 ? (
- <Tabs
- value={
- !databaseClient ? 'dbclient' : databaseClient
- }
- onValueChange={(value) => {
- setDatabaseClient(
- value === 'dbclient'
- ? undefined
- : (value as DatabaseClient)
- );
- }}
- >
- <div className="flex flex-1">
- <TabsList className="h-8 justify-start rounded-none rounded-t-sm ">
- <TabsTrigger
- value="dbclient"
- className="h-6 w-20"
- >
- DB Client
- </TabsTrigger>
-
- {databaseClients?.map((client) => (
+ {databaseTypeToClientsMap[databaseType].length > 0 ? (
+ <Tabs
+ value={
+ !databaseClient
+ ? 'dbclient'
+ : databaseClient
+ }
+ onValueChange={(value) => {
+ setDatabaseClient(
+ value === 'dbclient'
+ ? undefined
+ : (value as DatabaseClient)
+ );
+ }}
+ >
+ <div className="flex flex-1">
+ <TabsList className="h-8 justify-start rounded-none rounded-t-sm ">
<TabsTrigger
- key={client}
- value={client}
- className="h-6 !w-20"
+ value="dbclient"
+ className="h-6 w-20"
>
- {databaseClientToLabelMap[client]}
+ DB Client
</TabsTrigger>
- )) ?? []}
- </TabsList>
- </div>
+
+ {databaseClients?.map((client) => (
+ <TabsTrigger
+ key={client}
+ value={client}
+ className="h-6 !w-20"
+ >
+ {
+ databaseClientToLabelMap[
+ client
+ ]
+ }
+ </TabsTrigger>
+ )) ?? []}
+ </TabsList>
+ </div>
+ <CodeSnippet
+ className="h-40 w-full"
+ loading={!importMetadataScripts}
+ code={
+ importMetadataScripts?.[databaseType]?.(
+ {
+ databaseEdition,
+ databaseClient,
+ }
+ ) ?? ''
+ }
+ language={databaseClient ? 'shell' : 'sql'}
+ />
+ </Tabs>
+ ) : (
<CodeSnippet
- className="h-40 w-full"
+ className="h-40 w-full flex-auto"
loading={!importMetadataScripts}
code={
importMetadataScripts?.[databaseType]?.({
databaseEdition,
- databaseClient,
}) ?? ''
}
- language={databaseClient ? 'shell' : 'sql'}
+ language="sql"
/>
- </Tabs>
- ) : (
- <CodeSnippet
- className="h-40 w-full flex-auto"
- loading={!importMetadataScripts}
- code={
- importMetadataScripts?.[databaseType]?.({
- databaseEdition,
- }) ?? ''
- }
- language="sql"
- />
- )}
- </div>
- <div className="flex h-48 flex-col gap-1">
- <p className="text-sm text-muted-foreground">
- 2. {t('new_diagram_dialog.import_database.step_2')}
- </p>
- <Textarea
- className="w-full flex-1 rounded-md bg-muted p-2 text-sm"
- placeholder={t(
- 'new_diagram_dialog.import_database.script_results_placeholder'
)}
- value={scriptResult}
- onChange={handleInputChange}
- />
- {showCheckJsonButton || errorMessage ? (
- <div className="mt-2 flex items-center gap-2">
- {showCheckJsonButton ? (
- <Button
- type="button"
- variant="outline"
- size="sm"
- onClick={handleCheckJson}
- disabled={isCheckingJson}
- >
- {isCheckingJson ? (
- <Spinner size="small" />
- ) : (
- t(
- 'new_diagram_dialog.import_database.check_script_result'
- )
- )}
- </Button>
- ) : (
- <p className="text-sm text-red-700">
- {errorMessage}
- </p>
+ </div>
+ <div className="flex h-48 flex-col gap-1">
+ <p className="text-sm text-muted-foreground">
+ 2. {t('new_diagram_dialog.import_database.step_2')}
+ </p>
+ <Textarea
+ className="w-full flex-1 rounded-md bg-muted p-2 text-sm"
+ placeholder={t(
+ 'new_diagram_dialog.import_database.script_results_placeholder'
)}
- </div>
- ) : null}
+ value={scriptResult}
+ onChange={handleInputChange}
+ />
+ {showCheckJsonButton || errorMessage ? (
+ <div className="mt-2 flex items-center gap-2">
+ {showCheckJsonButton ? (
+ <Button
+ type="button"
+ variant="outline"
+ size="sm"
+ onClick={handleCheckJson}
+ disabled={isCheckingJson}
+ >
+ {isCheckingJson ? (
+ <Spinner size="small" />
+ ) : (
+ t(
+ 'new_diagram_dialog.import_database.check_script_result'
+ )
+ )}
+ </Button>
+ ) : (
+ <p className="text-sm text-red-700">
+ {errorMessage}
+ </p>
+ )}
+ </div>
+ ) : null}
+ </div>
</div>
- </div>
+ </DialogInternalContent>
);
}, [
databaseEdition,
diff --git a/src/dialogs/create-diagram-dialog/create-diagram-dialog.tsx b/src/dialogs/create-diagram-dialog/create-diagram-dialog.tsx
index 2506937a..93795801 100644
--- a/src/dialogs/create-diagram-dialog/create-diagram-dialog.tsx
+++ b/src/dialogs/create-diagram-dialog/create-diagram-dialog.tsx
@@ -128,7 +128,7 @@ export const CreateDiagramDialog: React.FC<CreateDiagramDialogProps> = ({
}}
>
<DialogContent
- className="flex w-[90vw] max-w-[90vw] flex-col overflow-y-auto md:overflow-visible lg:max-w-[60vw] xl:lg:max-w-lg xl:min-w-[45vw]"
+ className="flex max-h-screen w-[90vw] max-w-[90vw] flex-col overflow-y-auto md:overflow-visible lg:max-w-[60vw] xl:lg:max-w-lg xl:min-w-[45vw]"
showClose={hasExistingDiagram}
>
{step === CreateDiagramDialogStep.SELECT_DATABASE ? (
diff --git a/src/dialogs/create-diagram-dialog/select-database/select-database.tsx b/src/dialogs/create-diagram-dialog/select-database/select-database.tsx
index 9a55e1e3..77d5fcb9 100644
--- a/src/dialogs/create-diagram-dialog/select-database/select-database.tsx
+++ b/src/dialogs/create-diagram-dialog/select-database/select-database.tsx
@@ -5,6 +5,7 @@ import {
DialogDescription,
DialogFooter,
DialogHeader,
+ DialogInternalContent,
DialogTitle,
} from '@/components/dialog/dialog';
import { DatabaseType } from '@/lib/domain/database-type';
@@ -40,11 +41,13 @@ export const SelectDatabase: React.FC<SelectDatabaseProps> = ({
{t('new_diagram_dialog.database_selection.description')}
</DialogDescription>
</DialogHeader>
- <SelectDatabaseContent
- databaseType={databaseType}
- onContinue={onContinue}
- setDatabaseType={setDatabaseType}
- />
+ <DialogInternalContent>
+ <SelectDatabaseContent
+ databaseType={databaseType}
+ onContinue={onContinue}
+ setDatabaseType={setDatabaseType}
+ />
+ </DialogInternalContent>
<DialogFooter className="mt-4 flex !justify-between gap-2">
{hasExistingDiagram ? (
<DialogClose asChild>
diff --git a/src/dialogs/export-sql-dialog/export-sql-dialog.tsx b/src/dialogs/export-sql-dialog/export-sql-dialog.tsx
index d999c70f..9cbd248f 100644
--- a/src/dialogs/export-sql-dialog/export-sql-dialog.tsx
+++ b/src/dialogs/export-sql-dialog/export-sql-dialog.tsx
@@ -7,6 +7,7 @@ import {
DialogDescription,
DialogFooter,
DialogHeader,
+ DialogInternalContent,
DialogTitle,
} from '@/components/dialog/dialog';
import { Label } from '@/components/label/label';
@@ -151,7 +152,7 @@ export const ExportSQLDialog: React.FC<ExportSQLDialogProps> = ({
}}
>
<DialogContent
- className="flex max-h-[80vh] flex-col overflow-y-auto xl:min-w-[75vw]"
+ className="flex max-h-screen flex-col overflow-y-auto xl:min-w-[75vw]"
showClose
>
<DialogHeader>
@@ -167,23 +168,24 @@ export const ExportSQLDialog: React.FC<ExportSQLDialogProps> = ({
})}
</DialogDescription>
</DialogHeader>
- <div className="flex flex-1 items-center justify-center">
- {error ? (
- renderError()
- ) : script === undefined ? (
- renderLoader()
- ) : script.length === 0 ? (
- renderError()
- ) : (
- <CodeSnippet
- className="h-96 w-full"
- code={script!}
- autoScroll={true}
- isComplete={!isScriptLoading}
- />
- )}
- </div>
-
+ <DialogInternalContent>
+ <div className="flex flex-1 items-center justify-center">
+ {error ? (
+ renderError()
+ ) : script === undefined ? (
+ renderLoader()
+ ) : script.length === 0 ? (
+ renderError()
+ ) : (
+ <CodeSnippet
+ className="h-96 w-full"
+ code={script!}
+ autoScroll={true}
+ isComplete={!isScriptLoading}
+ />
+ )}
+ </div>
+ </DialogInternalContent>
<DialogFooter className="flex !justify-between gap-2">
<div />
<DialogClose asChild>
diff --git a/src/dialogs/import-database-dialog/import-database-dialog.tsx b/src/dialogs/import-database-dialog/import-database-dialog.tsx
index 1a1bce72..f7993574 100644
--- a/src/dialogs/import-database-dialog/import-database-dialog.tsx
+++ b/src/dialogs/import-database-dialog/import-database-dialog.tsx
@@ -323,7 +323,7 @@ export const ImportDatabaseDialog: React.FC<ImportDatabaseDialogProps> = ({
}}
>
<DialogContent
- className="flex w-[90vw] flex-col overflow-y-auto md:overflow-visible xl:min-w-[45vw]"
+ className="flex max-h-screen w-[90vw] flex-col overflow-y-auto md:overflow-visible xl:min-w-[45vw]"
showClose
>
<ImportDatabase
diff --git a/src/dialogs/import-diagram-dialog/import-diagram-dialog.tsx b/src/dialogs/import-diagram-dialog/import-diagram-dialog.tsx
index 7dc5a070..173dc0de 100644
--- a/src/dialogs/import-diagram-dialog/import-diagram-dialog.tsx
+++ b/src/dialogs/import-diagram-dialog/import-diagram-dialog.tsx
@@ -7,6 +7,7 @@ import {
DialogDescription,
DialogFooter,
DialogHeader,
+ DialogInternalContent,
DialogTitle,
} from '@/components/dialog/dialog';
import { Button } from '@/components/button/button';
@@ -87,7 +88,7 @@ export const ImportDiagramDialog: React.FC<ImportDiagramDialogProps> = ({
}
}}
>
- <DialogContent className="flex flex-col" showClose>
+ <DialogContent className="flex max-h-screen flex-col" showClose>
<DialogHeader>
<DialogTitle>
{t('import_diagram_dialog.title')}
@@ -96,23 +97,27 @@ export const ImportDiagramDialog: React.FC<ImportDiagramDialogProps> = ({
{t('import_diagram_dialog.description')}
</DialogDescription>
</DialogHeader>
- <div className="flex flex-col p-1">
- <FileUploader
- supportedExtensions={['.json']}
- onFilesChange={onFileChange}
- />
- {error ? (
- <Alert variant="destructive" className="mt-2">
- <AlertCircle className="size-4" />
- <AlertTitle>
- {t('import_diagram_dialog.error.title')}
- </AlertTitle>
- <AlertDescription>
- {t('import_diagram_dialog.error.description')}
- </AlertDescription>
- </Alert>
- ) : null}
- </div>
+ <DialogInternalContent>
+ <div className="flex flex-col p-1">
+ <FileUploader
+ supportedExtensions={['.json']}
+ onFilesChange={onFileChange}
+ />
+ {error ? (
+ <Alert variant="destructive" className="mt-2">
+ <AlertCircle className="size-4" />
+ <AlertTitle>
+ {t('import_diagram_dialog.error.title')}
+ </AlertTitle>
+ <AlertDescription>
+ {t(
+ 'import_diagram_dialog.error.description'
+ )}
+ </AlertDescription>
+ </Alert>
+ ) : null}
+ </div>
+ </DialogInternalContent>
<DialogFooter className="flex gap-1 md:justify-between">
<DialogClose asChild>
<Button variant="secondary">
diff --git a/src/dialogs/open-diagram-dialog/open-diagram-dialog.tsx b/src/dialogs/open-diagram-dialog/open-diagram-dialog.tsx
index 305128a2..7078ad15 100644
--- a/src/dialogs/open-diagram-dialog/open-diagram-dialog.tsx
+++ b/src/dialogs/open-diagram-dialog/open-diagram-dialog.tsx
@@ -7,9 +7,9 @@ import {
DialogDescription,
DialogFooter,
DialogHeader,
+ DialogInternalContent,
DialogTitle,
} from '@/components/dialog/dialog';
-import { ScrollArea } from '@/components/scroll-area/scroll-area';
import {
Table,
TableBody,
@@ -74,7 +74,7 @@ export const OpenDiagramDialog: React.FC<OpenDiagramDialogProps> = ({
}}
>
<DialogContent
- className="flex w-[90vw] flex-col overflow-y-auto md:w-screen xl:min-w-[55vw]"
+ className="flex h-[30rem] max-h-screen w-[90vw] flex-col overflow-y-auto md:w-screen xl:min-w-[55vw]"
showClose
>
<DialogHeader>
@@ -83,9 +83,9 @@ export const OpenDiagramDialog: React.FC<OpenDiagramDialogProps> = ({
{t('open_diagram_dialog.description')}
</DialogDescription>
</DialogHeader>
- <div className="flex flex-1 items-center justify-center">
- <ScrollArea className="h-80 w-full">
- <Table className="h-fit">
+ <DialogInternalContent>
+ <div className="flex flex-1 items-center justify-center">
+ <Table>
<TableHeader className="sticky top-0 bg-background">
<TableRow>
<TableHead />
@@ -155,8 +155,8 @@ export const OpenDiagramDialog: React.FC<OpenDiagramDialogProps> = ({
))}
</TableBody>
</Table>
- </ScrollArea>
- </div>
+ </div>
+ </DialogInternalContent>
<DialogFooter className="flex !justify-between gap-2">
<DialogClose asChild>
diff --git a/src/index.css b/src/index.css
index b6983c81..fae1a2eb 100644
--- a/src/index.css
+++ b/src/index.css
@@ -16,10 +16,6 @@
@apply hidden !important;
}
- .scrollable-flex > div {
- @apply !flex;
- }
-
.marker-definitions {
}
}