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

[Workspace] Add a workspace client in workspace plugin #6094

Merged

Conversation

SuZhou-Joe
Copy link
Member

@SuZhou-Joe SuZhou-Joe commented Mar 8, 2024

Description

This PR mainly introduces a workspace client to perform CRUD operations request to server side and gives some useful utils function.

Issues Resolved

closes #6093

Screenshot

As the changes only happen in a frontend client, there is no screenshot for that.

Testing the changes

  • Clone the branch and enable workspace in yml file.
  • Open the file src/plugins/workspace/public/plugin.ts
  • Perform some operations through the initialized workspaceClient like: workspaceClient.create, workspaceClient.delete and so on, it should making http request to server accordingly in browser side.

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Copy link

codecov bot commented Mar 8, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 16 lines in your changes are missing coverage. Please review.

Project coverage is 67.14%. Comparing base (362ab1e) to head (65fc363).

Files Patch % Lines
src/plugins/workspace/public/workspace_client.ts 72.41% 10 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6094      +/-   ##
==========================================
+ Coverage   67.13%   67.14%   +0.01%     
==========================================
  Files        3324     3326       +2     
  Lines       64330    64394      +64     
  Branches    10347    10358      +11     
==========================================
+ Hits        43188    43239      +51     
- Misses      18618    18626       +8     
- Partials     2524     2529       +5     
Flag Coverage Δ
Linux_1 31.73% <75.00%> (+0.06%) ⬆️
Linux_2 55.23% <ø> (ø)
Linux_3 44.71% <ø> (+<0.01%) ⬆️
Linux_4 35.08% <ø> (ø)
Windows_1 31.75% <75.00%> (+0.06%) ⬆️
Windows_2 55.20% <ø> (ø)
Windows_3 44.73% <ø> (ø)
Windows_4 35.08% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

ZilongX
ZilongX previously approved these changes Mar 8, 2024
* Check if provided workspace id exists,
* update the currentWorkspaceId$ if it exists.
*/
public async enterWorkspace(id: string): Promise<IResponse<null>> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it better to call it updateCurrentWorkspace then? Not sure if anyone using it would understand what does enterWorkspace mean if not looking at the code or doc

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currentWorkspace$ will be updated as a derived value in https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/core/public/workspace/workspaces_service.ts#L56. So for the workspace client it does not need to update explicitly. Would it be better that we update the doc to like
Check if provided workspace id exists in the storage and update core.currentWorkspaceId$ if it exists?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when will we use this method? is it when user tries to go inside a workspace?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will use that in setup lifeCycle of workspace plugin when user visit the page with pattern match /w/${workspaceId}/xxx, which will validate if the workspaceId exists and change the currentWorkspaceId$ if it does.

src/plugins/workspace/public/workspace_client.ts Outdated Show resolved Hide resolved
src/plugins/workspace/public/workspace_client.ts Outdated Show resolved Hide resolved
src/plugins/workspace/public/workspace_client.ts Outdated Show resolved Hide resolved
@SuZhou-Joe SuZhou-Joe force-pushed the feature/workspace-public-client branch from 56ba159 to 56d4113 Compare March 9, 2024 01:48
@SuZhou-Joe
Copy link
Member Author

@BionIT Could you please take a look here to see if all the comments have been addressed?

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
@SuZhou-Joe SuZhou-Joe force-pushed the feature/workspace-public-client branch from 866d2e0 to 65fc363 Compare March 12, 2024 02:39
* Check if provided workspace id exists,
* update the currentWorkspaceId$ if it exists.
*/
public async enterWorkspace(id: string): Promise<IResponse<null>> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when will we use this method? is it when user tries to go inside a workspace?

@SuZhou-Joe SuZhou-Joe merged commit 4b89ad0 into opensearch-project:main Mar 12, 2024
68 of 69 checks passed
Hailong-am pushed a commit to Hailong-am/OpenSearch-Dashboards that referenced this pull request Mar 12, 2024
…oject#6094)

