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]Validate features parameter in workspace create and update API #7884

Conversation

wanglam
Copy link
Contributor

@wanglam wanglam commented Aug 28, 2024

Description

This PR is for adding validate features field logic in workspace create and update API to align with the workspace create and update form. In current implementation, each workspace should have one use case.

Issues Resolved

#7907

Screenshot

No UI changes

Testing the changes

Prepare

  • Clone branch code and run yarn osd bootstrap --single-version ignore
  • Add below configs in config/opensearch_dashboards.yml
savedObjects.permission.enabled: true
workspace.enabled: true
uiSettings:
  overrides:
    'home:useNewHomePage': true
  • Run yarn start --no-base-path

Test with UI

  • Login and visit workspace create page
  • Click "Create workspace" button, the workspace should be created successfully
  • Page will redirect to the workspace detail page
  • Click edit button, add some description, click "Save changes", the workspace should be updated.

Test features parameter validation

Can reference with unit test files: src/plugins/workspace/server/routes/index.test.ts

Changelog

  • feat: [Workspace]Validate features parameter in workspace create and update API

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 Aug 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.33%. Comparing base (76d7a8b) to head (34c6f8d).
Report is 120 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7884      +/-   ##
==========================================
- Coverage   64.33%   64.33%   -0.01%     
==========================================
  Files        3676     3677       +1     
  Lines       81196    81206      +10     
  Branches    12944    12946       +2     
==========================================
+ Hits        52235    52241       +6     
  Misses      25751    25751              
- Partials     3210     3214       +4     
Flag Coverage Δ
Linux_1 30.74% <100.00%> (+0.48%) ⬆️
Linux_2 56.19% <ø> (ø)
Linux_3 40.60% <ø> (-0.01%) ⬇️
Linux_4 31.40% <ø> (ø)
Windows_1 30.76% <100.00%> (+0.46%) ⬆️
Windows_2 56.14% <ø> (ø)
Windows_3 40.61% <ø> (ø)
Windows_4 31.40% <ø> (ø)

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.

@wanglam wanglam changed the title [Workspace]Validate features field in workspace create and update API [Workspace]Validate features parameter in workspace create and update API Aug 28, 2024
ruanyl
ruanyl previously approved these changes Aug 30, 2024
Comment on lines 49 to 53
'all',
'observability',
'security-analytics',
'analytics',
'search',
Copy link
Member

Choose a reason for hiding this comment

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

Can we get the ids from default_nav_group.ts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, I got an error Unexpected path "../../../../core/utils" imported in restricted zone. Plugins may only import from src/core/server and src/core/public @osd/eslint/no-restricted-paths when commit changes . But after I change to import { DEFAULT_NAV_GROUPS } from '../../../../core/public';, the commit goes well. Will update this.

SuZhou-Joe
SuZhou-Joe previously approved these changes Aug 30, 2024
@SuZhou-Joe SuZhou-Joe merged commit 76de9a3 into opensearch-project:main Aug 30, 2024
67 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 128

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-7884-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 76de9a30abece503cecd7ce355a8c9bacbfabcff
# Push it to GitHub
git push --set-upstream origin backport/backport-7884-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-7884-to-2.x.

opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 30, 2024
… API (#7884)

* Add validate for features field in workspace create and update API

Signed-off-by: Lin Wang <[email protected]>

* Changeset file for PR #7884 created/updated

* Changeset file for PR #7884 created/updated

* Move router outside align with other plugins

Signed-off-by: Lin Wang <[email protected]>

* Add ut and fix integration tests

Signed-off-by: Lin Wang <[email protected]>

* Import use case id from default nav groups

Signed-off-by: Lin Wang <[email protected]>

* Fix workspace routes UT

Signed-off-by: Lin Wang <[email protected]>

* Share feature config generator between publicn and server

Signed-off-by: Lin Wang <[email protected]>

* Fix osd server crashed due to import from public

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit 76de9a3)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
wanglam added a commit to wanglam/OpenSearch-Dashboards that referenced this pull request Sep 4, 2024
… API (opensearch-project#7884)

* Add validate for features field in workspace create and update API

Signed-off-by: Lin Wang <[email protected]>

* Changeset file for PR opensearch-project#7884 created/updated

* Changeset file for PR opensearch-project#7884 created/updated

* Move router outside align with other plugins

Signed-off-by: Lin Wang <[email protected]>

* Add ut and fix integration tests

Signed-off-by: Lin Wang <[email protected]>

* Import use case id from default nav groups

Signed-off-by: Lin Wang <[email protected]>

* Fix workspace routes UT

Signed-off-by: Lin Wang <[email protected]>

* Share feature config generator between publicn and server

Signed-off-by: Lin Wang <[email protected]>

* Fix osd server crashed due to import from public

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
SuZhou-Joe pushed a commit that referenced this pull request Sep 4, 2024
* [Workspace]Validate features parameter in workspace create and update API (#7884)

* Add validate for features field in workspace create and update API

Signed-off-by: Lin Wang <[email protected]>

* Changeset file for PR #7884 created/updated

* Changeset file for PR #7884 created/updated

* Move router outside align with other plugins

Signed-off-by: Lin Wang <[email protected]>

* Add ut and fix integration tests

Signed-off-by: Lin Wang <[email protected]>

* Import use case id from default nav groups

Signed-off-by: Lin Wang <[email protected]>

* Fix workspace routes UT

Signed-off-by: Lin Wang <[email protected]>

* Share feature config generator between publicn and server

Signed-off-by: Lin Wang <[email protected]>

* Fix osd server crashed due to import from public

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>

* [Workspace]Fix dynamicConfigServiceMock import path in workspace routes UT (#7954)

* Fix dynamicConfigServiceMock import path in workspace routes UT

Signed-off-by: Lin Wang <[email protected]>

* Changeset file for PR #7954 created/updated

---------

Signed-off-by: Lin Wang <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>

---------

Signed-off-by: Lin Wang <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
opensearch-trigger-bot bot pushed a commit that referenced this pull request Sep 6, 2024
* [Workspace]Validate features parameter in workspace create and update API (#7884)

* Add validate for features field in workspace create and update API

Signed-off-by: Lin Wang <[email protected]>

* Changeset file for PR #7884 created/updated

* Changeset file for PR #7884 created/updated

* Move router outside align with other plugins

Signed-off-by: Lin Wang <[email protected]>

* Add ut and fix integration tests

Signed-off-by: Lin Wang <[email protected]>

* Import use case id from default nav groups

Signed-off-by: Lin Wang <[email protected]>

* Fix workspace routes UT

Signed-off-by: Lin Wang <[email protected]>

* Share feature config generator between publicn and server

Signed-off-by: Lin Wang <[email protected]>

* Fix osd server crashed due to import from public

Signed-off-by: Lin Wang <[email protected]>

---------

Signed-off-by: Lin Wang <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>

* [Workspace]Fix dynamicConfigServiceMock import path in workspace routes UT (#7954)

* Fix dynamicConfigServiceMock import path in workspace routes UT

Signed-off-by: Lin Wang <[email protected]>

* Changeset file for PR #7954 created/updated

---------

Signed-off-by: Lin Wang <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>

---------

Signed-off-by: Lin Wang <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
(cherry picked from commit d3ce40f)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
SuZhou-Joe pushed a commit that referenced this pull request Sep 6, 2024
* [Workspace]Validate features parameter in workspace create and update API (#7884)

* Add validate for features field in workspace create and update API



* Changeset file for PR #7884 created/updated

* Changeset file for PR #7884 created/updated

* Move router outside align with other plugins



* Add ut and fix integration tests



* Import use case id from default nav groups



* Fix workspace routes UT



* Share feature config generator between publicn and server



* Fix osd server crashed due to import from public



---------




* [Workspace]Fix dynamicConfigServiceMock import path in workspace routes UT (#7954)

* Fix dynamicConfigServiceMock import path in workspace routes UT



* Changeset file for PR #7954 created/updated

---------




---------



(cherry picked from commit d3ce40f)

Signed-off-by: Lin Wang <[email protected]>
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: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.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.

4 participants