Skip to content

Free, simple, and intuitive online database diagram editor and SQL generator.

Delete diagram on clear (#321)

sudhir3c95e51f06ca
diff --git a/src/components/EditorHeader/ControlPanel.jsx b/src/components/EditorHeader/ControlPanel.jsx
index 4f14ad95..6c9f8a95 100644
--- a/src/components/EditorHeader/ControlPanel.jsx
+++ b/src/components/EditorHeader/ControlPanel.jsx
@@ -1190,7 +1190,7 @@ export default function ControlPanel({
title: t("clear"),
message: t("are_you_sure_clear"),
},
- function: () => {
+ function: async () => {
setTables([]);
setRelationships([]);
setAreas([]);
@@ -1199,6 +1199,20 @@ export default function ControlPanel({
setTypes([]);
setUndoStack([]);
setRedoStack([]);
+
+ if (!diagramId) {
+ console.error("Something went wrong.");
+ return;
+ }
+
+ db.table("diagrams")
+ .delete(diagramId)
+ .then(() => {
+ console.info('Deleted diagram successfully.')
+ })
+ .catch((error) => {
+ console.error(`Error deleting records with gistId '${diagramId}':`, error);
+ });
},
},
edit: {