* feat: add comment

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update unit test

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: add CHANGELOG

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize comment

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize comment

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: Hailong Cui <ihailong@amazon.com>
ruanyl pushed a commit that referenced this pull request Mar 13, 2024
* Add workspacePluginSetup type

Signed-off-by: Hailong Cui <ihailong@amazon.com>

* add fakenews.co to .lycheeexclude

Signed-off-by: Hailong Cui <ihailong@amazon.com>

* [Workspace] Add a workspace client in workspace plugin (#6094)

* feat: add comment

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update unit test

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: add CHANGELOG

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize comment

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize comment

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: Hailong Cui <ihailong@amazon.com>

* Revert "add fakenews.co to .lycheeexclude"

This reverts commit 55f6344.

Signed-off-by: Hailong Cui <ihailong@amazon.com>

* Add WorkspacePluginStart

Signed-off-by: Hailong Cui <ihailong@amazon.com>

---------

Signed-off-by: Hailong Cui <ihailong@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Co-authored-by: SuZhou-Joe <suzhou@amazon.com>
SuZhou-Joe added a commit to SuZhou-Joe/OpenSearch-Dashboards that referenced this pull request Mar 22, 2024
…oject#6094)

* feat: add comment

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update unit test

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: add CHANGELOG

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize comment

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize comment

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
SuZhou-Joe added a commit to ruanyl/OpenSearch-Dashboards that referenced this pull request Mar 25, 2024
…oject#6094) (#308)

* feat: add comment



* feat: update unit test



* feat: add CHANGELOG



* feat: optimize comment



* feat: optimize comment



* feat: optimize code



* feat: optimize code



---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 11, 2024
* feat: add comment

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update unit test

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: add CHANGELOG

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize comment

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize comment

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
(cherry picked from commit 4b89ad0)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
SuZhou-Joe added a commit that referenced this pull request Apr 12, 2024
…#6409)

* [Workspace] Add a workspace client in workspace plugin (#6094)

* feat: add comment

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update unit test

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: add CHANGELOG

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize comment

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize comment

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
(cherry picked from commit 4b89ad0)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

* fix: unit test

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Apr 16, 2024
* Add workspacePluginSetup type

Signed-off-by: Hailong Cui <ihailong@amazon.com>

* add fakenews.co to .lycheeexclude

Signed-off-by: Hailong Cui <ihailong@amazon.com>

* [Workspace] Add a workspace client in workspace plugin (#6094)

* feat: add comment

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: update unit test

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: add CHANGELOG

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize comment

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize comment

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

* feat: optimize code

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: Hailong Cui <ihailong@amazon.com>

* Revert "add fakenews.co to .lycheeexclude"

This reverts commit 55f6344.

Signed-off-by: Hailong Cui <ihailong@amazon.com>

* Add WorkspacePluginStart

Signed-off-by: Hailong Cui <ihailong@amazon.com>

---------

Signed-off-by: Hailong Cui <ihailong@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Co-authored-by: SuZhou-Joe <suzhou@amazon.com>
(cherry picked from commit 9cdc7c9)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
SuZhou-Joe added a commit that referenced this pull request Apr 16, 2024
* Add workspacePluginSetup type



* add fakenews.co to .lycheeexclude



* [Workspace] Add a workspace client in workspace plugin (#6094)

* feat: add comment



* feat: update unit test



* feat: add CHANGELOG



* feat: optimize comment



* feat: optimize comment



* feat: optimize code



* feat: optimize code



---------




* Revert "add fakenews.co to .lycheeexclude"

This reverts commit 55f6344.



* Add WorkspacePluginStart



---------




(cherry picked from commit 9cdc7c9)

Signed-off-by: Hailong Cui <ihailong@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: SuZhou-Joe <suzhou@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Workspace] Add a client in public side of workspace plugin
4 participants