From 2f7702a5936947198aeaaf2c53ed899bf5135406 Mon Sep 17 00:00:00 2001 From: 1ilit Date: Thu, 11 Apr 2024 10:30:42 +0300 Subject: [PATCH] Add warnings to destructive operations --- src/components/EditorHeader/ControlPanel.jsx | 26 +++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/components/EditorHeader/ControlPanel.jsx b/src/components/EditorHeader/ControlPanel.jsx index 79883ae..a27f854 100644 --- a/src/components/EditorHeader/ControlPanel.jsx +++ b/src/components/EditorHeader/ControlPanel.jsx @@ -19,6 +19,7 @@ import { Tooltip, Spin, Toast, + Popconfirm, } from "@douyinfe/semi-ui"; import { toPng, toJpeg, toSvg } from "html-to-image"; import { saveAs } from "file-saver"; @@ -715,6 +716,11 @@ export default function ControlPanel({ }, }, "Delete diagram": { + warning: { + title: "Delete diagram", + message: + "Are you sure you want to delete this diagram? This operation is irreversible.", + }, function: async () => { await db.diagrams .delete(diagramId) @@ -1090,6 +1096,11 @@ export default function ControlPanel({ function: () => setModal(MODAL.TABLE_WIDTH), }, "Flush storage": { + warning: { + title: "Flush storage", + message: + "Are you sure you want to flush the storage? This will irreversibly delete all your diagrams and custom templates.", + }, function: async () => { db.delete() .then(() => { @@ -1399,7 +1410,7 @@ export default function ControlPanel({ {menu[category][item].children.map( @@ -1429,6 +1440,19 @@ export default function ControlPanel({ ); } + if (menu[category][item].warning) { + return ( + + {item} + + ); + } return (