mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-22 07:53:34 +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(),
|
uid: uuid(),
|
||||||
name: '',
|
name: '',
|
||||||
value: '',
|
value: '',
|
||||||
type: 'request',
|
|
||||||
enabled: true
|
enabled: true
|
||||||
});
|
});
|
||||||
set(folder, 'root.request.vars.req', vars);
|
set(folder, 'root.request.vars.req', vars);
|
||||||
@ -1189,7 +1188,6 @@ export const collectionsSlice = createSlice({
|
|||||||
uid: uuid(),
|
uid: uuid(),
|
||||||
name: '',
|
name: '',
|
||||||
value: '',
|
value: '',
|
||||||
type: 'response',
|
|
||||||
enabled: true
|
enabled: true
|
||||||
});
|
});
|
||||||
set(folder, 'root.request.vars.res', vars);
|
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 = {
|
di.root = {
|
||||||
request: {
|
request: {
|
||||||
headers: si?.root?.request?.headers,
|
headers: si?.root?.request?.headers,
|
||||||
@ -393,10 +393,6 @@ export const transformCollectionToSaveToExportAsFile = (collection, options = {}
|
|||||||
name: si?.root?.meta?.name
|
name: si?.root?.meta?.name
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
di.root.request.auth = {
|
|
||||||
mode: get(si.root.request, 'auth.mode', 'none')
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (si.type === 'js') {
|
if (si.type === 'js') {
|
||||||
|
@ -38,11 +38,10 @@ const collectionBruToJson = (bru) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const jsonToCollectionBru = (json) => {
|
const jsonToCollectionBru = (json, isFolder) => {
|
||||||
try {
|
try {
|
||||||
const collectionBruJson = {
|
const collectionBruJson = {
|
||||||
headers: _.get(json, 'request.headers', []),
|
headers: _.get(json, 'request.headers', []),
|
||||||
auth: _.get(json, 'request.auth', {}),
|
|
||||||
script: {
|
script: {
|
||||||
req: _.get(json, 'request.script.req', ''),
|
req: _.get(json, 'request.script.req', ''),
|
||||||
res: _.get(json, 'request.script.res', '')
|
res: _.get(json, 'request.script.res', '')
|
||||||
@ -64,6 +63,10 @@ const jsonToCollectionBru = (json) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isFolder) {
|
||||||
|
collectionBruJson.auth = _.get(json, 'request.auth', {});
|
||||||
|
}
|
||||||
|
|
||||||
return _jsonToCollectionBru(collectionBruJson);
|
return _jsonToCollectionBru(collectionBruJson);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
|
@ -161,7 +161,10 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
|||||||
name: folderName
|
name: folderName
|
||||||
};
|
};
|
||||||
|
|
||||||
const content = jsonToCollectionBru(folderRoot);
|
const content = jsonToCollectionBru(
|
||||||
|
folderRoot,
|
||||||
|
true // isFolder
|
||||||
|
);
|
||||||
await writeFile(folderBruFilePath, content);
|
await writeFile(folderBruFilePath, content);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
@ -439,10 +442,14 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
|||||||
const folderPath = path.join(currentPath, item.name);
|
const folderPath = path.join(currentPath, item.name);
|
||||||
fs.mkdirSync(folderPath);
|
fs.mkdirSync(folderPath);
|
||||||
|
|
||||||
const folderBruFilePath = path.join(folderPath, 'folder.bru');
|
if (item?.root?.meta?.name) {
|
||||||
const folderContent = jsonToCollectionBru(item.root);
|
const folderBruFilePath = path.join(folderPath, 'folder.bru');
|
||||||
console.log('folder COntent', item.root, folderContent);
|
const folderContent = jsonToCollectionBru(
|
||||||
fs.writeFileSync(folderBruFilePath, folderContent);
|
item.root,
|
||||||
|
true // isFolder
|
||||||
|
);
|
||||||
|
fs.writeFileSync(folderBruFilePath, folderContent);
|
||||||
|
}
|
||||||
|
|
||||||
if (item.items && item.items.length) {
|
if (item.items && item.items.length) {
|
||||||
parseCollectionItems(item.items, folderPath);
|
parseCollectionItems(item.items, folderPath);
|
||||||
|
Loading…
Reference in New Issue
Block a user