diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/CloneCollectionItem/index.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/CloneCollectionItem/index.js index 9e3e9ecd..1d076f89 100644 --- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/CloneCollectionItem/index.js +++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/CloneCollectionItem/index.js @@ -1,4 +1,5 @@ import React, { useRef, useEffect } from 'react'; +import toast from 'react-hot-toast'; import { useFormik } from 'formik'; import * as Yup from 'yup'; import Modal from 'components/Modal'; @@ -19,8 +20,13 @@ const CloneCollectionItem = ({ collection, item, onClose }) => { name: Yup.string().min(1, 'must be atleast 1 characters').max(50, 'must be 50 characters or less').required('name is required') }), onSubmit: (values) => { - dispatch(cloneItem(values.name, item.uid, collection.uid)); - onClose(); + dispatch(cloneItem(values.name, item.uid, collection.uid)) + .then(() => { + onClose(); + }) + .catch((err) => { + toast.error(err ? err.message : 'An error occured while cloning the request') + }); } }); diff --git a/packages/bruno-app/src/components/Sidebar/NewFolder/index.js b/packages/bruno-app/src/components/Sidebar/NewFolder/index.js index 3f1318d1..f72a4df0 100644 --- a/packages/bruno-app/src/components/Sidebar/NewFolder/index.js +++ b/packages/bruno-app/src/components/Sidebar/NewFolder/index.js @@ -32,7 +32,7 @@ const NewFolder = ({ collection, item, onClose }) => { onSubmit: (values) => { dispatch(newFolder(values.folderName, collection.uid, item ? item.uid : null)) .then(() => onClose()) - .catch(() => toast.error('An error occured while adding the request')); + .catch((err) => toast.error(err ? err.message : 'An error occured while adding the request')); } }); diff --git a/packages/bruno-app/src/components/Sidebar/NewRequest/index.js b/packages/bruno-app/src/components/Sidebar/NewRequest/index.js index d1714764..f9b173c9 100644 --- a/packages/bruno-app/src/components/Sidebar/NewRequest/index.js +++ b/packages/bruno-app/src/components/Sidebar/NewRequest/index.js @@ -56,7 +56,7 @@ const NewRequest = ({ collection, item, isEphermal, onClose }) => { ); onClose(); }) - .catch(() => toast.error('An error occured while adding the request')); + .catch((err) => toast.error(err ? err.message : 'An error occured while adding the request')); } else { dispatch( newHttpRequest({ @@ -69,7 +69,7 @@ const NewRequest = ({ collection, item, isEphermal, onClose }) => { }) ) .then(() => onClose()) - .catch(() => toast.error('An error occured while adding the request')); + .catch((err) => toast.error(err ? err.message : 'An error occured while adding the request')); } } }); diff --git a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js index a833a904..71785884 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js @@ -1,6 +1,7 @@ import path from 'path'; import toast from 'react-hot-toast'; import trim from 'lodash/trim'; +import find from 'lodash/find'; import get from 'lodash/get'; import filter from 'lodash/filter'; import { uuid } from 'utils/common'; @@ -192,7 +193,7 @@ export const newFolder = (folderName, collectionUid, itemUid) => (dispatch, getS .then(() => resolve()) .catch((error) => reject(error)); } else { - return reject(new Error('folder with same name already exists')); + return reject(new Error('Duplicate folder names under same parent folder are not allowed')); } } else { const currentItem = findItemInCollection(collection, itemUid); @@ -207,7 +208,7 @@ export const newFolder = (folderName, collectionUid, itemUid) => (dispatch, getS .then(() => resolve()) .catch((error) => reject(error)); } else { - return reject(new Error('folder with same name already exists')); + return reject(new Error('Duplicate folder names under same parent folder are not allowed')); } } else { return reject(new Error('unable to find parent folder')); @@ -285,7 +286,7 @@ export const cloneItem = (newName, itemUid, collectionUid) => (dispatch, getStat .then(resolve) .catch(reject); } else { - return reject(new Error(`${requestName} already exists in collection`)); + return reject(new Error('Duplicate request names are not allowed under the same folder')); } } else { const reqWithSameNameExists = find(parentItem.items, (i) => i.type !== 'folder' && trim(i.filename) === trim(filename)); @@ -302,7 +303,7 @@ export const cloneItem = (newName, itemUid, collectionUid) => (dispatch, getStat .then(resolve) .catch(reject); } else { - return reject(new Error(`${requestName} already exists in the folder`)); + return reject(new Error('Duplicate request names are not allowed under the same folder')); } } }); @@ -544,7 +545,7 @@ export const newHttpRequest = (params) => (dispatch, getState) => { ipcRenderer.invoke('renderer:new-request', fullName, item).then(resolve).catch(reject); } else { - return reject(new Error(`${requestName} already exists in collection`)); + return reject(new Error('Duplicate request names are not allowed under the same folder')); } } else { const currentItem = findItemInCollection(collection, itemUid); @@ -558,7 +559,7 @@ export const newHttpRequest = (params) => (dispatch, getState) => { ipcRenderer.invoke('renderer:new-request', fullName, item).then(resolve).catch(reject); } else { - return reject(new Error(`${requestName} already exists in the folder`)); + return reject(new Error('Duplicate request names are not allowed under the same folder')); } } }