Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(workspaces): personal workspace provider additions for REST environments #4113

Conversation

jamesgeorge007
Copy link
Member

@jamesgeorge007 jamesgeorge007 commented Jun 11, 2024

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.

@jamesgeorge007 jamesgeorge007 force-pushed the refactor/workspaces-personal-provider-additions branch 18 times, most recently from 55147fe to 6e7b46c Compare June 13, 2024 13:40
@jamesgeorge007 jamesgeorge007 force-pushed the refactor/workspaces-personal-provider-additions branch 2 times, most recently from 23861b8 to 995bd55 Compare June 14, 2024 08:31
Remove redundant issued handle updates happening in the `create(REST/GQL)Request` methods since it is accounted for via returning `getRequestHandle`. This led to dissociating the handle undergoing updates at the service level with that of the UI.
@jamesgeorge007 jamesgeorge007 force-pushed the refactor/workspaces-personal-provider-additions branch from 995bd55 to bd6b76d Compare June 14, 2024 08:35
Replace computing authorization/headers with the respective provider view based method.
…ervice`

To be replaced with `workspaceService` once the support for teams is brought about.
@jamesgeorge007 jamesgeorge007 force-pushed the refactor/workspaces-personal-provider-additions branch 4 times, most recently from 0c54896 to 427bc5f Compare June 17, 2024 13:25
@jamesgeorge007 jamesgeorge007 force-pushed the refactor/workspaces-personal-provider-additions branch from 33cc7d9 to 98a9f0d Compare June 18, 2024 17:27
@jamesgeorge007 jamesgeorge007 marked this pull request as ready for review June 18, 2024 17:31
@jamesgeorge007 jamesgeorge007 changed the title refactor(workspaces): personal workspace provider additions for GQL collections & environments refactor(workspaces): personal workspace provider additions for GQL collections & REST environments Jun 19, 2024
@jamesgeorge007 jamesgeorge007 force-pushed the refactor/workspaces-personal-provider-additions branch 4 times, most recently from ec20afa to df0c9ee Compare June 19, 2024 14:09
… and reopened

Remove the issued request handle under tabs while closing.
@jamesgeorge007 jamesgeorge007 force-pushed the refactor/workspaces-personal-provider-additions branch from df0c9ee to d31bed7 Compare June 19, 2024 14:09
@jamesgeorge007 jamesgeorge007 force-pushed the refactor/workspaces-personal-provider-additions branch from d48a184 to 18c7d2e Compare June 19, 2024 14:30
@jamesgeorge007 jamesgeorge007 force-pushed the refactor/workspaces-personal-provider-additions branch 3 times, most recently from 17b0690 to fe7a56d Compare June 20, 2024 18:32
@jamesgeorge007 jamesgeorge007 force-pushed the refactor/workspaces-personal-provider-additions branch from fe7a56d to 7c11bd3 Compare June 20, 2024 18:33
@jamesgeorge007 jamesgeorge007 changed the title refactor(workspaces): personal workspace provider additions for GQL collections & REST environments refactor(workspaces): personal workspace provider additions for REST environments Jun 20, 2024
@jamesgeorge007 jamesgeorge007 merged commit 8eb69ca into refactor/workspaces Jun 21, 2024
@jamesgeorge007 jamesgeorge007 deleted the refactor/workspaces-personal-provider-additions branch June 21, 2024 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants