diff --git a/packages/bruno-app/src/components/CollectionSettings/Overview/RequestsNotLoaded/index.js b/packages/bruno-app/src/components/CollectionSettings/Overview/RequestsNotLoaded/index.js index d498ca451..db1b5eb01 100644 --- a/packages/bruno-app/src/components/CollectionSettings/Overview/RequestsNotLoaded/index.js +++ b/packages/bruno-app/src/components/CollectionSettings/Overview/RequestsNotLoaded/index.js @@ -6,7 +6,6 @@ import { useDispatch, useSelector } from 'react-redux'; import { isItemARequest, itemIsOpenedInTabs } from 'utils/tabs/index'; import { getDefaultRequestPaneTab } from 'utils/collections/index'; import { addTab, focusTab } from 'providers/ReduxStore/slices/tabs'; -import { hideHomePage } from 'providers/ReduxStore/slices/app'; const RequestsNotLoaded = ({ collection }) => { const dispatch = useDispatch(); @@ -21,7 +20,6 @@ const RequestsNotLoaded = ({ collection }) => { const handleRequestClick = (item) => (e) => { e.preventDefault(); if (isItemARequest(item)) { - dispatch(hideHomePage()); if (itemIsOpenedInTabs(item, tabs)) { dispatch( focusTab({ diff --git a/packages/bruno-app/src/components/GlobalSearchModal/index.js b/packages/bruno-app/src/components/GlobalSearchModal/index.js index fd1b476b7..e2a168beb 100644 --- a/packages/bruno-app/src/components/GlobalSearchModal/index.js +++ b/packages/bruno-app/src/components/GlobalSearchModal/index.js @@ -10,7 +10,6 @@ import { } from '@tabler/icons'; import { flattenItems, isItemARequest, isItemAFolder, findParentItemInCollection } from 'utils/collections'; import { addTab, focusTab } from 'providers/ReduxStore/slices/tabs'; -import { hideHomePage } from 'providers/ReduxStore/slices/app'; import { toggleCollectionItem, toggleCollection } from 'providers/ReduxStore/slices/collections'; import { mountCollection } from 'providers/ReduxStore/slices/collections/actions'; import { getDefaultRequestPaneTab } from 'utils/collections'; @@ -246,8 +245,6 @@ const GlobalSearchModal = ({ isOpen, onClose }) => { expandItemPath(result); if (result.type === SEARCH_TYPES.REQUEST) { - dispatch(hideHomePage()); - const existingTab = tabs.find((tab) => tab.uid === result.item.uid); if (existingTab) { diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js index eb0879b5b..90272636c 100644 --- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js +++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/index.js @@ -37,7 +37,6 @@ import GenerateCodeItem from './GenerateCodeItem'; import { isItemARequest, isItemAFolder } from 'utils/tabs'; import { doesRequestMatchSearchText, doesFolderHaveItemsMatchSearchText } from 'utils/collections/search'; import { getDefaultRequestPaneTab } from 'utils/collections'; -import { hideHomePage, hideApiSpecPage } from 'providers/ReduxStore/slices/app'; import toast from 'react-hot-toast'; import StyledWrapper from './StyledWrapper'; import NetworkError from 'components/ResponsePane/NetworkError/index'; @@ -214,8 +213,6 @@ const CollectionItem = ({ item, collectionUid, collectionPathname, searchText }) setTimeout(scrollToTheActiveTab, 50); const isRequest = isItemARequest(item); if (isRequest) { - dispatch(hideHomePage()); - dispatch(hideApiSpecPage()); if (isTabForItemPresent) { dispatch( focusTab({ @@ -233,8 +230,6 @@ const CollectionItem = ({ item, collectionUid, collectionPathname, searchText }) }) ); } else { - dispatch(hideHomePage()); - dispatch(hideApiSpecPage()); dispatch( addTab({ uid: item.uid, 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 5a9f4eac3..b9ecb1210 100644 --- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js +++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js @@ -24,7 +24,6 @@ import { import { toggleCollection, collapseFullCollection } from 'providers/ReduxStore/slices/collections'; import { mountCollection, moveCollectionAndPersist, handleCollectionItemDrop, pasteItem, showInFolder, saveCollectionSecurityConfig } from 'providers/ReduxStore/slices/collections/actions'; import { useDispatch, useSelector } from 'react-redux'; -import { hideApiSpecPage, hideHomePage } from 'providers/ReduxStore/slices/app'; import { addTab, makeTabPermanent } from 'providers/ReduxStore/slices/tabs'; import toast from 'react-hot-toast'; import NewRequest from 'components/Sidebar/NewRequest'; @@ -111,8 +110,6 @@ const Collection = ({ collection, searchText }) => { } if (!isChevronClick) { - dispatch(hideHomePage()); // @TODO Playwright tests are often stuck on home page, rather than collection settings tab. Revisit for a proper fix. - dispatch(hideApiSpecPage()); dispatch( addTab({ uid: collection.uid, diff --git a/packages/bruno-app/src/components/WorkspaceHome/WorkspaceOverview/CollectionsList/index.js b/packages/bruno-app/src/components/WorkspaceHome/WorkspaceOverview/CollectionsList/index.js index 0d228df93..160f9ed68 100644 --- a/packages/bruno-app/src/components/WorkspaceHome/WorkspaceOverview/CollectionsList/index.js +++ b/packages/bruno-app/src/components/WorkspaceHome/WorkspaceOverview/CollectionsList/index.js @@ -3,7 +3,6 @@ import { useSelector, useDispatch } from 'react-redux'; import { IconBox, IconTrash, IconEdit, IconShare, IconDots } from '@tabler/icons'; import { removeCollectionFromWorkspaceAction } from 'providers/ReduxStore/slices/workspaces/actions'; import { addTab } from 'providers/ReduxStore/slices/tabs'; -import { hideHomePage } from 'providers/ReduxStore/slices/app'; import { mountCollection } from 'providers/ReduxStore/slices/collections/actions'; import { normalizePath } from 'utils/common/path'; import toast from 'react-hot-toast'; @@ -117,8 +116,6 @@ const CollectionsList = ({ workspace }) => { }) ); - dispatch(hideHomePage()); - dispatch( addTab({ uid: collection.uid, diff --git a/packages/bruno-app/src/providers/ReduxStore/middlewares/tasks/middleware.js b/packages/bruno-app/src/providers/ReduxStore/middlewares/tasks/middleware.js index eef8e3160..e9830b589 100644 --- a/packages/bruno-app/src/providers/ReduxStore/middlewares/tasks/middleware.js +++ b/packages/bruno-app/src/providers/ReduxStore/middlewares/tasks/middleware.js @@ -2,7 +2,7 @@ import get from 'lodash/get'; import each from 'lodash/each'; import filter from 'lodash/filter'; import { createListenerMiddleware } from '@reduxjs/toolkit'; -import { removeTaskFromQueue, hideHomePage } from 'providers/ReduxStore/slices/app'; +import { removeTaskFromQueue } from 'providers/ReduxStore/slices/app'; import { addTab } from 'providers/ReduxStore/slices/tabs'; import { collectionAddFileEvent, collectionChangeFileEvent } from 'providers/ReduxStore/slices/collections'; import { findCollectionByUid, findItemInCollectionByPathname, getDefaultRequestPaneTab, findItemInCollectionByItemUid } from 'utils/collections/index'; @@ -37,7 +37,6 @@ taskMiddleware.startListening({ requestPaneTab: getDefaultRequestPaneTab(item) }) ); - listenerApi.dispatch(hideHomePage()); } } @@ -80,7 +79,6 @@ taskMiddleware.startListening({ type: 'response-example', itemUid: item.uid })); - listenerApi.dispatch(hideHomePage()); } } } diff --git a/packages/bruno-app/src/providers/ReduxStore/slices/app.js b/packages/bruno-app/src/providers/ReduxStore/slices/app.js index f43e27a00..ff7115565 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/app.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/app.js @@ -1,6 +1,7 @@ import { createSlice } from '@reduxjs/toolkit'; import filter from 'lodash/filter'; import brunoClipboard from 'utils/bruno-clipboard'; +import { addTab, focusTab } from './tabs'; const initialState = { isDragging: false, @@ -127,6 +128,20 @@ export const appSlice = createSlice({ // Update clipboard UI state state.clipboard.hasCopiedItems = action.payload.hasCopiedItems; } + }, + extraReducers: (builder) => { + // Automatically hide special pages when any tab is added or focused + builder + .addCase(addTab, (state) => { + state.showHomePage = false; + state.showApiSpecPage = false; + state.showManageWorkspacePage = false; + }) + .addCase(focusTab, (state) => { + state.showHomePage = false; + state.showApiSpecPage = false; + state.showManageWorkspacePage = false; + }); } });