fix: collection import (#2353)

This commit is contained in:
lohit
2024-05-22 21:32:24 +05:30
committed by GitHub
parent 4f11da12af
commit 4f64c2d59b
8 changed files with 21 additions and 76 deletions

View File

@@ -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'));
};

View File

@@ -23,7 +23,9 @@ const TitleBar = () => {
const handleImportCollection = ({ collection, translationLog }) => {
setImportedCollection(collection);
setImportedTranslationLog(translationLog);
if (translationLog) {
setImportedTranslationLog(translationLog);
}
setImportCollectionModalOpen(false);
setImportCollectionLocationModalOpen(true);
};

View File

@@ -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>

View File

@@ -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'));

View File

@@ -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));

View File

@@ -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));

View File

@@ -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);
}
});
};