Skip to content

Commit

Permalink
Feat: Added confirmation to create new file (#977)
Browse files Browse the repository at this point in the history
Co-authored-by: samz <[email protected]>
  • Loading branch information
ashmit-coder and Amzani authored Feb 27, 2024
1 parent 25db427 commit 0a913c8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
31 changes: 31 additions & 0 deletions apps/studio/src/components/Modals/ConfirmNewFileModal.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<ConfirmModal
containerClassName="sm:max-w-6xl"
title="Confirm New File"
confirmText="Create New File"
confirmDisabled={false}
onSubmit={onConfirm}
>
<div className="flex content-center justify-center flex-col">
<div className="w-full overflow-auto">
<div>
Would you like to create a new file?
<p>
<b className='text-pink-500'>All the existing changes will be lost and overwritten.</b>
</p>
</div>
</div>
</div>
</ConfirmModal>
);
});
1 change: 1 addition & 0 deletions apps/studio/src/components/Modals/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from './ImportBase64Modal';
export * from './ImportURLModal';
export * from './NewFileModal';
export * from './RedirectedModal';
export * from './ConfirmNewFileModal';
4 changes: 2 additions & 2 deletions apps/studio/src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -105,7 +105,7 @@ export const Sidebar: FunctionComponent<SidebarProps> = () => {
name: 'newFile',
title: 'New file',
isActive: false,
onClick: () => showModal(NewFileModal),
onClick: () => showModal(ConfirmNewFileModal),
icon: <VscNewFile className="w-5 h-5" />,
tooltip: 'New file',
enabled: true
Expand Down

0 comments on commit 0a913c8

Please sign in to comment.