mirror of
https://github.com/usebruno/bruno.git
synced 2025-01-03 04:29:09 +01:00
feat: enhance collection item deletion and renaming functionality (#3607)
This commit is contained in:
parent
47179535d5
commit
b181aba646
@ -12,10 +12,15 @@ const DeleteCollectionItem = ({ onClose, item, collection }) => {
|
|||||||
const isFolder = isItemAFolder(item);
|
const isFolder = isItemAFolder(item);
|
||||||
const onConfirm = () => {
|
const onConfirm = () => {
|
||||||
dispatch(deleteItem(item.uid, collection.uid)).then(() => {
|
dispatch(deleteItem(item.uid, collection.uid)).then(() => {
|
||||||
|
|
||||||
if (isFolder) {
|
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(
|
dispatch(
|
||||||
closeTabs({
|
closeTabs({
|
||||||
tabUids: recursivelyGetAllItemUids(item.items)
|
tabUids: tabUids
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -6,6 +6,7 @@ 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';
|
import toast from 'react-hot-toast';
|
||||||
|
import { closeTabs } from 'providers/ReduxStore/slices/tabs';
|
||||||
|
|
||||||
const RenameCollectionItem = ({ collection, item, onClose }) => {
|
const RenameCollectionItem = ({ collection, item, onClose }) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
@ -33,7 +34,8 @@ const RenameCollectionItem = ({ collection, item, onClose }) => {
|
|||||||
}
|
}
|
||||||
dispatch(renameItem(values.name, item.uid, collection.uid))
|
dispatch(renameItem(values.name, item.uid, collection.uid))
|
||||||
.then(() => {
|
.then(() => {
|
||||||
toast.success('Request renamed');
|
dispatch(closeTabs({ tabUids: [item.uid] }));
|
||||||
|
toast.success(isFolder ? 'Folder renamed' : 'Request renamed');
|
||||||
onClose();
|
onClose();
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user