From 98f3a524dc7b5d543b8a7de2c29771c8f3f3c732 Mon Sep 17 00:00:00 2001 From: lohit Date: Tue, 28 Jan 2025 21:26:46 +0530 Subject: [PATCH] feat: updated the bru async parsing logic (#3898) --- .../RequestTabPanel/RequestNotLoaded/index.js | 40 +++--- .../src/components/RunnerResults/index.jsx | 5 +- .../CollectionItemIcon/StyledWrapper.js | 3 + .../CollectionItemIcon/index.js | 6 +- .../RunCollectionItem/StyledWrapper.js | 3 + .../CollectionItem/RunCollectionItem/index.js | 8 +- .../ReduxStore/slices/collections/actions.js | 2 - .../ReduxStore/slices/collections/index.js | 4 +- packages/bruno-electron/src/app/watcher.js | 16 ++- packages/bruno-electron/src/bru/index.js | 58 +++++++-- .../bruno-electron/src/bru/workers/index.js | 4 +- .../src/bru/workers/scripts/bru-to-json.js | 1 + .../workers/scripts/collection-bru-to-json.js | 13 -- .../src/bru/workers/scripts/json-to-bru.js | 13 ++ packages/bruno-electron/src/ipc/collection.js | 50 +++----- .../bruno-electron/src/utils/collection.js | 2 +- packages/bruno-electron/src/workers/index.js | 3 + .../tests/utils/collection.spec.js | 121 ++++++++++++++++++ 18 files changed, 262 insertions(+), 90 deletions(-) delete mode 100644 packages/bruno-electron/src/bru/workers/scripts/collection-bru-to-json.js create mode 100644 packages/bruno-electron/src/bru/workers/scripts/json-to-bru.js create mode 100644 packages/bruno-electron/tests/utils/collection.spec.js diff --git a/packages/bruno-app/src/components/RequestTabPanel/RequestNotLoaded/index.js b/packages/bruno-app/src/components/RequestTabPanel/RequestNotLoaded/index.js index e7afb1f60..95c2e8c00 100644 --- a/packages/bruno-app/src/components/RequestTabPanel/RequestNotLoaded/index.js +++ b/packages/bruno-app/src/components/RequestTabPanel/RequestNotLoaded/index.js @@ -28,26 +28,28 @@ const RequestNotLoaded = ({ collection, item }) => {
{item?.pathname}
-
-
- - - May cause the app to freeze temporarily while it runs. - + {!item?.error ? +
+
+ + + May cause the app to freeze temporarily while it runs. + +
+
+ + + Runs in background. + +
-
- - - Runs in background. - -
-
+ : null}
} diff --git a/packages/bruno-app/src/components/RunnerResults/index.jsx b/packages/bruno-app/src/components/RunnerResults/index.jsx index f7c1e4d9c..dc6ad94e8 100644 --- a/packages/bruno-app/src/components/RunnerResults/index.jsx +++ b/packages/bruno-app/src/components/RunnerResults/index.jsx @@ -9,6 +9,7 @@ import { IconRefresh, IconCircleCheck, IconCircleX, IconCheck, IconX, IconRun } import slash from 'utils/common/slash'; import ResponsePane from './ResponsePane'; import StyledWrapper from './StyledWrapper'; +import { areItemsLoading } from 'utils/collections/index'; const getRelativePath = (fullPath, pathname) => { // convert to unix style path @@ -106,6 +107,8 @@ export default function RunnerResults({ collection }) { return (item.status !== 'error' && item.testStatus === 'fail') || item.assertionStatus === 'fail'; }); + let isCollectionLoading = areItemsLoading(collection); + if (!items || !items.length) { return ( @@ -116,7 +119,7 @@ export default function RunnerResults({ collection }) {
You have {totalRequestsInCollection} requests in this collection.
- + {isCollectionLoading ?
Requests in this collection are still loading.
: null}
props.theme.colors.text.yellow}; } + .error { + color: ${(props) => props.theme.colors.text.danger}; + } `; export default Wrapper; diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/CollectionItemIcon/index.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/CollectionItemIcon/index.js index 14de1eb2f..82d87aa7d 100644 --- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/CollectionItemIcon/index.js +++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/CollectionItemIcon/index.js @@ -1,8 +1,12 @@ import RequestMethod from "../RequestMethod"; -import { IconLoader2, IconAlertTriangle } from '@tabler/icons'; +import { IconLoader2, IconAlertTriangle, IconAlertCircle } from '@tabler/icons'; import StyledWrapper from "./StyledWrapper"; const CollectionItemIcon = ({ item }) => { + if (item?.error) { + return ; + } + if (item?.loading) { return ; } diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/RunCollectionItem/StyledWrapper.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/RunCollectionItem/StyledWrapper.js index 3b6e08f42..e7dd94d2f 100644 --- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/RunCollectionItem/StyledWrapper.js +++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/RunCollectionItem/StyledWrapper.js @@ -4,6 +4,9 @@ const Wrapper = styled.div` .bruno-modal-content { padding-bottom: 1rem; } + .warning { + color: ${(props) => props.theme.colors.text.danger}; + } `; export default Wrapper; diff --git a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/RunCollectionItem/index.js b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/RunCollectionItem/index.js index 4a81f59af..e4642801e 100644 --- a/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/RunCollectionItem/index.js +++ b/packages/bruno-app/src/components/Sidebar/Collections/Collection/CollectionItem/RunCollectionItem/index.js @@ -7,6 +7,7 @@ import { addTab } from 'providers/ReduxStore/slices/tabs'; import { runCollectionFolder } from 'providers/ReduxStore/slices/collections/actions'; import { flattenItems } from 'utils/collections'; import StyledWrapper from './StyledWrapper'; +import { areItemsLoading } from 'utils/collections/index'; const RunCollectionItem = ({ collection, item, onClose }) => { const dispatch = useDispatch(); @@ -32,6 +33,8 @@ const RunCollectionItem = ({ collection, item, onClose }) => { const flattenedItems = flattenItems(item ? item.items : collection.items); const recursiveRunLength = getRequestsCount(flattenedItems); + const isFolderLoading = areItemsLoading(item); + return ( @@ -44,13 +47,12 @@ const RunCollectionItem = ({ collection, item, onClose }) => { ({runLength} requests)
This will only run the requests in this folder.
-
Recursive Run ({recursiveRunLength} requests)
-
This will run all the requests in this folder and all its subfolders.
- +
This will run all the requests in this folder and all its subfolders.
+ {isFolderLoading ?
Requests in this folder are still loading.
: null}