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]Fix error toasts in sample data page #8842

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

wanglam
Copy link
Contributor

@wanglam wanglam commented Nov 11, 2024

Description

This PR fixes error toasts in sample data page when operate install / uninstall sample data. The root cause was the user doesn't have permission to update workspace level ui settings. This PR changed update ui settings behavior when installing sample data. It won't update ui settings when user is not workspace owner or dashboards admin. To avoid using a not exists default index pattern after user uninstall sample data. This PR will disable the remove button when user is not workspace owner or dashboards admin.

Screenshot

No UI Changes

Testing the changes

  • Clone branch code and run yarn osd bootstrap --single-version loose
  • 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
  • Login with admin user
  • Create a test1 workspace and visit sample data page
  • Click "Add data" and "Remove" button in sample data cards, should able to install / uninstall sample data
  • Create a test user with admin backend_role in "Internal users" page
  • Assign "Read and write" access level to test user inside test1 workspace
  • Open a incognito window and login with test user
  • Visit sample data page of test1 workspace, click "Add data" button, should no error toasts
  • The "Remove" button should be disabled except for "Sample Observability Logs, Traces, and Metrics" sample data
  • Use admin user update test user to workspace Admin inside test1 workspace
  • Refresh page in test user tab, the remove button should be available, click remove buttons should no error toasts
  • Update savedObjects.permission.enabled to false in config/opensearch_dashboards.yml
  • Refresh test user's page, click "Add data" and "Remove" buttons in sample data page, should able to install / uninstall sample data
  • Update workspace.enabled to false in config/opensearch_dashboards.yml
  • Refresh test user's page, click "Add data" and "Remove" buttons in sample data page, should able to install / uninstall sample data
  • Update workspace.enabled to false and home:useNewHomePage to false in config/opensearch_dashboards.yml
  • Visit homepage and click "Add sample data" with test user
  • Click "Add data" and "Remove" buttons, should able to install / uninstall sample data

Changelog

  • fix: [Workspace]Fix error toasts in sample data page

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 Nov 11, 2024

Codecov Report

Attention: Patch coverage is 71.42857% with 4 lines in your changes missing coverage. Please review.

Project coverage is 60.87%. Comparing base (995d986) to head (f199290).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ic/application/components/sample_data_set_cards.js 33.33% 2 Missing ⚠️
...gins/home/public/application/sample_data_client.js 0.00% 1 Missing ⚠️
src/plugins/home/public/application/utils.ts 90.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8842   +/-   ##
=======================================
  Coverage   60.87%   60.87%           
=======================================
  Files        3799     3800    +1     
  Lines       90762    90773   +11     
  Branches    14292    14297    +5     
=======================================
+ Hits        55247    55257   +10     
  Misses      32005    32005           
- Partials     3510     3511    +1     
Flag Coverage Δ
Linux_1 29.05% <ø> (ø)
Linux_2 56.39% <ø> (ø)
Linux_3 37.80% <ø> (ø)
Linux_4 29.88% <71.42%> (+0.01%) ⬆️
Windows_1 29.06% <ø> (ø)
Windows_2 56.34% <ø> (ø)
Windows_3 37.81% <ø> (ø)
Windows_4 29.88% <71.42%> (+0.01%) ⬆️

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.

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.

2 participants