Database diagrams editor that allows you to visualize and design your DB with a single query.
TypeScript databasedbdb-migrationeditorerdmariadbmssqlmysqlpostgresqlreactreact-flowschema-migrationssqlsqlitetypescriptvisualizationxyflow
relationships sketch
Guy Ben-Aharonc27ac36ab7e9
diff --git a/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-header/table-list-item-header-button/table-list-item-header-button.tsx b/src/pages/editor-page/side-panel/list-item-header-button/relationship-list-item-header-button.tsxsimilarity index 52%rename from src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-header/table-list-item-header-button/table-list-item-header-button.tsxrename to src/pages/editor-page/side-panel/list-item-header-button/relationship-list-item-header-button.tsxindex de4290ed..99c3af13 100644--- a/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-header/table-list-item-header-button/table-list-item-header-button.tsx+++ b/src/pages/editor-page/side-panel/list-item-header-button/relationship-list-item-header-button.tsx@@ -1,11 +1,11 @@import React from 'react';import { Button, ButtonProps } from '@/components/button/button';-export const TableListItemHeaderButton: React.FC<ButtonProps> = (props) => {+export const ListItemHeaderButton: React.FC<ButtonProps> = (props) => {return (<Buttonvariant="ghost"- className="hover:bg-primary-foreground p-2 w-[34px] text-slate-500 hover:text-slate-700"+ className="hover:bg-primary-foreground p-2 w-8 h-8 text-slate-500 hover:text-slate-700"{...props}/>);diff --git a/src/pages/editor-page/side-panel/relationships-section/relationship-list/relationship-list-item/relationship-list-item-content/relationship-list-item-content.tsx b/src/pages/editor-page/side-panel/relationships-section/relationship-list/relationship-list-item/relationship-list-item-content/relationship-list-item-content.tsxnew file mode 100644index 00000000..f544f738--- /dev/null+++ b/src/pages/editor-page/side-panel/relationships-section/relationship-list/relationship-list-item/relationship-list-item-content/relationship-list-item-content.tsx@@ -0,0 +1,80 @@+import { Button } from '@/components/button/button';+import {+ Select,+ SelectContent,+ SelectGroup,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from '@/components/select/select';+import { FileMinus2, FileOutput, Trash2 } from 'lucide-react';+import React from 'react';++export interface RelationshipListItemContentProps {}++export const RelationshipListItemContent: React.FC<+ RelationshipListItemContentProps+> = () => {+ return (+ <div className="rounded-b-md px-1 flex flex-col my-1">+ <div className="flex flex-col gap-4">+ <div className="flex justify-between items-center gap-1 text-xs">+ <div className="flex flex-col gap-1 text-xs">+ <div className="flex flex-row items-center gap-1">+ <FileMinus2 className="h-4 w-4 text-slate-700" />+ <div className="font-bold text-slate-700">+ Primary+ </div>+ </div>+ table_1(id)+ </div>+ <div className="flex flex-col gap-1 text-xs">+ <div className="flex flex-row items-center gap-1">+ <FileOutput className="h-4 w-4 text-slate-700" />+ <div className="font-bold text-slate-700">+ Foreign+ </div>+ </div>+ table_2(table_1_id)+ </div>+ </div>++ <div className="flex flex-col gap-1 text-xs">+ <div className="flex flex-row items-center gap-1">+ <FileOutput className="h-4 w-4 text-slate-700" />+ <div className="font-bold text-slate-700">+ Cardinality+ </div>+ </div>++ <Select defaultValue={'one_to_one'}>+ <SelectTrigger className="h-8">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ <SelectGroup>+ <SelectItem value="one_to_one">+ One to One+ </SelectItem>+ <SelectItem value="one_to_many">+ One to Many+ </SelectItem>+ <SelectItem value="many_to_one">+ Many to One+ </SelectItem>+ </SelectGroup>+ </SelectContent>+ </Select>+ </div>+ </div>++ {/* <Separator className="" /> */}+ <div className="flex items-center justify-center flex-1">+ <Button variant="ghost" className="text-xs h-8 p-2">+ <Trash2 className="h-3.5 w-3.5 mr-1 text-red-700" />+ <div className="text-red-700">Delete</div>+ </Button>+ </div>+ </div>+ );+};diff --git a/src/pages/editor-page/side-panel/relationships-section/relationship-list/relationship-list-item/relationship-list-item-header/relationship-list-item-header.tsx b/src/pages/editor-page/side-panel/relationships-section/relationship-list/relationship-list-item/relationship-list-item-header/relationship-list-item-header.tsxnew file mode 100644index 00000000..8a005caa--- /dev/null+++ b/src/pages/editor-page/side-panel/relationships-section/relationship-list/relationship-list-item/relationship-list-item-header/relationship-list-item-header.tsx@@ -0,0 +1,27 @@+import React from 'react';+import { Pencil, EllipsisVertical } from 'lucide-react';+import { ListItemHeaderButton } from '../../../../list-item-header-button/relationship-list-item-header-button';++export interface RelationshipListItemHeaderProps {}++export const RelationshipListItemHeader: React.FC<+ RelationshipListItemHeaderProps+> = () => {+ return (+ <div className="h-11 flex items-center justify-between flex-1 group">+ <div>table_1_id_fk</div>+ <div className="flex flex-row-reverse">+ <div>+ <ListItemHeaderButton>+ <EllipsisVertical />+ </ListItemHeaderButton>+ </div>+ <div className="hidden group-hover:flex flex-row-reverse">+ <ListItemHeaderButton>+ <Pencil />+ </ListItemHeaderButton>+ </div>+ </div>+ </div>+ );+};diff --git a/src/pages/editor-page/side-panel/relationships-section/relationship-list/relationship-list-item/relationship-list-item.tsx b/src/pages/editor-page/side-panel/relationships-section/relationship-list/relationship-list-item/relationship-list-item.tsxnew file mode 100644index 00000000..526c2057--- /dev/null+++ b/src/pages/editor-page/side-panel/relationships-section/relationship-list/relationship-list-item/relationship-list-item.tsx@@ -0,0 +1,23 @@+import React from 'react';+import {+ AccordionContent,+ AccordionItem,+ AccordionTrigger,+} from '@/components/accordion/accordion';+import { RelationshipListItemHeader } from './relationship-list-item-header/relationship-list-item-header';+import { RelationshipListItemContent } from './relationship-list-item-content/relationship-list-item-content';++export interface RelationshipListItemProps {}++export const RelationshipListItem: React.FC<RelationshipListItemProps> = () => {+ return (+ <AccordionItem value="item-1" className="rounded-md">+ <AccordionTrigger className="hover:no-underline hover:bg-accent rounded-md px-2 py-0 data-[state=open]:rounded-b-none">+ <RelationshipListItemHeader />+ </AccordionTrigger>+ <AccordionContent className="pb-0">+ <RelationshipListItemContent />+ </AccordionContent>+ </AccordionItem>+ );+};diff --git a/src/pages/editor-page/side-panel/relationships-section/relationship-list/relationship-list.tsx b/src/pages/editor-page/side-panel/relationships-section/relationship-list/relationship-list.tsxnew file mode 100644index 00000000..eecdc151--- /dev/null+++ b/src/pages/editor-page/side-panel/relationships-section/relationship-list/relationship-list.tsx@@ -0,0 +1,17 @@+import React from 'react';+import { Accordion } from '@/components/accordion/accordion';+import { RelationshipListItem } from './relationship-list-item/relationship-list-item';++export interface TableListProps {}++export const RelationshipList: React.FC<TableListProps> = () => {+ return (+ <Accordion+ type="single"+ collapsible+ className="flex flex-col w-full gap-1"+ >+ <RelationshipListItem />+ </Accordion>+ );+};diff --git a/src/pages/editor-page/side-panel/relationships-section/relationships-section.tsx b/src/pages/editor-page/side-panel/relationships-section/relationships-section.tsxnew file mode 100644index 00000000..b840fb73--- /dev/null+++ b/src/pages/editor-page/side-panel/relationships-section/relationships-section.tsx@@ -0,0 +1,34 @@+import React from 'react';+import { Button } from '@/components/button/button';+import { ListCollapse } from 'lucide-react';+import { ScrollArea } from '@/components/scroll-area/scroll-area';+import { Input } from '@/components/input/input';+import { RelationshipList } from './relationship-list/relationship-list';++export interface RelationshipsSectionProps {}++export const RelationshipsSection: React.FC<RelationshipsSectionProps> = () => {+ return (+ <section className="flex flex-col px-2 overflow-hidden flex-1">+ <div className="flex items-center py-1 justify-between gap-4">+ <div>+ <Button variant="ghost" className="p-0 h-8 w-8">+ <ListCollapse className="w-4 h-4" />+ </Button>+ </div>+ <div className="flex-1">+ <Input+ type="text"+ placeholder="Filter"+ className="h-8 focus-visible:ring-0 w-full"+ />+ </div>+ </div>+ <div className="flex flex-col flex-1 overflow-hidden">+ <ScrollArea className="h-full">+ <RelationshipList />+ </ScrollArea>+ </div>+ </section>+ );+};diff --git a/src/pages/editor-page/side-panel/side-panel.tsx b/src/pages/editor-page/side-panel/side-panel.tsxindex 59a43008..9c5e635d 100644--- a/src/pages/editor-page/side-panel/side-panel.tsx+++ b/src/pages/editor-page/side-panel/side-panel.tsx@@ -8,6 +8,7 @@ import {SelectValue,} from '@/components/select/select';import { TablesSection } from './tables-section/tables-section';+import { RelationshipsSection } from './relationships-section/relationships-section';export interface SidePanelProps {}@@ -15,12 +16,12 @@ export const SidePanel: React.FC<SidePanelProps> = () => {const [selected, setSelected] = React.useState('tables');return (<aside className="flex h-full flex-col overflow-hidden">- <div className="flex justify-center border-b">+ <div className="flex justify-center border-b pt-0.5"><Selectvalue={selected}onValueChange={(value) => setSelected(value)}>- <SelectTrigger className="border-none shadow-none focus:border-transparent focus:ring-0">+ <SelectTrigger className="border-none rounded-none shadow-none focus:border-transparent focus:ring-0 hover:underline hover:bg-secondary"><SelectValue /></SelectTrigger><SelectContent>@@ -33,7 +34,11 @@ export const SidePanel: React.FC<SidePanelProps> = () => {</SelectContent></Select></div>- {selected === 'tables' ? <TablesSection /> : null}+ {selected === 'tables' ? (+ <TablesSection />+ ) : (+ <RelationshipsSection />+ )}</aside>);};diff --git a/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-content/table-list-item-content.tsx b/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-content/table-list-item-content.tsxindex 93a11149..36f9b13b 100644--- a/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-content/table-list-item-content.tsx+++ b/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-content/table-list-item-content.tsx@@ -109,9 +109,9 @@ export const TableListItemContent: React.FC<TableListItemContentProps> = ({</Button><Buttonvariant="ghost"- className="hover:bg-primary-foreground p-2 w-[32px] text-slate-500 hover:text-slate-700 h-8"+ className="hover:bg-primary-foreground p-2 w-8 text-slate-500 hover:text-slate-700 h-8">- <Trash2 className="h-3.5 text-red-700" />+ <Trash2 className="h-3.5 w-3.5 text-red-700" /></Button></div></div>diff --git a/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-header/table-list-item-header.tsx b/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-header/table-list-item-header.tsxindex 22c9f854..4ef0d6cc 100644--- a/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-header/table-list-item-header.tsx+++ b/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-header/table-list-item-header.tsx@@ -1,26 +1,26 @@import React from 'react';import { CircleDotDashed, Pencil, EllipsisVertical } from 'lucide-react';-import { TableListItemHeaderButton } from './table-list-item-header-button/table-list-item-header-button';+import { ListItemHeaderButton } from '@/pages/editor-page/side-panel/list-item-header-button/relationship-list-item-header-button';export interface TableListItemHeaderProps {}export const TableListItemHeader: React.FC<TableListItemHeaderProps> = () => {return (- <div className="h-[44px] flex items-center justify-between flex-1 group">+ <div className="h-11 flex items-center justify-between flex-1 group"><div>table_1</div><div className="flex flex-row-reverse"><div>- <TableListItemHeaderButton>+ <ListItemHeaderButton><EllipsisVertical />- </TableListItemHeaderButton>+ </ListItemHeaderButton></div><div className="hidden group-hover:flex flex-row-reverse">- <TableListItemHeaderButton>+ <ListItemHeaderButton><Pencil />- </TableListItemHeaderButton>- <TableListItemHeaderButton>+ </ListItemHeaderButton>+ <ListItemHeaderButton><CircleDotDashed />- </TableListItemHeaderButton>+ </ListItemHeaderButton></div></div></div>diff --git a/src/pages/editor-page/side-panel/tables-section/tables-section.tsx b/src/pages/editor-page/side-panel/tables-section/tables-section.tsxindex 2a38ef03..12fd08ab 100644--- a/src/pages/editor-page/side-panel/tables-section/tables-section.tsx+++ b/src/pages/editor-page/side-panel/tables-section/tables-section.tsx@@ -3,18 +3,26 @@ import { TableList } from './table-list/table-list';import { Button } from '@/components/button/button';import { Table, ListCollapse } from 'lucide-react';import { ScrollArea } from '@/components/scroll-area/scroll-area';+import { Input } from '@/components/input/input';export interface TablesSectionProps {}export const TablesSection: React.FC<TablesSectionProps> = () => {return (<section className="flex flex-col px-2 overflow-hidden flex-1">- <div className="flex items-center py-1 justify-between">+ <div className="flex items-center py-1 justify-between gap-4"><div><Button variant="ghost" className="p-0 h-8 w-8"><ListCollapse className="w-4 h-4" /></Button></div>+ <div className="flex-1">+ <Input+ type="text"+ placeholder="Filter"+ className="h-8 focus-visible:ring-0 w-full"+ />+ </div><Button variant="secondary" className="text-xs h-8 p-2"><Table className="h-4" />Add Table