mirror of
https://github.com/hoppscotch/hoppscotch.git
synced 2026-04-26 01:06:00 +03:00
[PR #3859] [MERGED] refactor(workspaces): provider additions for collections under personal workspace #4559
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#4559
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/3859
Author: @jamesgeorge007
Created: 2/26/2024
Status: ✅ Merged
Merged: 5/22/2024
Merged by: @AndrewBastin
Base:
refactor/workspaces← Head:refactor/workspaces-collection-provider-additions📝 Commits (10+)
175ab50refactor: port import/export functionalitycfc726drefactor: port collection move/reorderc2e4ea5refactor: provider method definitions for collection reorder/movea797a04refactor: unify markup7542d23refactor: integrate provider API methods for collection move/reorder84078e0fix: associate requests under tabs while reordering collections8e44639refactor: view based implementation for search in personal workspace726a816refactor: add new tree adapter corresponding to search7c17c22refactor: integrate REST search collection adaptera4754dbfix: update save context for affected requests with collection move/reorder📊 Changes
40 files changed (+8207 additions, -1263 deletions)
View changed files
📝
packages/hoppscotch-common/src/components/app/Header.vue(+5 -9)📝
packages/hoppscotch-common/src/components/collections/ImportExport.vue(+83 -33)📝
packages/hoppscotch-common/src/components/collections/SaveRequest.vue(+8 -21)📝
packages/hoppscotch-common/src/components/collections/graphql/ImportExport.vue(+3 -3)📝
packages/hoppscotch-common/src/components/environments/ImportExport.vue(+3 -3)📝
packages/hoppscotch-common/src/components/http/Request.vue(+27 -19)📝
packages/hoppscotch-common/src/components/http/RequestTab.vue(+31 -5)📝
packages/hoppscotch-common/src/components/new-collections/index.vue(+9 -30)📝
packages/hoppscotch-common/src/components/new-collections/rest/Collection.vue(+213 -6)📝
packages/hoppscotch-common/src/components/new-collections/rest/Request.vue(+145 -2)📝
packages/hoppscotch-common/src/components/new-collections/rest/index.vue(+1341 -347)📝
packages/hoppscotch-common/src/components/workspace/Current.vue(+4 -2)📝
packages/hoppscotch-common/src/components/workspace/PersonalWorkspaceSelector.vue(+5 -4)📝
packages/hoppscotch-common/src/components/workspace/TestWorkspaceSelector.vue(+5 -4)➕
packages/hoppscotch-common/src/helpers/adapters/WorkspaceRESTCollectionSearchTreeAdapter.ts(+92 -0)📝
packages/hoppscotch-common/src/helpers/adapters/WorkspaceRESTCollectionTreeAdapter.ts(+23 -18)📝
packages/hoppscotch-common/src/helpers/collection/collection.ts(+200 -162)📝
packages/hoppscotch-common/src/helpers/collection/request.ts(+57 -10)📝
packages/hoppscotch-common/src/helpers/import-export/export/index.ts(+17 -18)➖
packages/hoppscotch-common/src/helpers/import-export/export/myCollections.ts(+0 -5)...and 20 more files
📄 Description
Description
This PR ports the existing implementation for import/export, move/reorder, and search corresponding to collections under personal workspace to the provider-based new architecture. It also adds support for searching collections at any depth.
We're also moving to a new inert handle-based approach (proposed by @AndrewBastin). Previously, reactive handles were sent around everywhere with the provider methods expecting the same. This resulted in issues with the reactivity behavior mostly with the issued handle updates not getting reflected in the issued handles since the reference was coming up differently and the value getting automatically unwrapped at places. In the new approach, while obtaining a handle it's just a plain object and the underlying reactive value can be accessed later in time.
Personal workspaces have dynamic path-based IDs (
0/0,2/1/0, etc) based on the position (levels are separated by/, single digit represents root collections) of a resource (collection/request) in the tree. Previously to keep the association between requests open under tabs and the ones from the tree, every time the resultant IDs were computed manually after the action. Say, a request at a deeply nested collection is moved to a different location, each tab has information about the ID path of the request being open from the tree, and necessary updates are made to the above information based on the action computed from the source and destination IDs.With the new handle-based system, since handles are reactive references to a resource, we keep a list of issued handles (obtained while creating/selecting a request,). Each tab keeps a request handle reference under
tab.document.saveContext, and whenever an action requiring updates to the IDs happens, the corresponding handle is found from the compiled list of issued handles and the respective ID (collectionID,requestID) is updated accordingly. The updates are streamed to the tabs via the reactive behavior. The same approach is used for toggling the dirty state associated with requests when any parent-level collection is deleted or if the request itself is deleted.Closes HFE-437.
Changes
Adds the following methods under the personal workspace provider corresponding to the abovementioned features.
Migrate to the new inert handle-based approach.
Move to handle based updates to keep the association between requests from the collection tree and the ones open under tabs.
Additions to the
NewCollectionsRestcomponent accounting for the ported features mentioned above. The business logic associated with updates to the store for each action resides in the provider definition for each workspace invoked from the component level via the new workspace service implementation.Move the markup and associated logic wrt showing the active workspace and search from the parent level
NewCollectionscomponent to `NewCollectionsRest.Port the collection/request move/reorder logic (markup, events, handlers, etc) into the
NewCollectionsRestCollectionandNewCollectionsRestRequestcomponents.Introduce a new tree adapter to render the tree with search results. This was required since the existing adapter for rendering the default collection tree operates based on the supplied workspace handle. While, for search, is to be based on the initial data provided to be filtered based on.
The
getChildrenmethod to be implemented by the tree adapter now takes an additional argument signifying the type of the incoming node (collection/request). This acts as a safeguard to prevent errors with operations specific to a collection node.Remove
collectionIDfrom information persisted under the REST tabsaveContextsincerequestIDaccounts for it.initializeDownloadCollectionhelper under~/packages/hoppscotch-common/src/helpers/import-export/exportis given an agnosic nameinitializeDownloadFilesince it gets consumed in different contexts. The definition is updated to point to the platform definition to ensure the underlying platform defines the behavior.New helper functions under ~/packages/hoppscotch-common/src/services/new-workspace/helpers.ts to abstract common logic consumed in the provider method definitions.
Formalise a system for creating a persistable handle reference that can be loaded back again - Persist request handles at runtime, write only the unique IDs (provider, workspace & request IDs) required to restore the handle to
localStorage. Load the request handle back via the IDs at runtime.Introduce writable handles to signify updates to other handle references when an action is performed. For instance, a request from the collection tree is deleted and at the same time the handle issued is updated thereby the request handle persisted under tab
saveContextis aware of the update (handle type is set toinvalid) and toggles the dirty state in this case.Adds a test suite for the
PersonalWorkspaceProviderServicewith associated mocks and helpers.Checks
Note to reviewers
Switching to a team workspace will result in exceptions at the moment and can be ignored. This PR includes changes specific to the personal workspace. The existing provider definition for teams
test.workspace.tsis meant as a placeholder to be removed once the teams-side implementation is brought in.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.