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 6fd8634297..9097b70dd5 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 @@ -9,6 +9,7 @@ import { addTab, focusTab } from 'providers/ReduxStore/slices/tabs'; import { collectionFolderClicked } from 'providers/ReduxStore/slices/collections'; import { moveItem } from 'providers/ReduxStore/slices/collections/actions'; import { sendRequest } from 'providers/ReduxStore/slices/collections/actions'; +import { shellOpenCollectionPath } from 'providers/ReduxStore/slices/collections/actions'; import Dropdown from 'components/Dropdown'; import NewRequest from 'components/Sidebar/NewRequest'; import NewFolder from 'components/Sidebar/NewFolder'; @@ -105,6 +106,14 @@ const CollectionItem = ({ item, collection, searchText }) => { ); }; + const handleShellRevealItem = () => { + dispatch(shellOpenCollectionPath(item.pathname, false, false)); + }; + + const handleShellEditItem = () => { + dispatch(shellOpenCollectionPath(item.pathname, false, true)); + }; + const handleClick = (event) => { //scroll to the active tab setTimeout(scrollToTheActiveTab, 50); @@ -346,6 +355,26 @@ const CollectionItem = ({ item, collection, searchText }) => { > Delete +
{ + dropdownTippyRef.current.hide(); + handleShellRevealItem(); + }} + > + Open Location +
+ {!isFolder && ( +
{ + dropdownTippyRef.current.hide(); + handleShellEditItem(); + }} + > + Edit +
+ )} 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 1c758f2716..293cf076a0 100644 --- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js +++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/index.js @@ -7,6 +7,7 @@ import { IconChevronRight, IconDots } from '@tabler/icons'; import Dropdown from 'components/Dropdown'; import { collectionClicked } from 'providers/ReduxStore/slices/collections'; import { moveItemToRootOfCollection } from 'providers/ReduxStore/slices/collections/actions'; +import { shellOpenCollectionPath } from 'providers/ReduxStore/slices/collections/actions'; import { useDispatch } from 'react-redux'; import { addTab } from 'providers/ReduxStore/slices/tabs'; import NewRequest from 'components/Sidebar/NewRequest'; @@ -79,6 +80,14 @@ const Collection = ({ collection, searchText }) => { } }; + const handleShellRevealCollection = () => { + dispatch(shellOpenCollectionPath(collection.pathname, true, false)); + }; + + const handleShellEditCollection = () => { + dispatch(shellOpenCollectionPath(collection.pathname, true, true)); + }; + const viewCollectionSettings = () => { dispatch( addTab({ @@ -228,6 +237,24 @@ const Collection = ({ collection, searchText }) => { > Settings +
{ + menuDropdownTippyRef.current.hide(); + handleShellRevealCollection(); + }} + > + Open Location +
+
{ + menuDropdownTippyRef.current.hide(); + handleShellEditCollection(); + }} + > + Edit bruno.json +
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 8143cbc04b..381674dd1b 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js @@ -1046,7 +1046,13 @@ export const collectionAddEnvFileEvent = (payload) => (dispatch, getState) => { export const importCollection = (collection, collectionLocation) => (dispatch, getState) => { return new Promise((resolve, reject) => { const { ipcRenderer } = window; - ipcRenderer.invoke('renderer:import-collection', collection, collectionLocation).then(resolve).catch(reject); }); }; + +export const shellOpenCollectionPath = (itemPath, isCollection, edit) => () => { + return new Promise((resolve, reject) => { + const { ipcRenderer } = window; + ipcRenderer.invoke('renderer:shell-open', itemPath, isCollection, edit).then(resolve).catch(reject); + }); +}; diff --git a/packages/bruno-electron/src/ipc/collection.js b/packages/bruno-electron/src/ipc/collection.js index aed9848493..ff6275dac3 100644 --- a/packages/bruno-electron/src/ipc/collection.js +++ b/packages/bruno-electron/src/ipc/collection.js @@ -560,6 +560,22 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection } }); + ipcMain.handle('renderer:shell-open', async (event, itemPath, isCollection, edit) => { + if (isCollection) { + itemPath = path.join(itemPath, 'bruno.json'); + } + + if (fs.existsSync(itemPath)) { + const isDir = fs.statSync(itemPath).isDirectory(); + + if (edit && !isDir) { + shell.openPath(itemPath); + } else { + shell.showItemInFolder(itemPath); + } + } + }); + ipcMain.handle('renderer:update-bruno-config', async (event, brunoConfig, collectionPath, collectionUid) => { try { const brunoConfigPath = path.join(collectionPath, 'bruno.json');