mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-25 16:55:59 +03:00
[PR #4211] [MERGED] feat: duplicate REST/GraphQL collections #4703
Labels
No labels
CodeDay
a11y
browser limited
bug
bug fix
cli
core
critical
design
desktop
discussion
docker
documentation
duplicate
enterprise
feature
feature
fosshack
future
good first issue
hacktoberfest
help wanted
i18n
invalid
major
minor
need information
need testing
not applicable to hoppscotch
not reproducible
pull-request
question
refactor
resolved
sandbox
self-host
spam
stale
testmu
wip
wont fix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hoppscotch#4703
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hoppscotch/hoppscotch/pull/4211
Author: @jamesgeorge007
Created: 7/24/2024
Status: ✅ Merged
Merged: 7/29/2024
Merged by: @jamesgeorge007
Base:
next← Head:feat/duplicate-collection-ui📝 Commits (10+)
80d50e2feat: duplicate REST/GraphQL collectionsc6d2811fix: prevent duplicate collection entry fromuserCollectionCreatedGQL subscriptionb53da4dfix: ensure context menu is dismissed only after the action in team workspace36bf4bbfix: prevent missing children during collection creation27da1d7fix: consistent export format for bulk collection export under teamsf582e95fix: prevent stringifying collection level properties twice at the API levele93c9b5fix: syncing duplicate collections under personal workspace in SH6fa11cdrefactor: leverage helpersc4fb4f0fix: bulk export for collections under cloud team workspacee311d34chore: disableDuplicate collectionaction under personal workspace in SH📊 Changes
26 files changed (+726 additions, -97 deletions)
View changed files
📝
packages/hoppscotch-backend/src/team-collection/team-collection.service.ts(+11 -3)📝
packages/hoppscotch-backend/src/user-collection/user-collection.service.ts(+11 -3)📝
packages/hoppscotch-backend/src/utils.ts(+25 -6)📝
packages/hoppscotch-common/locales/en.json(+2 -1)📝
packages/hoppscotch-common/src/components/collections/Collection.vue(+48 -3)📝
packages/hoppscotch-common/src/components/collections/ImportExport.vue(+6 -22)📝
packages/hoppscotch-common/src/components/collections/MyCollections.vue(+21 -0)📝
packages/hoppscotch-common/src/components/collections/Request.vue(+7 -8)📝
packages/hoppscotch-common/src/components/collections/TeamCollections.vue(+28 -2)📝
packages/hoppscotch-common/src/components/collections/graphql/Collection.vue(+62 -11)📝
packages/hoppscotch-common/src/components/collections/graphql/Folder.vue(+58 -13)📝
packages/hoppscotch-common/src/components/collections/graphql/index.vue(+10 -0)📝
packages/hoppscotch-common/src/components/collections/index.vue(+39 -5)➕
packages/hoppscotch-common/src/helpers/backend/gql/mutations/DuplicateTeamCollection.graphql(+3 -0)📝
packages/hoppscotch-common/src/helpers/backend/helpers.ts(+99 -6)📝
packages/hoppscotch-common/src/helpers/backend/mutations/TeamCollection.ts(+12 -0)📝
packages/hoppscotch-common/src/helpers/teams/TeamCollectionAdapter.ts(+2 -2)📝
packages/hoppscotch-common/src/newstore/collections.ts(+123 -8)📝
packages/hoppscotch-common/src/platform/index.ts(+6 -0)📝
packages/hoppscotch-common/src/services/persistence/validation-schemas/index.ts(+2 -1)...and 6 more files
📄 Description
What's changed
This PR includes the UI changes adding the ability to duplicate REST/GraphQL collections. The context menu for collections (root/child) from the tree will include a new option labelled
Duplicate collection. This will result in a new collection entry within the same hierarchy, effectively cloning the children and retaining the collection level authorization/header properties. Additionally, while the context menu is open, the duplication action can be initiated by pressing thedkey.Closes HFE-491 HFE-545 HFE-547 #2475.
Apart from that, the following issues are patched:
userCollectionCreatedandteamCollectionCreatedGQL subscriptions fired after collection create actions (import, create, duplicate) sent collection-level properties (authorization/headers) applying stringification viaJSON.stringify()multiple times which led to an exception since FE expects it to be parsed viaJSON.parse()in one pass.HoppCollection. Attempting to export collections existing with authorization/headers set and importing them will result in the respective collection properties not getting populated. This is because the export format doesn't conform to the internal data structureHoppCollectionand while importing it fails to parse and goes ahead with the defaults. This also led to the CLI rejecting bulk collection exports from a team workspace - HFE-545teamCollectionAddedGQL subscription on cloud compared to SH where it was fired post-collection create actions. Child collections at all levels get populated under the imported collection or while creating child collections they get synced straightaway via the subscription. This has been patched at the tree level ensuring collection entries received via GQL subscriptions for a parent collection that is not expanded yet doesn't get populated - HFE-547.pkeypress while the context menu is open.Preview
https://github.com/user-attachments/assets/2536c93d-d5b0-4170-846d-fb95286767f7
Changes
~/packages/hoppscotch-backend/*, resolving the issue mentioned above where the collection level properties are stringified multiple times while communicating to FE. A new utility functiontransformCollectionData()under~/src/utils.tsis added for the purpose.i18nstring additions.HoppCollectionand hence a re-import resulting in the collection level properties (authorization/headers) missing and the CLI rejecting it (An issue mentioned as patched above). On this front, thegetTeamCollectionJSON()helper function under~/packages/hoppscotch-common/src/helpers/backend/helpers.tshas been updated to parse the JSON string, transform each entry and return a stringified representation. Also, the case where there are no collections to export is handled at source and returned as aleftcase.DuplicateUserCollection&DuplicateTeamCollectionGQL documents and respective updates integrating the same.duplicateLoadingtoduplicateRequestLoadingsince there's a newduplicateCollectionLoadingprop variant coming in.duplicateCollectiondispatcher function additions undernewstore/collection.tsalong withduplicateRESTCollection&duplicateGQLCollectionhelper functions that are exposed for consumption in the outside world.duplicateCollectionDisabledInPersonalWorkspaceis added. The naming convention is slightly differentpropEnabledto prevent the need for updates at thecentralplatform level config.Note to reviewers
~/packages/hoppscotch-selfhost-web/*can be ignored for now.selfhost-desktopwill be added alongside revisiting the syncing issue under personal workspace in SH.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.