Skip to content

Commit

Permalink
fix: collection import (#2353)
Browse files Browse the repository at this point in the history
  • Loading branch information
lohxt1 committed May 22, 2024
1 parent 4f11da1 commit 4f64c2d
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 76 deletions.
61 changes: 1 addition & 60 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,32 @@ const ImportCollection = ({ onClose, handleSubmit }) => {
});
const handleImportBrunoCollection = () => {
importBrunoCollection()
.then((collection) => {
handleSubmit(collection);
.then(({ collection }) => {
handleSubmit({ collection });
})
.catch((err) => toastError(err, 'Import collection failed'));
};

const handleImportPostmanCollection = () => {
importPostmanCollection(options)
.then((collection) => {
handleSubmit(collection);
.then(({ collection, translationLog }) => {
handleSubmit({ collection, translationLog });
})
.catch((err) => toastError(err, 'Postman Import collection failed'));
};

const handleImportInsomniaCollection = () => {
importInsomniaCollection()
.then((collection) => {
handleSubmit(collection);
.then(({ collection }) => {
handleSubmit({ collection });
})
.catch((err) => toastError(err, 'Insomnia Import collection failed'));
};

const handleImportOpenapiCollection = () => {
importOpenapiCollection()
.then((collection) => {
handleSubmit(collection);
.then(({ collection }) => {
handleSubmit({ collection });
})
.catch((err) => toastError(err, 'OpenAPI v3 Import collection failed'));
};
Expand Down
4 changes: 3 additions & 1 deletion packages/bruno-app/src/components/Sidebar/TitleBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ const TitleBar = () => {

const handleImportCollection = ({ collection, translationLog }) => {
setImportedCollection(collection);
setImportedTranslationLog(translationLog);
if (translationLog) {
setImportedTranslationLog(translationLog);
}
setImportCollectionModalOpen(false);
setImportCollectionLocationModalOpen(true);
};
Expand Down
8 changes: 5 additions & 3 deletions packages/bruno-app/src/components/Welcome/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ const Welcome = () => {
);
};

const handleImportCollection = (collection, translationLog) => {
const handleImportCollection = ({ collection, translationLog }) => {
setImportedCollection(collection);
setImportedTranslationLog(translationLog);
if (translationLog) {
setImportedTranslationLog(translationLog);
}
setImportCollectionModalOpen(false);
setImportCollectionLocationModalOpen(true);
};
Expand All @@ -53,7 +55,7 @@ const Welcome = () => {
/>
) : null}

<div className="">
<div>
<Bruno width={50} />
</div>
<div className="text-xl font-semibold select-none">bruno</div>
Expand Down
2 changes: 1 addition & 1 deletion packages/bruno-app/src/utils/importers/bruno-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const importCollection = () => {
.then(updateUidsInCollection)
.then(transformItemsInCollection)
.then(validateSchema)
.then((collection) => resolve(collection))
.then((collection) => resolve({ collection }))
.catch((err) => {
console.log(err);
reject(new BrunoError('Import collection failed'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ const importCollection = () => {
.then(transformItemsInCollection)
.then(hydrateSeqInCollection)
.then(validateSchema)
.then((collection) => resolve(collection))
.then((collection) => resolve({ collection }))
.catch((err) => {
console.error(err);
reject(new BrunoError('Import collection failed: ' + err.message));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ const importCollection = () => {
.then(transformItemsInCollection)
.then(hydrateSeqInCollection)
.then(validateSchema)
.then((collection) => resolve(collection))
.then((collection) => resolve({ collection }))
.catch((err) => {
console.error(err);
reject(new BrunoError('Import collection failed: ' + err.message));
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 @@ -431,7 +431,7 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
// Handle items of type 'js'
if (item.type === 'js') {
const filePath = path.join(currentPath, `${item.name}.js`);
fs.writeFileSync(filePath, item.raw);
fs.writeFileSync(filePath, item.fileContent);
}
});
};
Expand Down

0 comments on commit 4f64c2d

Please sign in to comment.