fix: updates (#3158)

This commit is contained in:
lohit 2024-09-21 19:49:50 +05:30 committed by GitHub
parent 6c6693757e
commit fc79436787
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 47 additions and 24 deletions

View File

@ -44,7 +44,7 @@ const CopyEnvironment = ({ collection, environment, onClose }) => {
return ( return (
<Portal> <Portal>
<Modal size="sm" title={'Copy Environment'} confirmText="Copy" handleConfirm={onSubmit} handleCancel={onClose}> <Modal size="sm" title={'Copy Environment'} confirmText="Copy" handleConfirm={onSubmit} handleCancel={onClose}>
<form className="bruno-form" onSubmit={formik.handleSubmit}> <form className="bruno-form" onSubmit={e => e.preventDefault()}>
<div> <div>
<label htmlFor="name" className="block font-semibold"> <label htmlFor="name" className="block font-semibold">
New Environment Name New Environment Name

View File

@ -50,7 +50,7 @@ const CreateEnvironment = ({ collection, onClose }) => {
handleConfirm={onSubmit} handleConfirm={onSubmit}
handleCancel={onClose} handleCancel={onClose}
> >
<form className="bruno-form" onSubmit={formik.handleSubmit}> <form className="bruno-form" onSubmit={e => e.preventDefault()}>
<div> <div>
<label htmlFor="name" className="block font-semibold"> <label htmlFor="name" className="block font-semibold">
Environment Name Environment Name

View File

@ -50,7 +50,7 @@ const RenameEnvironment = ({ onClose, environment, collection }) => {
handleConfirm={onSubmit} handleConfirm={onSubmit}
handleCancel={onClose} handleCancel={onClose}
> >
<form className="bruno-form" onSubmit={formik.handleSubmit}> <form className="bruno-form" onSubmit={e => e.preventDefault()}>
<div> <div>
<label htmlFor="name" className="block font-semibold"> <label htmlFor="name" className="block font-semibold">
Environment Name Environment Name

View File

@ -76,13 +76,15 @@ const Modal = ({
const modalRef = useRef(null); const modalRef = useRef(null);
const [isClosing, setIsClosing] = useState(false); const [isClosing, setIsClosing] = useState(false);
const handleKeydown = ({ keyCode }) => { const handleKeydown = (event) => {
const { keyCode, shiftKey, ctrlKey, altKey, metaKey } = event;
switch (keyCode) { switch (keyCode) {
case ESC_KEY_CODE: { case ESC_KEY_CODE: {
if (disableEscapeKey) return;
return closeModal({ type: 'esc' }); return closeModal({ type: 'esc' });
} }
case ENTER_KEY_CODE: { case ENTER_KEY_CODE: {
if(handleConfirm) { if (!shiftKey && !ctrlKey && !altKey && !metaKey && handleConfirm) {
return handleConfirm(); return handleConfirm();
} }
} }
@ -97,7 +99,6 @@ const Modal = ({
}; };
useEffect(() => { useEffect(() => {
if (disableEscapeKey) return;
document.addEventListener('keydown', handleKeydown, false); document.addEventListener('keydown', handleKeydown, false);
return () => { return () => {
document.removeEventListener('keydown', handleKeydown); document.removeEventListener('keydown', handleKeydown);

View File

@ -41,7 +41,7 @@ const CloneCollection = ({ onClose, collection }) => {
) )
) )
.then(() => { .then(() => {
toast.success('Collection created'); toast.success('Collection created!');
onClose(); onClose();
}) })
.catch((e) => toast.error('An error occurred while creating the collection - ' + e)); .catch((e) => toast.error('An error occurred while creating the collection - ' + e));
@ -72,7 +72,7 @@ const CloneCollection = ({ onClose, collection }) => {
return ( return (
<Modal size="sm" title="Clone Collection" confirmText="Create" handleConfirm={onSubmit} handleCancel={onClose}> <Modal size="sm" title="Clone Collection" confirmText="Create" handleConfirm={onSubmit} handleCancel={onClose}>
<form className="bruno-form" onSubmit={formik.handleSubmit}> <form className="bruno-form" onSubmit={e => e.preventDefault()}>
<div> <div>
<label htmlFor="collection-name" className="flex items-center font-semibold"> <label htmlFor="collection-name" className="flex items-center font-semibold">
Name Name

View File

@ -25,6 +25,7 @@ const CloneCollectionItem = ({ collection, item, onClose }) => {
onSubmit: (values) => { onSubmit: (values) => {
dispatch(cloneItem(values.name, item.uid, collection.uid)) dispatch(cloneItem(values.name, item.uid, collection.uid))
.then(() => { .then(() => {
toast.success('Request cloned!');
onClose(); onClose();
}) })
.catch((err) => { .catch((err) => {
@ -49,7 +50,7 @@ const CloneCollectionItem = ({ collection, item, onClose }) => {
handleConfirm={onSubmit} handleConfirm={onSubmit}
handleCancel={onClose} handleCancel={onClose}
> >
<form className="bruno-form" onSubmit={formik.handleSubmit}> <form className="bruno-form" onSubmit={e => e.preventDefault()}>
<div> <div>
<label htmlFor="name" className="block font-semibold"> <label htmlFor="name" className="block font-semibold">
{isFolder ? 'Folder' : 'Request'} Name {isFolder ? 'Folder' : 'Request'} Name

View File

@ -5,6 +5,7 @@ import Modal from 'components/Modal';
import { useDispatch } from 'react-redux'; import { useDispatch } from 'react-redux';
import { isItemAFolder } from 'utils/tabs'; import { isItemAFolder } from 'utils/tabs';
import { renameItem, saveRequest } from 'providers/ReduxStore/slices/collections/actions'; import { renameItem, saveRequest } from 'providers/ReduxStore/slices/collections/actions';
import toast from 'react-hot-toast';
const RenameCollectionItem = ({ collection, item, onClose }) => { const RenameCollectionItem = ({ collection, item, onClose }) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
@ -27,8 +28,14 @@ const RenameCollectionItem = ({ collection, item, onClose }) => {
if (!isFolder && item.draft) { if (!isFolder && item.draft) {
await dispatch(saveRequest(item.uid, collection.uid, true)); await dispatch(saveRequest(item.uid, collection.uid, true));
} }
dispatch(renameItem(values.name, item.uid, collection.uid)); dispatch(renameItem(values.name, item.uid, collection.uid))
.then(() => {
toast.success('Request renamed!');
onClose(); onClose();
})
.catch((err) => {
toast.error(err ? err.message : 'An error occurred while renaming the request');
});
} }
}); });
@ -48,7 +55,7 @@ const RenameCollectionItem = ({ collection, item, onClose }) => {
handleConfirm={onSubmit} handleConfirm={onSubmit}
handleCancel={onClose} handleCancel={onClose}
> >
<form className="bruno-form" onSubmit={formik.handleSubmit}> <form className="bruno-form" onSubmit={e => e.preventDefault()}>
<div> <div>
<label htmlFor="name" className="block font-semibold"> <label htmlFor="name" className="block font-semibold">
{isFolder ? 'Folder' : 'Request'} Name {isFolder ? 'Folder' : 'Request'} Name

View File

@ -21,9 +21,14 @@ const RenameCollection = ({ collection, onClose }) => {
.required('name is required') .required('name is required')
}), }),
onSubmit: (values) => { onSubmit: (values) => {
dispatch(renameCollection(values.name, collection.uid)); dispatch(renameCollection(values.name, collection.uid))
.then(() => {
toast.success('Collection renamed!'); toast.success('Collection renamed!');
onClose(); onClose();
})
.catch((err) => {
toast.error(err ? err.message : 'An error occurred while renaming the collection');
});
} }
}); });
@ -37,7 +42,7 @@ const RenameCollection = ({ collection, onClose }) => {
return ( return (
<Modal size="sm" title="Rename Collection" confirmText="Rename" handleConfirm={onSubmit} handleCancel={onClose}> <Modal size="sm" title="Rename Collection" confirmText="Rename" handleConfirm={onSubmit} handleCancel={onClose}>
<form className="bruno-form" onSubmit={formik.handleSubmit}> <form className="bruno-form" onSubmit={e => e.preventDefault()}>
<div> <div>
<label htmlFor="name" className="block font-semibold"> <label htmlFor="name" className="block font-semibold">
Name Name

View File

@ -34,7 +34,7 @@ const CreateCollection = ({ onClose }) => {
onSubmit: (values) => { onSubmit: (values) => {
dispatch(createCollection(values.collectionName, values.collectionFolderName, values.collectionLocation)) dispatch(createCollection(values.collectionName, values.collectionFolderName, values.collectionLocation))
.then(() => { .then(() => {
toast.success('Collection created'); toast.success('Collection created!');
onClose(); onClose();
}) })
.catch((e) => toast.error('An error occurred while creating the collection - ' + e)); .catch((e) => toast.error('An error occurred while creating the collection - ' + e));
@ -65,7 +65,7 @@ const CreateCollection = ({ onClose }) => {
return ( return (
<Modal size="sm" title="Create Collection" confirmText="Create" handleConfirm={onSubmit} handleCancel={onClose}> <Modal size="sm" title="Create Collection" confirmText="Create" handleConfirm={onSubmit} handleCancel={onClose}>
<form className="bruno-form" onSubmit={formik.handleSubmit}> <form className="bruno-form" onSubmit={e => e.preventDefault()}>
<div> <div>
<label htmlFor="collection-name" className="flex items-center font-semibold"> <label htmlFor="collection-name" className="flex items-center font-semibold">
Name Name

View File

@ -144,7 +144,7 @@ const ImportCollectionLocation = ({ onClose, handleSubmit, collectionName, trans
return ( return (
<Modal size="sm" title="Import Collection" confirmText="Import" handleConfirm={onSubmit} handleCancel={onClose}> <Modal size="sm" title="Import Collection" confirmText="Import" handleConfirm={onSubmit} handleCancel={onClose}>
<form className="bruno-form" onSubmit={formik.handleSubmit}> <form className="bruno-form" onSubmit={e => e.preventDefault()}>
<div> <div>
<label htmlFor="collectionName" className="block font-semibold"> <label htmlFor="collectionName" className="block font-semibold">
Name Name

View File

@ -32,7 +32,10 @@ const NewFolder = ({ collection, item, onClose }) => {
}), }),
onSubmit: (values) => { onSubmit: (values) => {
dispatch(newFolder(values.folderName, collection.uid, item ? item.uid : null)) dispatch(newFolder(values.folderName, collection.uid, item ? item.uid : null))
.then(() => onClose()) .then(() => {
toast.success('New folder created!');
onClose()
})
.catch((err) => toast.error(err ? err.message : 'An error occurred while adding the folder')); .catch((err) => toast.error(err ? err.message : 'An error occurred while adding the folder'));
} }
}); });
@ -47,7 +50,7 @@ const NewFolder = ({ collection, item, onClose }) => {
return ( return (
<Modal size="sm" title="New Folder" confirmText="Create" handleConfirm={onSubmit} handleCancel={onClose}> <Modal size="sm" title="New Folder" confirmText="Create" handleConfirm={onSubmit} handleCancel={onClose}>
<form className="bruno-form" onSubmit={formik.handleSubmit}> <form className="bruno-form" onSubmit={e => e.preventDefault()}>
<div> <div>
<label htmlFor="folderName" className="block font-semibold"> <label htmlFor="folderName" className="block font-semibold">
Folder Name Folder Name

View File

@ -113,7 +113,10 @@ const NewRequest = ({ collection, item, isEphemeral, onClose }) => {
auth: request.auth auth: request.auth
}) })
) )
.then(() => onClose()) .then(() => {
toast.success('New request created!');
onClose()
})
.catch((err) => toast.error(err ? err.message : 'An error occurred while adding the request')); .catch((err) => toast.error(err ? err.message : 'An error occurred while adding the request'));
} else { } else {
dispatch( dispatch(
@ -126,7 +129,10 @@ const NewRequest = ({ collection, item, isEphemeral, onClose }) => {
itemUid: item ? item.uid : null itemUid: item ? item.uid : null
}) })
) )
.then(() => onClose()) .then(() => {
toast.success('New request created!');
onClose()
})
.catch((err) => toast.error(err ? err.message : 'An error occurred while adding the request')); .catch((err) => toast.error(err ? err.message : 'An error occurred while adding the request'));
} }
} }
@ -162,7 +168,7 @@ const NewRequest = ({ collection, item, isEphemeral, onClose }) => {
return ( return (
<StyledWrapper> <StyledWrapper>
<Modal size="md" title="New Request" confirmText="Create" handleConfirm={onSubmit} handleCancel={onClose}> <Modal size="md" title="New Request" confirmText="Create" handleConfirm={onSubmit} handleCancel={onClose}>
<form className="bruno-form" onSubmit={formik.handleSubmit}> <form className="bruno-form" onSubmit={e => e.preventDefault()}>
<div> <div>
<label htmlFor="requestName" className="block font-semibold"> <label htmlFor="requestName" className="block font-semibold">
Type Type