diff --git a/packages/bruno-app/src/components/RequestTabPanel/FolderNotFound/index.js b/packages/bruno-app/src/components/RequestTabPanel/FolderNotFound/index.js new file mode 100644 index 000000000..eff188890 --- /dev/null +++ b/packages/bruno-app/src/components/RequestTabPanel/FolderNotFound/index.js @@ -0,0 +1,42 @@ +import React, { useEffect, useState, useCallback } from 'react'; +import { closeTabs } from 'providers/ReduxStore/slices/tabs'; +import { useDispatch } from 'react-redux'; + +const FolderNotFound = ({ folderUid }) => { + const dispatch = useDispatch(); + const [showErrorMessage, setShowErrorMessage] = useState(false); + + const closeTab = useCallback(() => { + dispatch( + closeTabs({ + tabUids: [folderUid] + }) + ); + }, [dispatch, folderUid]); + + useEffect(() => { + setTimeout(() => { + setShowErrorMessage(true); + }, 300); + }, []); + + if (!showErrorMessage) { + return null; + } + + return ( +
+
+
Folder no longer exists.
+
+ This can happen when the folder was renamed or deleted on your filesystem. +
+
+ +
+ ); +}; + +export default FolderNotFound; \ No newline at end of file diff --git a/packages/bruno-app/src/components/RequestTabPanel/index.js b/packages/bruno-app/src/components/RequestTabPanel/index.js index 90c6e2f41..5f53a5e02 100644 --- a/packages/bruno-app/src/components/RequestTabPanel/index.js +++ b/packages/bruno-app/src/components/RequestTabPanel/index.js @@ -25,7 +25,7 @@ import { produce } from 'immer'; import CollectionOverview from 'components/CollectionSettings/Overview'; import RequestNotLoaded from './RequestNotLoaded'; import RequestIsLoading from './RequestIsLoading'; -import { closeTabs } from 'providers/ReduxStore/slices/tabs'; +import FolderNotFound from './FolderNotFound'; const MIN_LEFT_PANE_WIDTH = 300; const MIN_RIGHT_PANE_WIDTH = 350; @@ -165,11 +165,7 @@ const RequestTabPanel = () => { if (focusedTab.type === 'folder-settings') { const folder = findItemInCollection(collection, focusedTab.folderUid); if (!folder) { - dispatch( - closeTabs({ - tabUids: [activeTabUid] - }) - ); + return ; } return ; diff --git a/packages/bruno-app/src/components/RequestTabs/RequestTab/index.js b/packages/bruno-app/src/components/RequestTabs/RequestTab/index.js index 072394b7f..182b7ff7e 100644 --- a/packages/bruno-app/src/components/RequestTabs/RequestTab/index.js +++ b/packages/bruno-app/src/components/RequestTabs/RequestTab/index.js @@ -76,7 +76,9 @@ const RequestTab = ({ tab, collection, tabIndex, collectionRequestTabs, folderUi className={`flex items-center justify-between tab-container px-1 ${tab.preview ? "italic" : ""}`} onMouseUp={handleMouseUp} // Add middle-click behavior here > - {tab.type === 'folder-settings' ? ( + {tab.type === 'folder-settings' && !folder ? ( + + ) : tab.type === 'folder-settings' ? ( dispatch(makeTabPermanent({ uid: tab.uid }))} type={tab.type} tabName={folder?.name} /> ) : ( dispatch(makeTabPermanent({ uid: tab.uid }))} type={tab.type} />