mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-22 16:03:39 +01:00
Merge pull request #1016 from StonyTV/feature/new-run-item-action-in-sidebar
feat(#1017) Added ability to run a single request from sidebar
This commit is contained in:
commit
98ea1aa548
@ -8,6 +8,7 @@ import { useSelector, useDispatch } from 'react-redux';
|
|||||||
import { addTab, focusTab } from 'providers/ReduxStore/slices/tabs';
|
import { addTab, focusTab } from 'providers/ReduxStore/slices/tabs';
|
||||||
import { collectionFolderClicked } from 'providers/ReduxStore/slices/collections';
|
import { collectionFolderClicked } from 'providers/ReduxStore/slices/collections';
|
||||||
import { moveItem } from 'providers/ReduxStore/slices/collections/actions';
|
import { moveItem } from 'providers/ReduxStore/slices/collections/actions';
|
||||||
|
import { sendRequest } from 'providers/ReduxStore/slices/collections/actions';
|
||||||
import Dropdown from 'components/Dropdown';
|
import Dropdown from 'components/Dropdown';
|
||||||
import NewRequest from 'components/Sidebar/NewRequest';
|
import NewRequest from 'components/Sidebar/NewRequest';
|
||||||
import NewFolder from 'components/Sidebar/NewFolder';
|
import NewFolder from 'components/Sidebar/NewFolder';
|
||||||
@ -23,6 +24,7 @@ import { getDefaultRequestPaneTab } from 'utils/collections';
|
|||||||
import { hideHomePage } from 'providers/ReduxStore/slices/app';
|
import { hideHomePage } from 'providers/ReduxStore/slices/app';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import StyledWrapper from './StyledWrapper';
|
import StyledWrapper from './StyledWrapper';
|
||||||
|
import NetworkError from 'components/ResponsePane/NetworkError/index';
|
||||||
|
|
||||||
const CollectionItem = ({ item, collection, searchText }) => {
|
const CollectionItem = ({ item, collection, searchText }) => {
|
||||||
const tabs = useSelector((state) => state.tabs.tabs);
|
const tabs = useSelector((state) => state.tabs.tabs);
|
||||||
@ -95,6 +97,14 @@ const CollectionItem = ({ item, collection, searchText }) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleRun = async () => {
|
||||||
|
dispatch(sendRequest(item, collection.uid)).catch((err) =>
|
||||||
|
toast.custom((t) => <NetworkError onClose={() => toast.dismiss(t.id)} />, {
|
||||||
|
duration: 5000
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const handleClick = (event) => {
|
const handleClick = (event) => {
|
||||||
//scroll to the active tab
|
//scroll to the active tab
|
||||||
setTimeout(scrollToTheActiveTab, 50);
|
setTimeout(scrollToTheActiveTab, 50);
|
||||||
@ -297,15 +307,27 @@ const CollectionItem = ({ item, collection, searchText }) => {
|
|||||||
Rename
|
Rename
|
||||||
</div>
|
</div>
|
||||||
{!isFolder && (
|
{!isFolder && (
|
||||||
<div
|
<>
|
||||||
className="dropdown-item"
|
<div
|
||||||
onClick={(e) => {
|
className="dropdown-item"
|
||||||
dropdownTippyRef.current.hide();
|
onClick={(e) => {
|
||||||
setCloneItemModalOpen(true);
|
dropdownTippyRef.current.hide();
|
||||||
}}
|
setCloneItemModalOpen(true);
|
||||||
>
|
}}
|
||||||
Clone
|
>
|
||||||
</div>
|
Clone
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
className="dropdown-item"
|
||||||
|
onClick={(e) => {
|
||||||
|
dropdownTippyRef.current.hide();
|
||||||
|
handleClick(null);
|
||||||
|
handleRun();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Run
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
{!isFolder && item.type === 'http-request' && (
|
{!isFolder && item.type === 'http-request' && (
|
||||||
<div
|
<div
|
||||||
|
Loading…
Reference in New Issue
Block a user