pr review changes (#2563)

This commit is contained in:
lohit 2024-07-04 14:47:46 +05:30 committed by GitHub
parent c8f95a34e9
commit 40f7be534a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 14 deletions

View File

@ -1179,7 +1179,6 @@ export const collectionsSlice = createSlice({
uid: uuid(),
name: '',
value: '',
type: 'request',
enabled: true
});
set(folder, 'root.request.vars.req', vars);
@ -1189,7 +1188,6 @@ export const collectionsSlice = createSlice({
uid: uuid(),
name: '',
value: '',
type: 'response',
enabled: true
});
set(folder, 'root.request.vars.res', vars);

View File

@ -380,7 +380,7 @@ export const transformCollectionToSaveToExportAsFile = (collection, options = {}
}
}
if (si?.root) {
if (si.type == 'folder' && si?.root) {
di.root = {
request: {
headers: si?.root?.request?.headers,
@ -393,10 +393,6 @@ export const transformCollectionToSaveToExportAsFile = (collection, options = {}
name: si?.root?.meta?.name
}
};
di.root.request.auth = {
mode: get(si.root.request, 'auth.mode', 'none')
};
}
if (si.type === 'js') {

View File

@ -38,11 +38,10 @@ const collectionBruToJson = (bru) => {
}
};
const jsonToCollectionBru = (json) => {
const jsonToCollectionBru = (json, isFolder) => {
try {
const collectionBruJson = {
headers: _.get(json, 'request.headers', []),
auth: _.get(json, 'request.auth', {}),
script: {
req: _.get(json, 'request.script.req', ''),
res: _.get(json, 'request.script.res', '')
@ -64,6 +63,10 @@ const jsonToCollectionBru = (json) => {
};
}
if (!isFolder) {
collectionBruJson.auth = _.get(json, 'request.auth', {});
}
return _jsonToCollectionBru(collectionBruJson);
} catch (error) {
return Promise.reject(error);

View File

@ -161,7 +161,10 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
name: folderName
};
const content = jsonToCollectionBru(folderRoot);
const content = jsonToCollectionBru(
folderRoot,
true // isFolder
);
await writeFile(folderBruFilePath, content);
} catch (error) {
return Promise.reject(error);
@ -439,10 +442,14 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
const folderPath = path.join(currentPath, item.name);
fs.mkdirSync(folderPath);
const folderBruFilePath = path.join(folderPath, 'folder.bru');
const folderContent = jsonToCollectionBru(item.root);
console.log('folder COntent', item.root, folderContent);
fs.writeFileSync(folderBruFilePath, folderContent);
if (item?.root?.meta?.name) {
const folderBruFilePath = path.join(folderPath, 'folder.bru');
const folderContent = jsonToCollectionBru(
item.root,
true // isFolder
);
fs.writeFileSync(folderBruFilePath, folderContent);
}
if (item.items && item.items.length) {
parseCollectionItems(item.items, folderPath);