From 0a913c8f912bb2a64d040d8306c7cfe3ada2c7fd Mon Sep 17 00:00:00 2001 From: Ashmit Jagtap Date: Tue, 27 Feb 2024 21:45:09 +0530 Subject: [PATCH] Feat: Added confirmation to create new file (#977) Co-authored-by: samz --- .../components/Modals/ConfirmNewFileModal.tsx | 31 +++++++++++++++++++ apps/studio/src/components/Modals/index.tsx | 1 + apps/studio/src/components/Sidebar.tsx | 4 +-- 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 apps/studio/src/components/Modals/ConfirmNewFileModal.tsx diff --git a/apps/studio/src/components/Modals/ConfirmNewFileModal.tsx b/apps/studio/src/components/Modals/ConfirmNewFileModal.tsx new file mode 100644 index 000000000..2263632d3 --- /dev/null +++ b/apps/studio/src/components/Modals/ConfirmNewFileModal.tsx @@ -0,0 +1,31 @@ +import { create } from '@ebay/nice-modal-react'; +import { NewFileModal } from './NewFileModal'; +import { ConfirmModal } from './ConfirmModal'; +import { show as showModal } from '@ebay/nice-modal-react'; + +export const ConfirmNewFileModal = create(() => { + const onConfirm = () => { + showModal(NewFileModal) + }; + + return ( + +
+
+
+ Would you like to create a new file? +

+ All the existing changes will be lost and overwritten. +

+
+
+
+
+ ); +}); diff --git a/apps/studio/src/components/Modals/index.tsx b/apps/studio/src/components/Modals/index.tsx index 97154ba7f..b89162281 100644 --- a/apps/studio/src/components/Modals/index.tsx +++ b/apps/studio/src/components/Modals/index.tsx @@ -8,3 +8,4 @@ export * from './ImportBase64Modal'; export * from './ImportURLModal'; export * from './NewFileModal'; export * from './RedirectedModal'; +export * from './ConfirmNewFileModal'; \ No newline at end of file diff --git a/apps/studio/src/components/Sidebar.tsx b/apps/studio/src/components/Sidebar.tsx index 6e8e9c7a7..2d6f32065 100644 --- a/apps/studio/src/components/Sidebar.tsx +++ b/apps/studio/src/components/Sidebar.tsx @@ -2,7 +2,7 @@ import { VscListSelection, VscCode, VscOpenPreview, VscGraph, VscNewFile, VscSet import { show as showModal } from '@ebay/nice-modal-react'; import { Tooltip } from './common'; -import { SettingsModal, NewFileModal } from './Modals'; +import { SettingsModal, ConfirmNewFileModal } from './Modals'; import { usePanelsState, panelsState, useDocumentsState } from '../state'; @@ -105,7 +105,7 @@ export const Sidebar: FunctionComponent = () => { name: 'newFile', title: 'New file', isActive: false, - onClick: () => showModal(NewFileModal), + onClick: () => showModal(ConfirmNewFileModal), icon: , tooltip: 'New file', enabled: true