Skip to content

Commit

Permalink
Merge pull request #1016 from StonyTV/feature/new-run-item-action-in-…
Browse files Browse the repository at this point in the history
…sidebar

feat(#1017) Added ability to run a single request from sidebar
  • Loading branch information
helloanoop authored Nov 22, 2023
2 parents 553d1c0 + fd1e8f6 commit 98ea1aa
Showing 1 changed file with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useSelector, useDispatch } from 'react-redux';
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 Dropdown from 'components/Dropdown';
import NewRequest from 'components/Sidebar/NewRequest';
import NewFolder from 'components/Sidebar/NewFolder';
Expand All @@ -23,6 +24,7 @@ import { getDefaultRequestPaneTab } from 'utils/collections';
import { hideHomePage } from 'providers/ReduxStore/slices/app';
import toast from 'react-hot-toast';
import StyledWrapper from './StyledWrapper';
import NetworkError from 'components/ResponsePane/NetworkError/index';

const CollectionItem = ({ item, collection, searchText }) => {
const tabs = useSelector((state) => state.tabs.tabs);
Expand Down Expand Up @@ -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) => {
//scroll to the active tab
setTimeout(scrollToTheActiveTab, 50);
Expand Down Expand Up @@ -297,15 +307,27 @@ const CollectionItem = ({ item, collection, searchText }) => {
Rename
</div>
{!isFolder && (
<div
className="dropdown-item"
onClick={(e) => {
dropdownTippyRef.current.hide();
setCloneItemModalOpen(true);
}}
>
Clone
</div>
<>
<div
className="dropdown-item"
onClick={(e) => {
dropdownTippyRef.current.hide();
setCloneItemModalOpen(true);
}}
>
Clone
</div>
<div
className="dropdown-item"
onClick={(e) => {
dropdownTippyRef.current.hide();
handleClick(null);
handleRun();
}}
>
Run
</div>
</>
)}
{!isFolder && item.type === 'http-request' && (
<div
Expand Down

0 comments on commit 98ea1aa

Please sign in to comment.