feat: Enhance runCollectionFolder to support selected request ordering (#6320)

* Refactor `runCollectionFolder` action to accept `selectedRequestUids` for filtering and ordering requests.
* Update IPC handler to process `selectedRequestUids`, ensuring requests are executed in the specified order while preserving folder data.
This commit is contained in:
Pragadesh-45
2025-12-08 17:16:24 +05:30
committed by GitHub
parent 4016754d71
commit a66be21523
2 changed files with 19 additions and 23 deletions

View File

@@ -672,26 +672,6 @@ export const runCollectionFolder
})
);
// to only include those requests in the specified order while preserving folder data
if (selectedRequestUids && selectedRequestUids.length > 0) {
const newItems = [];
selectedRequestUids.forEach((uid, index) => {
const requestItem = findItemInCollection(collectionCopy, uid);
if (requestItem) {
const clonedRequest = cloneDeep(requestItem);
clonedRequest.seq = index + 1;
newItems.push(clonedRequest);
}
});
if (folder) {
folder.items = newItems;
} else {
collectionCopy.items = newItems;
}
}
const { ipcRenderer } = window;
ipcRenderer
.invoke(
@@ -702,7 +682,8 @@ export const runCollectionFolder
collectionCopy.runtimeVariables,
recursive,
delay,
tags
tags,
selectedRequestUids
)
.then(resolve)
.catch((err) => {

View File

@@ -1057,8 +1057,7 @@ const registerNetworkIpc = (mainWindow) => {
ipcMain.handle('fetch-gql-schema', fetchGqlSchemaHandler);
ipcMain.handle(
'renderer:run-collection-folder',
async (event, folder, collection, environment, runtimeVariables, recursive, delay, tags) => {
'renderer:run-collection-folder', async (event, folder, collection, environment, runtimeVariables, recursive, delay, tags, selectedRequestUids) => {
const collectionUid = collection.uid;
const collectionPath = collection.pathname;
const folderUid = folder ? folder.uid : null;
@@ -1135,6 +1134,22 @@ const registerNetworkIpc = (mainWindow) => {
});
}
// Filter requests based on selectedRequestUids (for "Configure requests to run")
if (selectedRequestUids && selectedRequestUids.length > 0) {
const uidIndexMap = new Map();
selectedRequestUids.forEach((uid, index) => {
uidIndexMap.set(uid, index);
});
folderRequests = folderRequests
.filter((request) => uidIndexMap.has(request.uid))
.sort((a, b) => {
const indexA = uidIndexMap.get(a.uid);
const indexB = uidIndexMap.get(b.uid);
return indexA - indexB;
});
}
let currentRequestIndex = 0;
let nJumps = 0; // count the number of jumps to avoid infinite loops
while (currentRequestIndex < folderRequests.length) {