mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-25 01:14:23 +01:00
pr review changes (#2563)
This commit is contained in:
parent
c8f95a34e9
commit
40f7be534a
@ -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);
|
||||
|
@ -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') {
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
if (item?.root?.meta?.name) {
|
||||
const folderBruFilePath = path.join(folderPath, 'folder.bru');
|
||||
const folderContent = jsonToCollectionBru(item.root);
|
||||
console.log('folder COntent', item.root, folderContent);
|
||||
const folderContent = jsonToCollectionBru(
|
||||
item.root,
|
||||
true // isFolder
|
||||
);
|
||||
fs.writeFileSync(folderBruFilePath, folderContent);
|
||||
}
|
||||
|
||||
if (item.items && item.items.length) {
|
||||
parseCollectionItems(item.items, folderPath);
|
||||
|
Loading…
Reference in New Issue
Block a user