From d51d11d8b35d306e2323a97807298e8d97a43e4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matheus=20Andr=C3=A9?= <92062874+matheusandre1@users.noreply.github.com> Date: Thu, 5 Feb 2026 01:07:55 -0300 Subject: [PATCH 1/2] feat: Warning on deletion --- package-lock.json | 18 +++++-- src/components/editor/NavigationPanel.tsx | 41 +++++++++++++--- src/components/modals/ConfirmDeleteModal.tsx | 51 ++++++++++++++++++++ test-app/package-lock.json | 13 +++-- 4 files changed, 109 insertions(+), 14 deletions(-) create mode 100644 src/components/modals/ConfirmDeleteModal.tsx diff --git a/package-lock.json b/package-lock.json index c8f7317..08ab06b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -88,6 +88,7 @@ "integrity": "sha512-e7jT4DxYvIDLk1ZHmU/m/mB19rex9sv0c2ftBtjSBv+kVM/902eh0fINUzD7UwLLNR+jU585GxUJ8/EBfAM5fw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@babel/code-frame": "^7.27.1", "@babel/generator": "^7.28.5", @@ -1912,6 +1913,7 @@ "integrity": "sha512-MWtvHrGZLFttgeEj28VXHxpmwYbor/ATPYbBfSFZEIRK0ecCFLl2Qo55z52Hss+UV9CRN7trSeq1zbgx7YDWWg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "csstype": "^3.2.2" } @@ -1932,8 +1934,7 @@ "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==", "dev": true, "license": "MIT", - "optional": true, - "peer": true + "optional": true }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "8.48.1", @@ -1971,6 +1972,7 @@ "integrity": "sha512-PC0PDZfJg8sP7cmKe6L3QIL8GZwU5aRvUFedqSIpw3B+QjRSUZeeITC2M5XKeMXEzL6wccN196iy3JLwKNvDVA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.48.1", "@typescript-eslint/types": "8.48.1", @@ -2338,6 +2340,7 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -2659,6 +2662,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "baseline-browser-mapping": "^2.8.25", "caniuse-lite": "^1.0.30001754", @@ -3017,7 +3021,6 @@ "integrity": "sha512-WhL/YuveyGXJaerVlMYGWhvQswa7myDG17P7Vu65EWC05o8vfeNbvNf4d/BOvH99+ZW+LlQsc1GDKMa1vNK6dw==", "dev": true, "license": "(MPL-2.0 OR Apache-2.0)", - "peer": true, "optionalDependencies": { "@types/trusted-types": "^2.0.7" } @@ -3305,6 +3308,7 @@ "integrity": "sha512-BhHmn2yNOFA9H9JmmIVKJmd288g9hrVRDkdoIgRCRuSySRUHH7r/DI6aAXW9T1WwUuY3DFgrcaqB+deURBLR5g==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -4862,7 +4866,6 @@ "integrity": "sha512-uIj4+faQ+MgHgwUW1l2PsPglZLOLOT1uErt06dAPtx2kjteLAkbsd/0FiYg/MGS+i7ZKLb7w2WClxHkzOOuryQ==", "dev": true, "license": "MIT", - "peer": true, "bin": { "marked": "bin/marked.js" }, @@ -5274,6 +5277,7 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=12" }, @@ -5387,6 +5391,7 @@ "integrity": "sha512-tmbWg6W31tQLeB5cdIBOicJDJRR2KzXsV7uSK9iNfLWQ5bIZfxuPEHp7M8wiHyHnn0DD1i7w3Zmin0FtkrwoCQ==", "dev": true, "license": "MIT", + "peer": true, "engines": { "node": ">=0.10.0" } @@ -5397,6 +5402,7 @@ "integrity": "sha512-UlbRu4cAiGaIewkPyiRGJk0imDN2T3JjieT6spoL2UeSf5od4n5LB/mQ4ejmxhCFT1tYe8IvaFulzynWovsEFQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "scheduler": "^0.27.0" }, @@ -6145,6 +6151,7 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -6260,6 +6267,7 @@ "integrity": "sha512-tI2l/nFHC5rLh7+5+o7QjKjSR04ivXDF4jcgV0f/bTQ+OJiITy5S6gaynVsEM+7RqzufMnVbIon6Sr5x1SDYaQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.5.0", @@ -6491,6 +6499,7 @@ "integrity": "sha512-mplynKqc1C2hTVYxd0PU2xQAc22TI1vShAYGksCCfxbn/dFwnHTNi1bvYsBTkhdUNtGIf5xNOg938rrSSYvS9A==", "dev": true, "license": "ISC", + "peer": true, "bin": { "yaml": "bin.mjs" }, @@ -6520,6 +6529,7 @@ "integrity": "sha512-AvvthqfqrAhNH9dnfmrfKzX5upOdjUVJYFqNSlkmGf64gRaTzlPwz99IHYnVs28qYAybvAlBV+H7pn0saFY4Ig==", "dev": true, "license": "MIT", + "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" } diff --git a/src/components/editor/NavigationPanel.tsx b/src/components/editor/NavigationPanel.tsx index c14fa5a..47ac24a 100644 --- a/src/components/editor/NavigationPanel.tsx +++ b/src/components/editor/NavigationPanel.tsx @@ -23,6 +23,7 @@ import { } from '@apicurio/data-models'; import { CreatePathModal } from '@components/modals/CreatePathModal'; import { CreateSchemaModal } from '@components/modals/CreateSchemaModal'; +import { ConfirmDeleteModal } from '@components/modals/ConfirmDeleteModal'; import { CreatePathCommand } from '@commands/CreatePathCommand'; import { CreateSchemaCommand } from '@commands/CreateSchemaCommand'; import { DeletePathCommand } from '@commands/DeletePathCommand'; @@ -40,6 +41,8 @@ export const NavigationPanel: React.FC = () => { const { executeCommand } = useCommand(); const [isCreatePathModalOpen, setIsCreatePathModalOpen] = useState(false); const [isCreateSchemaModalOpen, setIsCreateSchemaModalOpen] = useState(false); + const [isDeleteConfirmModalOpen, setIsDeleteConfirmModalOpen] = useState(false); + const [deleteInfo, setDeleteInfo] = useState<{ name: string; type: 'path' | 'schema' }>({ name: '', type: 'path' }); const [filterText, setFilterText] = useState(''); /** @@ -175,17 +178,29 @@ export const NavigationPanel: React.FC = () => { * Handle deleting a path from context menu */ const handleDeletePath = (pathName: string) => { - const command = new DeletePathCommand(pathName); - executeCommand(command, `Delete path ${pathName}`); - selectRoot(); + setDeleteInfo({ name: pathName, type: 'path' }); + setIsDeleteConfirmModalOpen(true); }; /** * Handle deleting a schema from context menu */ const handleDeleteSchema = (schemaName: string) => { - const command = new DeleteSchemaCommand(schemaName); - executeCommand(command, `Delete schema ${schemaName}`); + setDeleteInfo({ name: schemaName, type: 'schema' }); + setIsDeleteConfirmModalOpen(true); + }; + + /** + * Confirm deletion of path or schema + */ + const handleConfirmDelete = () => { + if (deleteInfo.type === 'path') { + const command = new DeletePathCommand(deleteInfo.name); + executeCommand(command, `Delete path ${deleteInfo.name}`); + } else { + const command = new DeleteSchemaCommand(deleteInfo.name); + executeCommand(command, `Delete schema ${deleteInfo.name}`); + } selectRoot(); }; @@ -211,7 +226,7 @@ export const NavigationPanel: React.FC = () => { return ( <> -