From 3f5bd4744abfcba434d58ecbbdcbf1116e8b3910 Mon Sep 17 00:00:00 2001 From: bpoulaindev Date: Wed, 21 Feb 2024 16:52:17 +0100 Subject: [PATCH] feature(postman_tests_scripts): partial changes, preparing merge from 1.9.0 --- .../Sidebar/ImportCollectionLocation/index.js | 1 + .../src/components/Sidebar/TitleBar/index.js | 2 +- packages/bruno-app/src/components/Welcome/index.js | 4 ++-- .../src/utils/importers/postman-collection.js | 13 +++++++------ packages/bruno-electron/src/ipc/collection.js | 2 +- 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/packages/bruno-app/src/components/Sidebar/ImportCollectionLocation/index.js b/packages/bruno-app/src/components/Sidebar/ImportCollectionLocation/index.js index 62a02bdd56..773df6916d 100644 --- a/packages/bruno-app/src/components/Sidebar/ImportCollectionLocation/index.js +++ b/packages/bruno-app/src/components/Sidebar/ImportCollectionLocation/index.js @@ -80,6 +80,7 @@ const ImportCollectionLocation = ({ onClose, handleSubmit, collectionName }) => Browse + wesh alors diff --git a/packages/bruno-app/src/components/Sidebar/TitleBar/index.js b/packages/bruno-app/src/components/Sidebar/TitleBar/index.js index ebf8c608dc..6f683a6463 100644 --- a/packages/bruno-app/src/components/Sidebar/TitleBar/index.js +++ b/packages/bruno-app/src/components/Sidebar/TitleBar/index.js @@ -26,7 +26,7 @@ const TitleBar = () => { setImportCollectionLocationModalOpen(true); }; - const handleImportCollectionLocation = (collectionLocation) => { + const handleImportCollectionLocation = (collectionLocation, useTranslation) => { dispatch(importCollection(importedCollection, collectionLocation)); setImportCollectionLocationModalOpen(false); setImportedCollection(null); diff --git a/packages/bruno-app/src/components/Welcome/index.js b/packages/bruno-app/src/components/Welcome/index.js index adfce3dd88..592d06badc 100644 --- a/packages/bruno-app/src/components/Welcome/index.js +++ b/packages/bruno-app/src/components/Welcome/index.js @@ -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'); diff --git a/packages/bruno-app/src/utils/importers/postman-collection.js b/packages/bruno-app/src/utils/importers/postman-collection.js index 71b0cb8213..d2c0fd6587 100644 --- a/packages/bruno-app/src/utils/importers/postman-collection.js +++ b/packages/bruno-app/src/utils/importers/postman-collection.js @@ -54,7 +54,7 @@ const convertV21Auth = (array) => { }, {}); }; -const importPostmanV2CollectionItem = (brunoParent, item, parentAuth) => { +const importPostmanV2CollectionItem = (brunoParent, item, parentAuth, enableTranslation) => { brunoParent.items = brunoParent.items || []; const folderMap = {}; @@ -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) { @@ -266,7 +266,7 @@ const searchLanguageByHeader = (headers) => { return contentType; }; -const importPostmanV2Collection = (collection) => { +const importPostmanV2Collection = (collection, enableTranslation) => { const brunoCollection = { name: collection.info.name, uid: uuid(), @@ -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); @@ -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'); diff --git a/packages/bruno-electron/src/ipc/collection.js b/packages/bruno-electron/src/ipc/collection.js index 9428eb4eca..04ebad05f2 100644 --- a/packages/bruno-electron/src/ipc/collection.js +++ b/packages/bruno-electron/src/ipc/collection.js @@ -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);