mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-21 23:43:15 +01:00
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 <anusree@usebruno.com>
This commit is contained in:
parent
f31c997fed
commit
721d0e1e49
@ -23,43 +23,53 @@ const RunCollectionItem = ({ collection, item, onClose }) => {
|
|||||||
onClose();
|
onClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
const runLength = item ? get(item, 'items.length', 0) : get(collection, 'items.length', 0);
|
const getRequestsCount = (items) => {
|
||||||
const items = flattenItems(item ? item.items : collection.items);
|
const requestTypes = ['http-request', 'graphql-request']
|
||||||
const requestItems = items.filter((item) => item.type !== 'folder');
|
return items.filter(req => requestTypes.includes(req.type)).length;
|
||||||
const recursiveRunLength = requestItems.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 (
|
return (
|
||||||
<StyledWrapper>
|
<StyledWrapper>
|
||||||
<Modal size="md" title="Collection Runner" hideFooter={true} handleCancel={onClose}>
|
<Modal size="md" title="Collection Runner" hideFooter={true} handleCancel={onClose}>
|
||||||
<div className="mb-1">
|
{!runLength && !recursiveRunLength ? (
|
||||||
<span className="font-medium">Run</span>
|
<div className="mb-8">No request found in this folder.</div>
|
||||||
<span className="ml-1 text-xs">({runLength} requests)</span>
|
) : (
|
||||||
</div>
|
<div>
|
||||||
<div className="mb-8">This will only run the requests in this folder.</div>
|
<div className="mb-1">
|
||||||
|
<span className="font-medium">Run</span>
|
||||||
|
<span className="ml-1 text-xs">({runLength} requests)</span>
|
||||||
|
</div>
|
||||||
|
<div className="mb-8">This will only run the requests in this folder.</div>
|
||||||
|
|
||||||
<div className="mb-1">
|
<div className="mb-1">
|
||||||
<span className="font-medium">Recursive Run</span>
|
<span className="font-medium">Recursive Run</span>
|
||||||
<span className="ml-1 text-xs">({recursiveRunLength} requests)</span>
|
<span className="ml-1 text-xs">({recursiveRunLength} requests)</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-8">This will run all the requests in this folder and all its subfolders.</div>
|
<div className="mb-8">This will run all the requests in this folder and all its subfolders.</div>
|
||||||
|
|
||||||
<div className="flex justify-end bruno-modal-footer">
|
<div className="flex justify-end bruno-modal-footer">
|
||||||
<span className="mr-3">
|
<span className="mr-3">
|
||||||
<button type="button" onClick={onClose} className="btn btn-md btn-close">
|
<button type="button" onClick={onClose} className="btn btn-md btn-close">
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
<button type="submit" className="submit btn btn-md btn-secondary mr-3" onClick={() => onSubmit(true)}>
|
<button type="submit" disabled={!recursiveRunLength} className="submit btn btn-md btn-secondary mr-3" onClick={() => onSubmit(true)}>
|
||||||
Recursive Run
|
Recursive Run
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span>
|
||||||
<button type="submit" className="submit btn btn-md btn-secondary" onClick={() => onSubmit(false)}>
|
<button type="submit" disabled={!runLength} className="submit btn btn-md btn-secondary" onClick={() => onSubmit(false)}>
|
||||||
Run
|
Run
|
||||||
</button>
|
</button>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</Modal>
|
</Modal>
|
||||||
</StyledWrapper>
|
</StyledWrapper>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user