[PR #4113] [MERGED] refactor(workspaces): personal workspace provider additions for REST environments #4674

Closed
opened 2026-03-17 02:11:18 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/4113
Author: @jamesgeorge007
Created: 6/11/2024
Status: Merged
Merged: 6/21/2024
Merged by: @jamesgeorge007

Base: refactor/workspacesHead: refactor/workspaces-personal-provider-additions


📝 Commits (10+)

  • f7e5d7e refactor: port GQL related functionality to the new architecture
  • bd6b76d fix: UI not reflecting underlying service level changes immediately
  • de9fe49 chore: ensure handle for the collection being updated/removed are updated straightaway
  • 75b1ca6 refactor: enable GQL related functionality in Save as modal
  • 6481d83 refactor: invoke GQL provider methods via personalWorkspaceProviderService
  • e1260d8 refactor: port REST environments related functionality to the new architecture
  • 65e1a81 chore: cleanup
  • 98a9f0d refactor: dedicated methods for REST/GQL
  • 27bffaa refactor: eliminate redundancy
  • b2a1ae9 refactor: perform request duplication via the create request provider method

📊 Changes

35 files changed (+1792 additions, -564 deletions)

View changed files

📝 packages/hoppscotch-common/locales/en.json (+3 -2)
📝 packages/hoppscotch-common/src/components.d.ts (+4 -0)
📝 packages/hoppscotch-common/src/components/collections/Collection.vue (+2 -2)
📝 packages/hoppscotch-common/src/components/collections/ImportExport.vue (+5 -7)
📝 packages/hoppscotch-common/src/components/collections/MyCollections.vue (+3 -3)
📝 packages/hoppscotch-common/src/components/collections/Properties.vue (+11 -4)
📝 packages/hoppscotch-common/src/components/collections/SaveRequest.vue (+92 -82)
📝 packages/hoppscotch-common/src/components/collections/TeamCollections.vue (+3 -3)
📝 packages/hoppscotch-common/src/components/environments/ImportExport.vue (+73 -42)
📝 packages/hoppscotch-common/src/components/environments/index.vue (+226 -8)
📝 packages/hoppscotch-common/src/components/environments/my/Details.vue (+29 -52)
📝 packages/hoppscotch-common/src/components/environments/my/Environment.vue (+81 -27)
📝 packages/hoppscotch-common/src/components/environments/my/index.vue (+25 -6)
📝 packages/hoppscotch-common/src/components/environments/teams/Details.vue (+11 -0)
📝 packages/hoppscotch-common/src/components/environments/teams/Environment.vue (+9 -0)
📝 packages/hoppscotch-common/src/components/environments/teams/index.vue (+13 -0)
📝 packages/hoppscotch-common/src/components/http/Sidebar.vue (+0 -1)
📝 packages/hoppscotch-common/src/components/new-collections/index.vue (+6 -2)
📝 packages/hoppscotch-common/src/components/new-collections/rest/index.vue (+77 -44)
📝 packages/hoppscotch-common/src/helpers/adapters/WorkspaceRESTCollectionTreeAdapter.ts (+1 -1)

...and 15 more files

📄 Description

Description

This PR ports GraphQL collections & REST environments to the new handles-based architecture.

Closes HFE-525.

Changes

  • Adds the following methods under the personal workspace provider corresponding to the abovementioned features.

    getRESTEnvironmentsView(
      workspaceHandle: Handle<Workspace>
    ): Promise<E.Either<never, Handle<RESTEnvironmentsView>>>
    
    createRESTEnvironment(
      workspaceHandle: Handle<Workspace>,
      newEnvironment: Partial<Environment> & { name: string }
    ): Promise<E.Either<unknown, Handle<WorkspaceEnvironment>>>
    duplicateRESTEnvironment(
      environmentHandle: Handle<WorkspaceEnvironment>
    ): Promise<E.Either<unknown, Handle<WorkspaceEnvironment>>>
    updateRESTEnvironment(
      environmentHandle: Handle<WorkspaceEnvironment>,
      updatedEnvironment: Partial<Environment>
    ): Promise<E.Either<unknown, void>>
    removeRESTEnvironment(
      environmentHandle: Handle<WorkspaceEnvironment>
    ): Promise<E.Either<unknown, void>>
    
    importRESTEnvironments(
      workspaceHandle: Handle<Workspace>,
      environments: Environment[]
    ): Promise<E.Either<unknown, void>>
    exportRESTEnvironments(
      workspaceHandle: Handle<Workspace>
    ): Promise<E.Either<unknown, void>>
    exportRESTEnvironment(
      environmentHandle: Handle<WorkspaceEnvironment>
    ): Promise<E.Either<unknown, void>>
    
  • Introduce restEnvironmentState member at the PersonalWorkspaceProviderService level holding the environment store state.

  • The getCollectionHandle & getRequestHandle methods are renamed to getRESTCollectionHandle & getRESTRequestHandle respectively.

  • Environments-related component updates moving to the provider API methods. Separate components for personal/team workspaces are kept as is for now and events are emitted corresponding to the action performed (create, edit, etc) bound to the respective provider method at the base component level (Environments).

  • Introduce the RESTEnvironmentsView type corresponding to the list of environments under a workspace (return type of the getRESTEnvironmentsView method).

  • Perform request duplication via the provider method for creating a request.

  • Includes a fix for the case when the request from the collection tree and the one open under a tab dissociates when closed and reopened. The corresponding request handle is removed from the issued handles list maintained at the PersonalWorkspaceProvider service level via the new setIssuedHandles method when a tab is closed. A new helper function updateIssuedHandlesForPersonalWorkspace is added under ~/helpers/tab/index.ts abstracting the business logic for use in the REST / page (to be extended to GQL in the future). Also, while invalidating the affected request handles while removing a collection/request, the respective handles are removed from issuedHandles to prevent having unnecessary invalidated handle { type: "invalid", reason: <string> } entries kept throughout.

Checks

  • My pull request adheres to the code style of this project
  • All the tests have passed

Note to reviewers

The changes aimed at porting GQL collections are reverted for the time being since a few issues were encountered while testing the flows e2e - To be revisited.

REST prefixes are added to certain methods. Dedicated methods will be introduced once GQL collections-related functionality is ported with future-proofing in mind. Although the functionality is almost similar with the store update approach being the difference, they are kept distinct to account for the increase in scope (The current scope of workspace refactor only deals with the store/data source level) that might lead to diverging business logic.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/4113 **Author:** [@jamesgeorge007](https://github.com/jamesgeorge007) **Created:** 6/11/2024 **Status:** ✅ Merged **Merged:** 6/21/2024 **Merged by:** [@jamesgeorge007](https://github.com/jamesgeorge007) **Base:** `refactor/workspaces` ← **Head:** `refactor/workspaces-personal-provider-additions` --- ### 📝 Commits (10+) - [`f7e5d7e`](https://github.com/hoppscotch/hoppscotch/commit/f7e5d7e4a81842f53c543c914b86f4c390cd8bef) refactor: port GQL related functionality to the new architecture - [`bd6b76d`](https://github.com/hoppscotch/hoppscotch/commit/bd6b76d38ac768d01fe0401676ffd4440086cc64) fix: UI not reflecting underlying service level changes immediately - [`de9fe49`](https://github.com/hoppscotch/hoppscotch/commit/de9fe4938425d81a5e07506eb4577e25271405db) chore: ensure handle for the collection being updated/removed are updated straightaway - [`75b1ca6`](https://github.com/hoppscotch/hoppscotch/commit/75b1ca615d6f2add2efa2036f15d28b11131f87f) refactor: enable GQL related functionality in `Save as` modal - [`6481d83`](https://github.com/hoppscotch/hoppscotch/commit/6481d830f44ed4637d7b6c5cc62a26a976433812) refactor: invoke GQL provider methods via `personalWorkspaceProviderService` - [`e1260d8`](https://github.com/hoppscotch/hoppscotch/commit/e1260d80a6546acf150522e657b91daccb1ae118) refactor: port REST environments related functionality to the new architecture - [`65e1a81`](https://github.com/hoppscotch/hoppscotch/commit/65e1a8114af41403e1dcb068e864ad44a75d6c65) chore: cleanup - [`98a9f0d`](https://github.com/hoppscotch/hoppscotch/commit/98a9f0dd27f44e443d6136aeb8aa588a0bcd1f12) refactor: dedicated methods for REST/GQL - [`27bffaa`](https://github.com/hoppscotch/hoppscotch/commit/27bffaac4690ad64f1b80116c831b98fecca2e31) refactor: eliminate redundancy - [`b2a1ae9`](https://github.com/hoppscotch/hoppscotch/commit/b2a1ae9955c07aea2581f559e85f8e581597a2a5) refactor: perform request duplication via the create request provider method ### 📊 Changes **35 files changed** (+1792 additions, -564 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-common/locales/en.json` (+3 -2) 📝 `packages/hoppscotch-common/src/components.d.ts` (+4 -0) 📝 `packages/hoppscotch-common/src/components/collections/Collection.vue` (+2 -2) 📝 `packages/hoppscotch-common/src/components/collections/ImportExport.vue` (+5 -7) 📝 `packages/hoppscotch-common/src/components/collections/MyCollections.vue` (+3 -3) 📝 `packages/hoppscotch-common/src/components/collections/Properties.vue` (+11 -4) 📝 `packages/hoppscotch-common/src/components/collections/SaveRequest.vue` (+92 -82) 📝 `packages/hoppscotch-common/src/components/collections/TeamCollections.vue` (+3 -3) 📝 `packages/hoppscotch-common/src/components/environments/ImportExport.vue` (+73 -42) 📝 `packages/hoppscotch-common/src/components/environments/index.vue` (+226 -8) 📝 `packages/hoppscotch-common/src/components/environments/my/Details.vue` (+29 -52) 📝 `packages/hoppscotch-common/src/components/environments/my/Environment.vue` (+81 -27) 📝 `packages/hoppscotch-common/src/components/environments/my/index.vue` (+25 -6) 📝 `packages/hoppscotch-common/src/components/environments/teams/Details.vue` (+11 -0) 📝 `packages/hoppscotch-common/src/components/environments/teams/Environment.vue` (+9 -0) 📝 `packages/hoppscotch-common/src/components/environments/teams/index.vue` (+13 -0) 📝 `packages/hoppscotch-common/src/components/http/Sidebar.vue` (+0 -1) 📝 `packages/hoppscotch-common/src/components/new-collections/index.vue` (+6 -2) 📝 `packages/hoppscotch-common/src/components/new-collections/rest/index.vue` (+77 -44) 📝 `packages/hoppscotch-common/src/helpers/adapters/WorkspaceRESTCollectionTreeAdapter.ts` (+1 -1) _...and 15 more files_ </details> ### 📄 Description ### Description This PR ports GraphQL collections & REST environments to the new handles-based architecture. Closes HFE-525. ### Changes - Adds the following methods under the personal workspace provider corresponding to the abovementioned features. ```js getRESTEnvironmentsView( workspaceHandle: Handle<Workspace> ): Promise<E.Either<never, Handle<RESTEnvironmentsView>>> createRESTEnvironment( workspaceHandle: Handle<Workspace>, newEnvironment: Partial<Environment> & { name: string } ): Promise<E.Either<unknown, Handle<WorkspaceEnvironment>>> duplicateRESTEnvironment( environmentHandle: Handle<WorkspaceEnvironment> ): Promise<E.Either<unknown, Handle<WorkspaceEnvironment>>> updateRESTEnvironment( environmentHandle: Handle<WorkspaceEnvironment>, updatedEnvironment: Partial<Environment> ): Promise<E.Either<unknown, void>> removeRESTEnvironment( environmentHandle: Handle<WorkspaceEnvironment> ): Promise<E.Either<unknown, void>> importRESTEnvironments( workspaceHandle: Handle<Workspace>, environments: Environment[] ): Promise<E.Either<unknown, void>> exportRESTEnvironments( workspaceHandle: Handle<Workspace> ): Promise<E.Either<unknown, void>> exportRESTEnvironment( environmentHandle: Handle<WorkspaceEnvironment> ): Promise<E.Either<unknown, void>> ``` - Introduce `restEnvironmentState` member at the `PersonalWorkspaceProviderService` level holding the environment store state. - The `getCollectionHandle` & `getRequestHandle` methods are renamed to `getRESTCollectionHandle` & `getRESTRequestHandle` respectively. - Environments-related component updates moving to the provider API methods. Separate components for personal/team workspaces are kept as is for now and events are emitted corresponding to the action performed (create, edit, etc) bound to the respective provider method at the base component level (`Environments`). - Introduce the `RESTEnvironmentsView` type corresponding to the list of environments under a workspace (return type of the `getRESTEnvironmentsView` method). - Perform request duplication via the provider method for creating a request. - Includes a fix for the case when the request from the collection tree and the one open under a tab dissociates when closed and reopened. The corresponding request handle is removed from the issued handles list maintained at the `PersonalWorkspaceProvider` service level via the new `setIssuedHandles` method when a tab is closed. A new helper function `updateIssuedHandlesForPersonalWorkspace` is added under `~/helpers/tab/index.ts` abstracting the business logic for use in the REST `/` page (to be extended to GQL in the future). Also, while invalidating the affected request handles while removing a collection/request, the respective handles are removed from `issuedHandles` to prevent having unnecessary invalidated handle `{ type: "invalid", reason: <string> }` entries kept throughout. ### Checks - [x] My pull request adheres to the code style of this project - [x] All the tests have passed ### Note to reviewers The changes aimed at porting GQL collections are reverted for the time being since a few issues were encountered while testing the flows e2e - To be revisited. `REST` prefixes are added to certain methods. Dedicated methods will be introduced once GQL collections-related functionality is ported with future-proofing in mind. Although the functionality is almost similar with the store update approach being the difference, they are kept distinct to account for the increase in scope (The current scope of workspace refactor only deals with the store/data source level) that might lead to diverging business logic. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:11:18 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#4674
No description provided.