mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-08 14:35:03 +00:00
fix: collection import (#2353)
This commit is contained in:
@@ -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'));
|
||||
};
|
||||
|
||||
@@ -23,7 +23,9 @@ const TitleBar = () => {
|
||||
|
||||
const handleImportCollection = ({ collection, translationLog }) => {
|
||||
setImportedCollection(collection);
|
||||
setImportedTranslationLog(translationLog);
|
||||
if (translationLog) {
|
||||
setImportedTranslationLog(translationLog);
|
||||
}
|
||||
setImportCollectionModalOpen(false);
|
||||
setImportCollectionLocationModalOpen(true);
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
@@ -53,7 +55,7 @@ const Welcome = () => {
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<div className="">
|
||||
<div>
|
||||
<Bruno width={50} />
|
||||
</div>
|
||||
<div className="text-xl font-semibold select-none">bruno</div>
|
||||
|
||||
@@ -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'));
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user