mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
fix: prevent rerun flicker and fix runner configuration list order (#7639)
This commit is contained in:
@@ -5,7 +5,8 @@ import { IconGripVertical, IconCheck } from '@tabler/icons';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { updateRunnerConfiguration } from 'providers/ReduxStore/slices/collections/actions';
|
||||
import StyledWrapper from './StyledWrapper';
|
||||
import { isItemARequest } from 'utils/collections';
|
||||
import { isItemARequest, isItemAFolder } from 'utils/collections';
|
||||
import { sortByNameThenSequence } from 'utils/common/index';
|
||||
import path from 'utils/common/path';
|
||||
import { cloneDeep, get } from 'lodash';
|
||||
import Button from 'ui/Button/index';
|
||||
@@ -187,20 +188,25 @@ const RunConfigurationPanel = ({ collection, selectedItems, setSelectedItems, ta
|
||||
const processItems = (items) => {
|
||||
if (!items?.length) return;
|
||||
|
||||
items.forEach((item) => {
|
||||
if (isItemARequest(item) && !item.partial && !item.isTransient) {
|
||||
const relativePath = path.relative(collection.pathname, path.dirname(item.pathname));
|
||||
const folderPath = relativePath !== '.' ? relativePath : '';
|
||||
const folderItems = sortByNameThenSequence(items.filter((item) => isItemAFolder(item) && !item.isTransient));
|
||||
const requestItems = items
|
||||
.filter((item) => isItemARequest(item) && !item.partial && !item.isTransient)
|
||||
.sort((a, b) => a.seq - b.seq);
|
||||
|
||||
result.push({
|
||||
...item,
|
||||
folderPath: folderPath.replace(/\\/g, '/')
|
||||
});
|
||||
folderItems.forEach((folder) => {
|
||||
if (folder.items?.length) {
|
||||
processItems(folder.items);
|
||||
}
|
||||
});
|
||||
|
||||
if (item.items?.length) {
|
||||
processItems(item.items);
|
||||
}
|
||||
requestItems.forEach((item) => {
|
||||
const relativePath = path.relative(collection.pathname, path.dirname(item.pathname));
|
||||
const folderPath = relativePath !== '.' ? relativePath : '';
|
||||
|
||||
result.push({
|
||||
...item,
|
||||
folderPath: folderPath.replace(/\\/g, '/')
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ export default function RunnerResults({ collection }) {
|
||||
const [delay, setDelay] = useState(null);
|
||||
const [activeFilter, setActiveFilter] = useState('all');
|
||||
const [selectedRequestItems, setSelectedRequestItems] = useState([]);
|
||||
const isReRunningRef = useRef(false);
|
||||
// ref for the runner output body
|
||||
const runnerBodyRef = useRef();
|
||||
|
||||
@@ -165,6 +166,13 @@ export default function RunnerResults({ collection }) {
|
||||
}
|
||||
}, [collection.runnerConfiguration, delay]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isReRunningRef.current
|
||||
&& (items?.length > 0 || runnerInfo?.status === 'ended' || runnerInfo?.status === 'cancelled')) {
|
||||
isReRunningRef.current = false;
|
||||
}
|
||||
}, [items, runnerInfo?.status]);
|
||||
|
||||
const ensureCollectionIsMounted = () => {
|
||||
if (collection.mountStatus === 'mounted') {
|
||||
return;
|
||||
@@ -184,6 +192,7 @@ export default function RunnerResults({ collection }) {
|
||||
|
||||
const runAgain = () => {
|
||||
ensureCollectionIsMounted();
|
||||
isReRunningRef.current = true;
|
||||
// Get the saved configuration to determine what to run
|
||||
const savedConfiguration = get(collection, 'runnerConfiguration', null);
|
||||
const savedSelectedItems = savedConfiguration?.selectedRequestItems || [];
|
||||
@@ -201,6 +210,7 @@ export default function RunnerResults({ collection }) {
|
||||
};
|
||||
|
||||
const resetRunner = () => {
|
||||
isReRunningRef.current = false;
|
||||
dispatch(
|
||||
resetCollectionRunner({
|
||||
collectionUid: collection.uid
|
||||
@@ -222,7 +232,7 @@ export default function RunnerResults({ collection }) {
|
||||
};
|
||||
|
||||
let isCollectionLoading = areItemsLoading(collection);
|
||||
if (!items || !items.length) {
|
||||
if ((!items || !items.length) && !isReRunningRef.current) {
|
||||
return (
|
||||
<StyledWrapper className="pl-4 overflow-hidden h-full">
|
||||
<div className="flex overflow-hidden max-h-full h-full">
|
||||
|
||||
Reference in New Issue
Block a user