Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Added confirmation to create new file #977

Merged
merged 4 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading