Recover relationships after undoing table delete

This commit is contained in:
1ilit
2024-05-31 20:17:21 +03:00
parent 679f6b05e5
commit 3988b8d990
2 changed files with 10 additions and 3 deletions
+7 -1
View File
@@ -68,12 +68,18 @@ export default function TablesContextProvider({ children }) {
const deleteTable = (id, addToHistory = true) => {
if (addToHistory) {
Toast.success(t("table_deleted"));
const rels = relationships.reduce((acc, r) => {
if (r.startTableId === id || r.endTableId === id) {
acc.push(r);
}
return acc;
}, []);
setUndoStack((prev) => [
...prev,
{
action: Action.DELETE,
element: ObjectType.TABLE,
data: tables[id],
data: { table: tables[id], relationship: rels },
message: t("delete_table", { tableName: tables[id] }),
},
]);