From 721d0e1e49b93c8be10c2b48385abc2f168883da Mon Sep 17 00:00:00 2001 From: anusreesubash <65728079+anusreesubash@users.noreply.github.com> Date: Mon, 16 Sep 2024 00:33:15 +0530 Subject: [PATCH] Improved Request Count Calculation and UI Handling in RunCollectionItem (#2959) * Fix | properl calculates the request number for folder run * Chore|formatted document --------- Co-authored-by: Anusree Subash --- .../CollectionItem/RunCollectionItem/index.js | 72 +++++++++++-------- 1 file changed, 41 insertions(+), 31 deletions(-) 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 8c3da90a7..4a81f59af 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 @@ -23,43 +23,53 @@ const RunCollectionItem = ({ collection, item, onClose }) => { onClose(); }; - const runLength = item ? get(item, 'items.length', 0) : get(collection, 'items.length', 0); - const items = flattenItems(item ? item.items : collection.items); - const requestItems = items.filter((item) => item.type !== 'folder'); - const recursiveRunLength = requestItems.length; + const getRequestsCount = (items) => { + const requestTypes = ['http-request', 'graphql-request'] + return items.filter(req => requestTypes.includes(req.type)).length; + } + + const runLength = item ? getRequestsCount(item.items) : get(collection, 'items.length', 0); + const flattenedItems = flattenItems(item ? item.items : collection.items); + const recursiveRunLength = getRequestsCount(flattenedItems); return ( -
- Run - ({runLength} requests) -
-
This will only run the requests in this folder.
+ {!runLength && !recursiveRunLength ? ( +
No request found in this folder.
+ ) : ( +
+
+ Run + ({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.
+
+ Recursive Run + ({recursiveRunLength} requests) +
+
This will run all the requests in this folder and all its subfolders.
-
- - - - - - - - - -
+
+ + + + + + + + + +
+
+ )}
);