From 410bc70318daf3593116146217c8bbabfe3ca81a Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Fri, 14 Oct 2022 01:34:15 +0530 Subject: [PATCH] feat: cancel running request (resolves #26) --- .../RequestPane/HttpRequestPane/index.js | 6 +-- .../src/components/RequestTabPanel/index.js | 2 +- .../components/ResponsePane/Overlay/index.js | 13 +++++- .../src/components/ResponsePane/index.js | 6 ++- .../ReduxStore/slices/collections/actions.js | 41 ++++++++++++++++++ .../ReduxStore/slices/collections/index.js | 43 ++++++++++--------- .../src/utils/network/cancelTokens.js | 14 ++++++ packages/bruno-app/src/utils/network/index.js | 40 +++++++++-------- 8 files changed, 118 insertions(+), 47 deletions(-) create mode 100644 packages/bruno-app/src/utils/network/cancelTokens.js diff --git a/packages/bruno-app/src/components/RequestPane/HttpRequestPane/index.js b/packages/bruno-app/src/components/RequestPane/HttpRequestPane/index.js index c4f592b2..3c9e8d65 100644 --- a/packages/bruno-app/src/components/RequestPane/HttpRequestPane/index.js +++ b/packages/bruno-app/src/components/RequestPane/HttpRequestPane/index.js @@ -8,7 +8,7 @@ import RequestHeaders from 'components/RequestPane/RequestHeaders'; import RequestBody from 'components/RequestPane/RequestBody'; import RequestBodyMode from 'components/RequestPane/RequestBody/RequestBodyMode'; import QueryUrl from 'components/RequestPane/QueryUrl'; -import { sendRequest } from 'providers/ReduxStore/slices/collections'; +import { sendRequest } from 'providers/ReduxStore/slices/collections/actions'; import StyledWrapper from './StyledWrapper'; const HttpRequestPane = ({item, collection, leftPaneWidth}) => { @@ -16,7 +16,7 @@ const HttpRequestPane = ({item, collection, leftPaneWidth}) => { const tabs = useSelector((state) => state.tabs.tabs); const activeTabUid = useSelector((state) => state.tabs.activeTabUid); - const sendNetworkRequest = async () => dispatch(sendRequest(item, collection.uid)); + const handleRun = async () => dispatch(sendRequest(item, collection.uid)); const selectTab = (tab) => { dispatch(updateRequestPaneTab({ @@ -67,7 +67,7 @@ const HttpRequestPane = ({item, collection, leftPaneWidth}) => {
diff --git a/packages/bruno-app/src/components/RequestTabPanel/index.js b/packages/bruno-app/src/components/RequestTabPanel/index.js index 53a69ba6..338bbbf5 100644 --- a/packages/bruno-app/src/components/RequestTabPanel/index.js +++ b/packages/bruno-app/src/components/RequestTabPanel/index.js @@ -139,9 +139,9 @@ const RequestTabPanel = () => {
diff --git a/packages/bruno-app/src/components/ResponsePane/Overlay/index.js b/packages/bruno-app/src/components/ResponsePane/Overlay/index.js index 9b825da5..e5003250 100644 --- a/packages/bruno-app/src/components/ResponsePane/Overlay/index.js +++ b/packages/bruno-app/src/components/ResponsePane/Overlay/index.js @@ -1,9 +1,17 @@ import React from 'react'; import { IconRefresh } from '@tabler/icons'; +import { useDispatch } from 'react-redux'; +import { cancelRequest } from 'providers/ReduxStore/slices/collections/actions'; import StopWatch from '../../StopWatch'; import StyledWrapper from './StyledWrapper'; -const QueryResult = () => { +const ResponseLoadingOverlay = ({item, collection}) => { + const dispatch = useDispatch(); + + const handleCancelRequest = () => { + dispatch(cancelRequest(item.cancelTokenUid, item, collection)); + }; + return (
@@ -14,6 +22,7 @@ const QueryResult = () => {