Skip to content

Commit

Permalink
feature(postman_tests_scripts): partial changes, preparing merge from…
Browse files Browse the repository at this point in the history
… 1.9.0
  • Loading branch information
bpoulaindev committed Feb 21, 2024
1 parent 9b51c79 commit 3f5bd47
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const ImportCollectionLocation = ({ onClose, handleSubmit, collectionName }) =>
Browse
</span>
</div>
<span>wesh alors</span>
</div>
</form>
</Modal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const TitleBar = () => {
setImportCollectionLocationModalOpen(true);
};

const handleImportCollectionLocation = (collectionLocation) => {
const handleImportCollectionLocation = (collectionLocation, useTranslation) => {
dispatch(importCollection(importedCollection, collectionLocation));
setImportCollectionLocationModalOpen(false);
setImportedCollection(null);
Expand Down
4 changes: 2 additions & 2 deletions packages/bruno-app/src/components/Welcome/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const Welcome = () => {
setImportCollectionLocationModalOpen(true);
};

const handleImportCollectionLocation = (collectionLocation) => {
dispatch(importCollection(importedCollection, collectionLocation));
const handleImportCollectionLocation = (collectionLocation, enableTRanslation = true) => {
dispatch(importCollection(importedCollection, collectionLocation, enableTranslation));
setImportCollectionLocationModalOpen(false);
setImportedCollection(null);
toast.success('Collection imported successfully');
Expand Down
13 changes: 7 additions & 6 deletions packages/bruno-app/src/utils/importers/postman-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const convertV21Auth = (array) => {
}, {});
};

const importPostmanV2CollectionItem = (brunoParent, item, parentAuth) => {
const importPostmanV2CollectionItem = (brunoParent, item, parentAuth, enableTranslation) => {
brunoParent.items = brunoParent.items || [];
const folderMap = {};

Expand All @@ -78,7 +78,7 @@ const importPostmanV2CollectionItem = (brunoParent, item, parentAuth) => {
brunoParent.items.push(brunoFolderItem);
folderMap[folderName] = brunoFolderItem;
if (i.item && i.item.length) {
importPostmanV2CollectionItem(brunoFolderItem, i.item, i.auth ?? parentAuth);
importPostmanV2CollectionItem(brunoFolderItem, i.item, i.auth ?? parentAuth, enableTranslation);
}
} else {
if (i.request) {
Expand Down Expand Up @@ -266,7 +266,7 @@ const searchLanguageByHeader = (headers) => {
return contentType;
};

const importPostmanV2Collection = (collection) => {
const importPostmanV2Collection = (collection, enableTranslation) => {
const brunoCollection = {
name: collection.info.name,
uid: uuid(),
Expand All @@ -275,12 +275,13 @@ const importPostmanV2Collection = (collection) => {
environments: []
};

importPostmanV2CollectionItem(brunoCollection, collection.item, collection.auth);
importPostmanV2CollectionItem(brunoCollection, collection.item, collection.auth, enableTranslation);

return brunoCollection;
};

const parsePostmanCollection = (str) => {
const parsePostmanCollection = (str, enableTranslation) => {
console.log('PITIE PITIT SVP')
return new Promise((resolve, reject) => {
try {
let collection = JSON.parse(str);
Expand All @@ -292,7 +293,7 @@ const parsePostmanCollection = (str) => {
];

if (v2Schemas.includes(schema)) {
return resolve(importPostmanV2Collection(collection));
return resolve(importPostmanV2Collection(collection, enableTranslation));
}

throw new BrunoError('Unknown postman schema');
Expand Down
2 changes: 1 addition & 1 deletion packages/bruno-electron/src/ipc/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
}
});

ipcMain.handle('renderer:import-collection', async (event, collection, collectionLocation) => {
ipcMain.handle('renderer:import-collection', async (event, collection, collectionLocation, enableTranslation) => {
try {
let collectionName = sanitizeDirectoryName(collection.name);
let collectionPath = path.join(collectionLocation, collectionName);
Expand Down

0 comments on commit 3f5bd47

Please sign in to comment.