From b181aba646bae6a72b6d245dbb6099be2626d9fd Mon Sep 17 00:00:00 2001 From: Pragadesh-45 <54320162+Pragadesh-45@users.noreply.github.com> Date: Sun, 15 Dec 2024 16:44:32 +0530 Subject: [PATCH] feat: enhance collection item deletion and renaming functionality (#3607) --- .../CollectionItem/DeleteCollectionItem/index.js | 7 ++++++- .../CollectionItem/RenameCollectionItem/index.js | 4 +++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/DeleteCollectionItem/index.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/DeleteCollectionItem/index.js index 59f19dcb2..2646bf676 100644 --- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/DeleteCollectionItem/index.js +++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/DeleteCollectionItem/index.js @@ -12,10 +12,15 @@ const DeleteCollectionItem = ({ onClose, item, collection }) => { const isFolder = isItemAFolder(item); const onConfirm = () => { dispatch(deleteItem(item.uid, collection.uid)).then(() => { + if (isFolder) { + // close all tabs that belong to the folder + // including the folder itself and its children + const tabUids = [...recursivelyGetAllItemUids(item.items), item.uid] + dispatch( closeTabs({ - tabUids: recursivelyGetAllItemUids(item.items) + tabUids: tabUids }) ); } else { diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/RenameCollectionItem/index.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/RenameCollectionItem/index.js index 6cf8cb21a..c9ce0b95f 100644 --- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/RenameCollectionItem/index.js +++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/RenameCollectionItem/index.js @@ -6,6 +6,7 @@ import { useDispatch } from 'react-redux'; import { isItemAFolder } from 'utils/tabs'; import { renameItem, saveRequest } from 'providers/ReduxStore/slices/collections/actions'; import toast from 'react-hot-toast'; +import { closeTabs } from 'providers/ReduxStore/slices/tabs'; const RenameCollectionItem = ({ collection, item, onClose }) => { const dispatch = useDispatch(); @@ -33,7 +34,8 @@ const RenameCollectionItem = ({ collection, item, onClose }) => { } dispatch(renameItem(values.name, item.uid, collection.uid)) .then(() => { - toast.success('Request renamed'); + dispatch(closeTabs({ tabUids: [item.uid] })); + toast.success(isFolder ? 'Folder renamed' : 'Request renamed'); onClose(); }) .catch((err) => {