feat: Add the ability to optionally update an existing collection on import #3615
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a new confirmation dialog that allows for a collection import to "update" an existing collection, instead of having this operation always fail as it did before.
Currently, importing a collection that already has a matching directory causes an immediate error. Now, that error is caught and the user will be prompted if they would like to add to the existing collection:
If the user chooses to continue with the import, the existing
import-collection
logic will be run in a newupdateExistingCollection
mode, which creates necessary new directories but also traverses existing directories to add items that were parsed from the input file to existing directories.When working with an OpenAPI spec that is frequently updated, this workflow allows users to add new endpoints from newer versions to an existing collection while preserving their environments and settings. This partially resolves the need detailed in #1354.
Future contributions could extend on this feature in a variety of ways:
handleConfirmCollectionImportUpdate
that could check for duplicate requests across the collection, regardless of folder locationpackages/bruno-app/src/components/ConfirmCollectionImportUpdate
that would allow users to "replace existing endpoints" as well as "add new endpoints."I'm sure there are more ways that this could be built on in the future - this feature itself is fairly simple, but my hope is that it may spawn additional future contributions (from myself, or others) by breaking the assumption that "once a collection is imported, that directory can never be imported into again."
Contribution Checklist: