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
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 21 additions and 76 deletions

61
package-lock.json generated
View File

@ -19729,7 +19729,7 @@
},
"packages/bruno-electron": {
"name": "bruno",
"version": "v1.17.0",
"version": "v1.18.0",
"dependencies": {
"@aws-sdk/credential-providers": "3.525.0",
"@usebruno/common": "0.1.0",
@ -20762,21 +20762,6 @@
"node": ">=14.0.0"
}
},
"packages/bruno-electron/node_modules/ajv": {
"version": "8.13.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.13.0.tgz",
"integrity": "sha512-PRA911Blj99jR5RMeTunVbNXMF6Lp4vZXnk5GQjcnUWUTsrXtekg/pnmFFI2u/I36Y/2bITGS30GZCXei6uNkA==",
"dependencies": {
"fast-deep-equal": "^3.1.3",
"json-schema-traverse": "^1.0.0",
"require-from-string": "^2.0.2",
"uri-js": "^4.4.1"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/epoberezkin"
}
},
"packages/bruno-electron/node_modules/fs-extra": {
"version": "10.1.0",
"license": "MIT",
@ -20789,11 +20774,6 @@
"node": ">=12"
}
},
"packages/bruno-electron/node_modules/json-schema-traverse": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="
},
"packages/bruno-graphql-docs": {
"name": "@usebruno/graphql-docs",
"version": "0.1.0",
@ -27012,40 +26992,6 @@
"tslib": "^2.5.0"
}
},
"@usebruno/js": {
"version": "https://registry.npmjs.org/@usebruno/js/-/js-0.11.0.tgz",
"integrity": "sha512-csbKAnFtLTupG46aMIahRWeNW8/rdDeaZPtvr4kIzcHDPNmKNowcFcrIR4VSpceh47Ltpm8n0sgzrHzw8P8Yjg==",
"requires": {
"@usebruno/query": "0.1.0",
"ajv": "^8.12.0",
"ajv-formats": "^2.1.1",
"atob": "^2.1.2",
"axios": "^1.5.1",
"btoa": "^1.2.1",
"chai": "^4.3.7",
"chai-string": "^1.5.0",
"crypto-js": "^4.1.1",
"handlebars": "^4.7.8",
"json-query": "^2.2.2",
"lodash": "^4.17.21",
"moment": "^2.29.4",
"nanoid": "3.3.4",
"node-fetch": "2.*",
"node-vault": "^0.10.2",
"uuid": "^9.0.0"
}
},
"ajv": {
"version": "8.13.0",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.13.0.tgz",
"integrity": "sha512-PRA911Blj99jR5RMeTunVbNXMF6Lp4vZXnk5GQjcnUWUTsrXtekg/pnmFFI2u/I36Y/2bITGS30GZCXei6uNkA==",
"requires": {
"fast-deep-equal": "^3.1.3",
"json-schema-traverse": "^1.0.0",
"require-from-string": "^2.0.2",
"uri-js": "^4.4.1"
}
},
"fs-extra": {
"version": "10.1.0",
"requires": {
@ -27053,11 +26999,6 @@
"jsonfile": "^6.0.1",
"universalify": "^2.0.0"
}
},
"json-schema-traverse": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="
}
}
},

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