mirror of
https://github.com/chartdb/chartdb.git
synced 2025-11-06 06:53:34 +00:00
clear diagram data
This commit is contained in:
29
package-lock.json
generated
29
package-lock.json
generated
@@ -10,6 +10,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ai-sdk/openai": "^0.0.51",
|
"@ai-sdk/openai": "^0.0.51",
|
||||||
"@radix-ui/react-accordion": "^1.2.0",
|
"@radix-ui/react-accordion": "^1.2.0",
|
||||||
|
"@radix-ui/react-alert-dialog": "^1.1.1",
|
||||||
"@radix-ui/react-checkbox": "^1.1.1",
|
"@radix-ui/react-checkbox": "^1.1.1",
|
||||||
"@radix-ui/react-collapsible": "^1.1.0",
|
"@radix-ui/react-collapsible": "^1.1.0",
|
||||||
"@radix-ui/react-dialog": "^1.1.1",
|
"@radix-ui/react-dialog": "^1.1.1",
|
||||||
@@ -1402,6 +1403,34 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@radix-ui/react-alert-dialog": {
|
||||||
|
"version": "1.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-alert-dialog/-/react-alert-dialog-1.1.1.tgz",
|
||||||
|
"integrity": "sha512-wmCoJwj7byuVuiLKqDLlX7ClSUU0vd9sdCeM+2Ls+uf13+cpSJoMgwysHq1SGVVkJj5Xn0XWi1NoRCdkMpr6Mw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@radix-ui/primitive": "1.1.0",
|
||||||
|
"@radix-ui/react-compose-refs": "1.1.0",
|
||||||
|
"@radix-ui/react-context": "1.1.0",
|
||||||
|
"@radix-ui/react-dialog": "1.1.1",
|
||||||
|
"@radix-ui/react-primitive": "2.0.0",
|
||||||
|
"@radix-ui/react-slot": "1.1.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@types/react": "*",
|
||||||
|
"@types/react-dom": "*",
|
||||||
|
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
||||||
|
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@types/react": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"@types/react-dom": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@radix-ui/react-arrow": {
|
"node_modules/@radix-ui/react-arrow": {
|
||||||
"version": "1.1.0",
|
"version": "1.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-arrow/-/react-arrow-1.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-arrow/-/react-arrow-1.1.0.tgz",
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ai-sdk/openai": "^0.0.51",
|
"@ai-sdk/openai": "^0.0.51",
|
||||||
"@radix-ui/react-accordion": "^1.2.0",
|
"@radix-ui/react-accordion": "^1.2.0",
|
||||||
|
"@radix-ui/react-alert-dialog": "^1.1.1",
|
||||||
"@radix-ui/react-checkbox": "^1.1.1",
|
"@radix-ui/react-checkbox": "^1.1.1",
|
||||||
"@radix-ui/react-collapsible": "^1.1.0",
|
"@radix-ui/react-collapsible": "^1.1.0",
|
||||||
"@radix-ui/react-dialog": "^1.1.1",
|
"@radix-ui/react-dialog": "^1.1.1",
|
||||||
|
|||||||
139
src/components/alert-dialog/alert-dialog.tsx
Normal file
139
src/components/alert-dialog/alert-dialog.tsx
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
import * as React from 'react';
|
||||||
|
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
|
||||||
|
|
||||||
|
import { cn } from '@/lib/utils';
|
||||||
|
import { buttonVariants } from '../button/button-variants';
|
||||||
|
|
||||||
|
const AlertDialog = AlertDialogPrimitive.Root;
|
||||||
|
|
||||||
|
const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
|
||||||
|
|
||||||
|
const AlertDialogPortal = AlertDialogPrimitive.Portal;
|
||||||
|
|
||||||
|
const AlertDialogOverlay = React.forwardRef<
|
||||||
|
React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<AlertDialogPrimitive.Overlay
|
||||||
|
className={cn(
|
||||||
|
'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
ref={ref}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
|
||||||
|
|
||||||
|
const AlertDialogContent = React.forwardRef<
|
||||||
|
React.ElementRef<typeof AlertDialogPrimitive.Content>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<AlertDialogPortal>
|
||||||
|
<AlertDialogOverlay />
|
||||||
|
<AlertDialogPrimitive.Content
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg',
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
</AlertDialogPortal>
|
||||||
|
));
|
||||||
|
AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
|
||||||
|
|
||||||
|
const AlertDialogHeader = ({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
'flex flex-col space-y-2 text-center sm:text-left',
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
AlertDialogHeader.displayName = 'AlertDialogHeader';
|
||||||
|
|
||||||
|
const AlertDialogFooter = ({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.HTMLAttributes<HTMLDivElement>) => (
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2',
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
AlertDialogFooter.displayName = 'AlertDialogFooter';
|
||||||
|
|
||||||
|
const AlertDialogTitle = React.forwardRef<
|
||||||
|
React.ElementRef<typeof AlertDialogPrimitive.Title>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<AlertDialogPrimitive.Title
|
||||||
|
ref={ref}
|
||||||
|
className={cn('text-lg font-semibold', className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
|
||||||
|
|
||||||
|
const AlertDialogDescription = React.forwardRef<
|
||||||
|
React.ElementRef<typeof AlertDialogPrimitive.Description>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<AlertDialogPrimitive.Description
|
||||||
|
ref={ref}
|
||||||
|
className={cn('text-sm text-muted-foreground', className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
AlertDialogDescription.displayName =
|
||||||
|
AlertDialogPrimitive.Description.displayName;
|
||||||
|
|
||||||
|
const AlertDialogAction = React.forwardRef<
|
||||||
|
React.ElementRef<typeof AlertDialogPrimitive.Action>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<AlertDialogPrimitive.Action
|
||||||
|
ref={ref}
|
||||||
|
className={cn(buttonVariants(), className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
|
||||||
|
|
||||||
|
const AlertDialogCancel = React.forwardRef<
|
||||||
|
React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
|
||||||
|
>(({ className, ...props }, ref) => (
|
||||||
|
<AlertDialogPrimitive.Cancel
|
||||||
|
ref={ref}
|
||||||
|
className={cn(
|
||||||
|
buttonVariants({ variant: 'outline' }),
|
||||||
|
'mt-2 sm:mt-0',
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
));
|
||||||
|
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
|
||||||
|
|
||||||
|
export {
|
||||||
|
AlertDialog,
|
||||||
|
AlertDialogPortal,
|
||||||
|
AlertDialogOverlay,
|
||||||
|
AlertDialogTrigger,
|
||||||
|
AlertDialogContent,
|
||||||
|
AlertDialogHeader,
|
||||||
|
AlertDialogFooter,
|
||||||
|
AlertDialogTitle,
|
||||||
|
AlertDialogDescription,
|
||||||
|
AlertDialogAction,
|
||||||
|
AlertDialogCancel,
|
||||||
|
};
|
||||||
@@ -23,6 +23,7 @@ export interface ChartDBContext {
|
|||||||
) => Promise<void>;
|
) => Promise<void>;
|
||||||
loadDiagram: (diagramId: string) => Promise<Diagram | undefined>;
|
loadDiagram: (diagramId: string) => Promise<Diagram | undefined>;
|
||||||
updateDiagramUpdatedAt: () => Promise<void>;
|
updateDiagramUpdatedAt: () => Promise<void>;
|
||||||
|
clearDiagramData: () => Promise<void>;
|
||||||
|
|
||||||
// Database type operations
|
// Database type operations
|
||||||
updateDatabaseType: (databaseType: DatabaseType) => Promise<void>;
|
updateDatabaseType: (databaseType: DatabaseType) => Promise<void>;
|
||||||
@@ -138,6 +139,7 @@ export const chartDBContext = createContext<ChartDBContext>({
|
|||||||
updateDiagramName: emptyFn,
|
updateDiagramName: emptyFn,
|
||||||
updateDiagramUpdatedAt: emptyFn,
|
updateDiagramUpdatedAt: emptyFn,
|
||||||
loadDiagram: emptyFn,
|
loadDiagram: emptyFn,
|
||||||
|
clearDiagramData: emptyFn,
|
||||||
|
|
||||||
// Database type operations
|
// Database type operations
|
||||||
updateDatabaseType: emptyFn,
|
updateDatabaseType: emptyFn,
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ export const ChartDBProvider: React.FC<React.PropsWithChildren> = ({
|
|||||||
children,
|
children,
|
||||||
}) => {
|
}) => {
|
||||||
const db = useStorage();
|
const db = useStorage();
|
||||||
const { addUndoAction, resetRedoStack } = useRedoUndoStack();
|
const { addUndoAction, resetRedoStack, resetUndoStack } =
|
||||||
|
useRedoUndoStack();
|
||||||
const [diagramId, setDiagramId] = useState('');
|
const [diagramId, setDiagramId] = useState('');
|
||||||
const [diagramName, setDiagramName] = useState('');
|
const [diagramName, setDiagramName] = useState('');
|
||||||
const [diagramCreatedAt, setDiagramCreatedAt] = useState<Date>(new Date());
|
const [diagramCreatedAt, setDiagramCreatedAt] = useState<Date>(new Date());
|
||||||
@@ -47,6 +48,23 @@ export const ChartDBProvider: React.FC<React.PropsWithChildren> = ({
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const clearDiagramData: ChartDBContext['clearDiagramData'] =
|
||||||
|
useCallback(async () => {
|
||||||
|
const updatedAt = new Date();
|
||||||
|
setTables([]);
|
||||||
|
setRelationships([]);
|
||||||
|
setDiagramUpdatedAt(updatedAt);
|
||||||
|
|
||||||
|
resetRedoStack();
|
||||||
|
resetUndoStack();
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
db.updateDiagram({ id: diagramId, attributes: { updatedAt } }),
|
||||||
|
db.deleteDiagramTables(diagramId),
|
||||||
|
db.deleteDiagramRelationships(diagramId),
|
||||||
|
]);
|
||||||
|
}, [db, diagramId, resetRedoStack, resetUndoStack]);
|
||||||
|
|
||||||
const updateDiagramUpdatedAt: ChartDBContext['updateDiagramUpdatedAt'] =
|
const updateDiagramUpdatedAt: ChartDBContext['updateDiagramUpdatedAt'] =
|
||||||
useCallback(async () => {
|
useCallback(async () => {
|
||||||
const updatedAt = new Date();
|
const updatedAt = new Date();
|
||||||
@@ -928,6 +946,7 @@ export const ChartDBProvider: React.FC<React.PropsWithChildren> = ({
|
|||||||
updateDiagramName,
|
updateDiagramName,
|
||||||
loadDiagram,
|
loadDiagram,
|
||||||
updateDatabaseType,
|
updateDatabaseType,
|
||||||
|
clearDiagramData,
|
||||||
updateDiagramUpdatedAt,
|
updateDiagramUpdatedAt,
|
||||||
createTable,
|
createTable,
|
||||||
addTable,
|
addTable,
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ export interface StorageContext {
|
|||||||
}) => Promise<void>;
|
}) => Promise<void>;
|
||||||
deleteTable: (params: { diagramId: string; id: string }) => Promise<void>;
|
deleteTable: (params: { diagramId: string; id: string }) => Promise<void>;
|
||||||
listTables: (diagramId: string) => Promise<DBTable[]>;
|
listTables: (diagramId: string) => Promise<DBTable[]>;
|
||||||
|
deleteDiagramTables: (diagramId: string) => Promise<void>;
|
||||||
|
|
||||||
// Relationships operations
|
// Relationships operations
|
||||||
addRelationship: (params: {
|
addRelationship: (params: {
|
||||||
@@ -60,6 +61,7 @@ export interface StorageContext {
|
|||||||
id: string;
|
id: string;
|
||||||
}) => Promise<void>;
|
}) => Promise<void>;
|
||||||
listRelationships: (diagramId: string) => Promise<DBRelationship[]>;
|
listRelationships: (diagramId: string) => Promise<DBRelationship[]>;
|
||||||
|
deleteDiagramRelationships: (diagramId: string) => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const storageContext = createContext<StorageContext>({
|
export const storageContext = createContext<StorageContext>({
|
||||||
@@ -77,10 +79,12 @@ export const storageContext = createContext<StorageContext>({
|
|||||||
updateTable: emptyFn,
|
updateTable: emptyFn,
|
||||||
deleteTable: emptyFn,
|
deleteTable: emptyFn,
|
||||||
listTables: emptyFn,
|
listTables: emptyFn,
|
||||||
|
deleteDiagramTables: emptyFn,
|
||||||
|
|
||||||
addRelationship: emptyFn,
|
addRelationship: emptyFn,
|
||||||
getRelationship: emptyFn,
|
getRelationship: emptyFn,
|
||||||
updateRelationship: emptyFn,
|
updateRelationship: emptyFn,
|
||||||
deleteRelationship: emptyFn,
|
deleteRelationship: emptyFn,
|
||||||
listRelationships: emptyFn,
|
listRelationships: emptyFn,
|
||||||
|
deleteDiagramRelationships: emptyFn,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -188,6 +188,12 @@ export const StorageProvider: React.FC<React.PropsWithChildren> = ({
|
|||||||
return await db.db_tables.get({ id, diagramId });
|
return await db.db_tables.get({ id, diagramId });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const deleteDiagramTables: StorageContext['deleteDiagramTables'] = async (
|
||||||
|
diagramId: string
|
||||||
|
) => {
|
||||||
|
await db.db_tables.where('diagramId').equals(diagramId).delete();
|
||||||
|
};
|
||||||
|
|
||||||
const updateTable: StorageContext['updateTable'] = async ({
|
const updateTable: StorageContext['updateTable'] = async ({
|
||||||
id,
|
id,
|
||||||
attributes,
|
attributes,
|
||||||
@@ -238,6 +244,14 @@ export const StorageProvider: React.FC<React.PropsWithChildren> = ({
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const deleteDiagramRelationships: StorageContext['deleteDiagramRelationships'] =
|
||||||
|
async (diagramId: string) => {
|
||||||
|
await db.db_relationships
|
||||||
|
.where('diagramId')
|
||||||
|
.equals(diagramId)
|
||||||
|
.delete();
|
||||||
|
};
|
||||||
|
|
||||||
const getRelationship: StorageContext['getRelationship'] = async ({
|
const getRelationship: StorageContext['getRelationship'] = async ({
|
||||||
id,
|
id,
|
||||||
diagramId,
|
diagramId,
|
||||||
@@ -302,6 +316,8 @@ export const StorageProvider: React.FC<React.PropsWithChildren> = ({
|
|||||||
updateRelationship,
|
updateRelationship,
|
||||||
deleteRelationship,
|
deleteRelationship,
|
||||||
listRelationships,
|
listRelationships,
|
||||||
|
deleteDiagramTables,
|
||||||
|
deleteDiagramRelationships,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ export const ExportSQLDialog: React.FC<ExportSQLDialogProps> = ({
|
|||||||
}, [targetDatabaseType, currentDiagram]);
|
}, [targetDatabaseType, currentDiagram]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!dialog.open) return;
|
||||||
setScript(undefined);
|
setScript(undefined);
|
||||||
const fetchScript = async () => {
|
const fetchScript = async () => {
|
||||||
const script = await exportSQLScript();
|
const script = await exportSQLScript();
|
||||||
|
|||||||
@@ -32,16 +32,28 @@ import {
|
|||||||
databaseTypeToLabelMap,
|
databaseTypeToLabelMap,
|
||||||
} from '@/lib/databases';
|
} from '@/lib/databases';
|
||||||
import { DatabaseType } from '@/lib/domain/database-type';
|
import { DatabaseType } from '@/lib/domain/database-type';
|
||||||
|
import {
|
||||||
|
AlertDialog,
|
||||||
|
AlertDialogAction,
|
||||||
|
AlertDialogCancel,
|
||||||
|
AlertDialogContent,
|
||||||
|
AlertDialogDescription,
|
||||||
|
AlertDialogFooter,
|
||||||
|
AlertDialogHeader,
|
||||||
|
AlertDialogTitle,
|
||||||
|
} from '@/components/alert-dialog/alert-dialog';
|
||||||
|
|
||||||
export interface TopNavbarProps {}
|
export interface TopNavbarProps {}
|
||||||
|
|
||||||
export const TopNavbar: React.FC<TopNavbarProps> = () => {
|
export const TopNavbar: React.FC<TopNavbarProps> = () => {
|
||||||
const { diagramName, updateDiagramName, currentDiagram } = useChartDB();
|
const { diagramName, updateDiagramName, currentDiagram, clearDiagramData } =
|
||||||
|
useChartDB();
|
||||||
const {
|
const {
|
||||||
openCreateDiagramDialog,
|
openCreateDiagramDialog,
|
||||||
openOpenDiagramDialog,
|
openOpenDiagramDialog,
|
||||||
openExportSQLDialog,
|
openExportSQLDialog,
|
||||||
} = useDialog();
|
} = useDialog();
|
||||||
|
const [showClearAlert, setShowClearAlert] = useState(false);
|
||||||
const [editMode, setEditMode] = useState(false);
|
const [editMode, setEditMode] = useState(false);
|
||||||
const { exportImage } = useExportImage();
|
const { exportImage } = useExportImage();
|
||||||
const [editedDiagramName, setEditedDiagramName] =
|
const [editedDiagramName, setEditedDiagramName] =
|
||||||
@@ -79,6 +91,11 @@ export const TopNavbar: React.FC<TopNavbarProps> = () => {
|
|||||||
setEditMode(true);
|
setEditMode(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const clearDiagramDataHandler = useCallback(async () => {
|
||||||
|
setShowClearAlert(false);
|
||||||
|
await clearDiagramData();
|
||||||
|
}, [clearDiagramData]);
|
||||||
|
|
||||||
const exportPNG = useCallback(() => {
|
const exportPNG = useCallback(() => {
|
||||||
exportImage('png');
|
exportImage('png');
|
||||||
}, [exportImage]);
|
}, [exportImage]);
|
||||||
@@ -103,6 +120,7 @@ export const TopNavbar: React.FC<TopNavbarProps> = () => {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<nav className="flex flex-row items-center justify-between px-4 h-12 border-b">
|
<nav className="flex flex-row items-center justify-between px-4 h-12 border-b">
|
||||||
<div className="flex flex-1 justify-start gap-x-3">
|
<div className="flex flex-1 justify-start gap-x-3">
|
||||||
<div className="flex font-primary items-center">
|
<div className="flex font-primary items-center">
|
||||||
@@ -145,7 +163,11 @@ export const TopNavbar: React.FC<TopNavbarProps> = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{databaseTypeToLabelMap['generic']}
|
{
|
||||||
|
databaseTypeToLabelMap[
|
||||||
|
'generic'
|
||||||
|
]
|
||||||
|
}
|
||||||
</MenubarItem>
|
</MenubarItem>
|
||||||
<MenubarItem
|
<MenubarItem
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
@@ -169,7 +191,11 @@ export const TopNavbar: React.FC<TopNavbarProps> = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{databaseTypeToLabelMap['mysql']}
|
{
|
||||||
|
databaseTypeToLabelMap[
|
||||||
|
'mysql'
|
||||||
|
]
|
||||||
|
}
|
||||||
</MenubarItem>
|
</MenubarItem>
|
||||||
<MenubarItem
|
<MenubarItem
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
@@ -193,7 +219,11 @@ export const TopNavbar: React.FC<TopNavbarProps> = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{databaseTypeToLabelMap['mariadb']}
|
{
|
||||||
|
databaseTypeToLabelMap[
|
||||||
|
'mariadb'
|
||||||
|
]
|
||||||
|
}
|
||||||
</MenubarItem>
|
</MenubarItem>
|
||||||
<MenubarItem
|
<MenubarItem
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
@@ -203,7 +233,11 @@ export const TopNavbar: React.FC<TopNavbarProps> = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{databaseTypeToLabelMap['sqlite']}
|
{
|
||||||
|
databaseTypeToLabelMap[
|
||||||
|
'sqlite'
|
||||||
|
]
|
||||||
|
}
|
||||||
</MenubarItem>
|
</MenubarItem>
|
||||||
</MenubarSubContent>
|
</MenubarSubContent>
|
||||||
</MenubarSub>
|
</MenubarSub>
|
||||||
@@ -231,13 +265,19 @@ export const TopNavbar: React.FC<TopNavbarProps> = () => {
|
|||||||
<MenubarTrigger>Edit</MenubarTrigger>
|
<MenubarTrigger>Edit</MenubarTrigger>
|
||||||
<MenubarContent>
|
<MenubarContent>
|
||||||
<MenubarItem>
|
<MenubarItem>
|
||||||
Undo <MenubarShortcut>⌘Z</MenubarShortcut>
|
Undo{' '}
|
||||||
|
<MenubarShortcut>⌘Z</MenubarShortcut>
|
||||||
</MenubarItem>
|
</MenubarItem>
|
||||||
<MenubarItem>
|
<MenubarItem>
|
||||||
Redo <MenubarShortcut>⇧⌘Z</MenubarShortcut>
|
Redo{' '}
|
||||||
|
<MenubarShortcut>⇧⌘Z</MenubarShortcut>
|
||||||
</MenubarItem>
|
</MenubarItem>
|
||||||
<MenubarSeparator />
|
<MenubarSeparator />
|
||||||
<MenubarItem>Clear</MenubarItem>
|
<MenubarItem
|
||||||
|
onClick={() => setShowClearAlert(true)}
|
||||||
|
>
|
||||||
|
Clear
|
||||||
|
</MenubarItem>
|
||||||
</MenubarContent>
|
</MenubarContent>
|
||||||
</MenubarMenu>
|
</MenubarMenu>
|
||||||
<MenubarMenu>
|
<MenubarMenu>
|
||||||
@@ -268,7 +308,11 @@ export const TopNavbar: React.FC<TopNavbarProps> = () => {
|
|||||||
/>
|
/>
|
||||||
</TooltipTrigger>
|
</TooltipTrigger>
|
||||||
<TooltipContent>
|
<TooltipContent>
|
||||||
{databaseTypeToLabelMap[currentDiagram.databaseType]}
|
{
|
||||||
|
databaseTypeToLabelMap[
|
||||||
|
currentDiagram.databaseType
|
||||||
|
]
|
||||||
|
}
|
||||||
</TooltipContent>
|
</TooltipContent>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
@@ -326,5 +370,29 @@ export const TopNavbar: React.FC<TopNavbarProps> = () => {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
<AlertDialog open={showClearAlert}>
|
||||||
|
<AlertDialogContent>
|
||||||
|
<AlertDialogHeader>
|
||||||
|
<AlertDialogTitle>
|
||||||
|
Are you absolutely sure?
|
||||||
|
</AlertDialogTitle>
|
||||||
|
<AlertDialogDescription>
|
||||||
|
This action cannot be undone. This will permanently
|
||||||
|
delete all the data in the diagram.
|
||||||
|
</AlertDialogDescription>
|
||||||
|
</AlertDialogHeader>
|
||||||
|
<AlertDialogFooter>
|
||||||
|
<AlertDialogCancel
|
||||||
|
onClick={() => setShowClearAlert(false)}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</AlertDialogCancel>
|
||||||
|
<AlertDialogAction onClick={clearDiagramDataHandler}>
|
||||||
|
Clear
|
||||||
|
</AlertDialogAction>
|
||||||
|
</AlertDialogFooter>
|
||||||
|
</AlertDialogContent>
|
||||||
|
</AlertDialog>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user