diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/RemoveCollectionFromWorkspace/index.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/RemoveCollectionFromWorkspace/index.js index 94064dfa7..a5dbbf71b 100644 --- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/RemoveCollectionFromWorkspace/index.js +++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/RemoveCollectionFromWorkspace/index.js @@ -4,6 +4,7 @@ import Modal from 'components/Modal'; import { useSelector, useDispatch } from 'react-redux'; import { recursivelyGetAllItemUids } from 'utils/collections'; import { removeCollectionFromWorkspace } from 'providers/ReduxStore/slices/workspaces/actions'; +import { removeLocalCollection } from 'providers/ReduxStore/slices/collections/actions'; import { closeTabs } from 'providers/ReduxStore/slices/tabs'; const RemoveCollectionFromWorkspace = ({onClose, collection}) => { @@ -16,8 +17,9 @@ const RemoveCollectionFromWorkspace = ({onClose, collection}) => { dispatch(closeTabs({ tabUids: recursivelyGetAllItemUids(collection.items) })); - toast.success("Collection removed from workspace"); }) + .then(() => dispatch(removeLocalCollection(collection.uid))) + .then(() => toast.success("Collection removed from workspace")) .catch((err) => console.log(err) && toast.error("An error occured while removing the collection")); }; diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js index c8e599443..3510dbc1a 100644 --- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js +++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js @@ -11,7 +11,7 @@ import NewFolder from 'components/Sidebar/NewFolder'; import CollectionItem from './CollectionItem'; import RemoveCollectionFromWorkspace from './RemoveCollectionFromWorkspace'; import { doesCollectionHaveItemsMatchingSearchText } from 'utils/collections/search'; -import { isItemAFolder, isItemARequest, transformCollectionToSaveToIdb } from 'utils/collections'; +import { isItemAFolder, isItemARequest, transformCollectionToSaveToIdb, isLocalCollection } from 'utils/collections'; import exportCollection from 'utils/collections/export'; import RenameCollection from './RenameCollection'; @@ -67,6 +67,8 @@ const Collection = ({collection, searchText}) => { exportCollection(transformCollectionToSaveToIdb(collectionCopy)); }; + const isLocal = isLocalCollection(collection); + return ( {showNewRequestModal && setShowNewRequestModal(false)}/>} @@ -115,12 +117,14 @@ const Collection = ({collection, searchText}) => { }}> Remove from Workspace -
{ - menuDropdownTippyRef.current.hide(); - setShowDeleteCollectionModal(true); - }}> - Delete -
+ {!isLocal ? ( +
{ + menuDropdownTippyRef.current.hide(); + setShowDeleteCollectionModal(true); + }}> + Delete +
+ ) : null} 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 ca12a75ba..4ce67b054 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js @@ -612,4 +612,19 @@ export const newHttpRequest = (params) => (dispatch, getState) => { .then(() => resolve()) .catch(reject); }); +}; + +export const removeLocalCollection = (collectionUid) => (dispatch, getState) => { + return new Promise((resolve, reject) => { + const state = getState(); + const collection = findCollectionByUid(state.collections.collections, collectionUid); + if(!collection) { + return reject(new Error('Collection not found')); + } + const { ipcRenderer } = window; + ipcRenderer + .invoke('renderer:remove-collection', collection.pathname) + .then(resolve) + .catch(reject); + }); }; \ No newline at end of file diff --git a/packages/bruno-app/src/utils/collections/index.js b/packages/bruno-app/src/utils/collections/index.js index 957246962..249ba72b7 100644 --- a/packages/bruno-app/src/utils/collections/index.js +++ b/packages/bruno-app/src/utils/collections/index.js @@ -338,3 +338,7 @@ export const refreshUidsInItem = (item) => { return item; } + +export const isLocalCollection = (collection) => { + return collection.pathname ? true : false; +}; diff --git a/packages/bruno-electron/src/ipc/local-collection.js b/packages/bruno-electron/src/ipc/local-collection.js index 702c3794d..5a5acdda2 100644 --- a/packages/bruno-electron/src/ipc/local-collection.js +++ b/packages/bruno-electron/src/ipc/local-collection.js @@ -153,6 +153,7 @@ const registerRendererEventHandlers = (mainWindow, watcher) => { ipcMain.handle('renderer:remove-collection', async (event, collectionPath) => { if(watcher && mainWindow) { + console.log(`watcher stopWatching: ${collectionPath}`); watcher.removeWatcher(collectionPath, mainWindow); } });