OpenSearch-Dashboards icon indicating copy to clipboard operation
OpenSearch-Dashboards copied to clipboard

Edit wizard directly on dashboard

Open abbyhu2000 opened this issue 2 years ago • 6 comments

Description

Edit wizard directly on dashboard following the steps:

  1. choose a dashboard
  2. click Edit button on the top nav bar of the dashboard
  3. select the setting button on the top right of a wizard on that dashboard
  4. click edit wizard
Screen Shot 2022-10-05 at 10 49 47 AM

When finish editing wizard, there are some different options for saving that wizard, this PR ensures the below five different flows for editing wizard all work as expected:

  1. Save and return button on top nav bar --> will save the original wizard and return back to the dashboard without displaying an additional save modal
  2. Save as button on top nav bar --> will open a save modal
    • save as new wizard toggle on + add to dashboard after saving toggle on + Save and return button
    • save as new wizard toggle on + add to dashboard after saving toggle off + Save button
    • save as new wizard toggle off + return to dashboard after saving toggle on + Save and return button
    • save as new wizard toggle off + return to dashboard after saving toggle off + Save button

Screen Shot 2022-10-05 at 10 58 12 AM

Screen Shot 2022-10-05 at 10 57 32 AM

Screen Shot 2022-10-05 at 10 57 20 AM

Issues Resolved

https://github.com/opensearch-project/OpenSearch-Dashboards/issues/2382

Check List

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

abbyhu2000 avatar Oct 05 '22 01:10 abbyhu2000

Codecov Report

Merging #2508 (55bffea) into main (ac07159) will decrease coverage by 0.01%. The diff coverage is 12.50%.

@@            Coverage Diff             @@
##             main    #2508      +/-   ##
==========================================
- Coverage   66.74%   66.72%   -0.02%     
==========================================
  Files        3201     3201              
  Lines       60948    60955       +7     
  Branches     9267     9271       +4     
==========================================
- Hits        40679    40675       -4     
- Misses      18052    18062      +10     
- Partials     2217     2218       +1     
Impacted Files Coverage Δ
...rd/public/application/utils/get_top_nav_config.tsx 56.52% <12.50%> (-10.15%) :arrow_down:
...ared/static/forms/hook_form_lib/hooks/use_field.ts 65.70% <0.00%> (-0.97%) :arrow_down:
...ic/application/models/sense_editor/sense_editor.ts 64.00% <0.00%> (-0.89%) :arrow_down:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov-commenter avatar Oct 05 '22 02:10 codecov-commenter

Now that we have some test coverage for saving and loading (thanks!), we should also include unit tests for this flow, particularly because there are five separate user flows that are a little confusing to mentally model.

joshuarrrr avatar Oct 05 '22 19:10 joshuarrrr

Now that we have some test coverage for saving and loading (thanks!), we should also include unit tests for this flow, particularly because there are five separate user flows that are a little confusing to mentally model.

@joshuarrrr Yea i agree. Do you think it is more appropriate to write functional tests for these flows? Since it involves with user clicking different button and toggle.

Also when i was writing the unit tests for get_top_nav_config() function, i included a unit test for the edit logic there. https://github.com/opensearch-project/OpenSearch-Dashboards/blob/b75e07dd45d4d6b189fbd177ee5bad60a1d08505/src/plugins/wizard/public/application/utils/get_top_nav_config.test.tsx#L140

abbyhu2000 avatar Oct 05 '22 19:10 abbyhu2000

@joshuarrrr yeah there is a functional test we plan on adding for this flow.

ashwin-pc avatar Oct 07 '22 20:10 ashwin-pc

Now that we have some test coverage for saving and loading (thanks!), we should also include unit tests for this flow, particularly because there are five separate user flows that are a little confusing to mentally model.

@joshuarrrr Yea i agree. Do you think it is more appropriate to write functional tests for these flows? Since it involves with user clicking different button and toggle.

Also when i was writing the unit tests for get_top_nav_config() function, i included a unit test for the edit logic there.

https://github.com/opensearch-project/OpenSearch-Dashboards/blob/b75e07dd45d4d6b189fbd177ee5bad60a1d08505/src/plugins/wizard/public/application/utils/get_top_nav_config.test.tsx#L140

@abbyhu2000 how was that test for the edit flow previously passing if the change is being made here?

ashwin-pc avatar Oct 08 '22 01:10 ashwin-pc

Now that we have some test coverage for saving and loading (thanks!), we should also include unit tests for this flow, particularly because there are five separate user flows that are a little confusing to mentally model.

@joshuarrrr Yea i agree. Do you think it is more appropriate to write functional tests for these flows? Since it involves with user clicking different button and toggle. Also when i was writing the unit tests for get_top_nav_config() function, i included a unit test for the edit logic there. https://github.com/opensearch-project/OpenSearch-Dashboards/blob/b75e07dd45d4d6b189fbd177ee5bad60a1d08505/src/plugins/wizard/public/application/utils/get_top_nav_config.test.tsx#L140

@abbyhu2000 how was that test for the edit flow previously passing if the change is being made here?

@ashwin-pc When i am writing my last PR(create wizard directly from dashboard), i include the editing logic in the onSave() function. So when i am writing unit tests for onSave(), i am able to mock the props of onSave and test that part of the logic. However, in order for editing wizard from dashboard to work, the logic that's needed inside the topNavConfig constant to call that onSave() function with the correct props are still missing, so this PR added those logics. Previously when we try to edit wizard directly from dashboard, the changes were not being saved after we click Save.

abbyhu2000 avatar Oct 08 '22 02:10 abbyhu2000

The backport to 2.x failed:

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

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-2508-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 d6197a7827cc6858fb31af98154f8e8324b80fe3
# Push it to GitHub
git push --set-upstream origin backport/backport-2508-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x

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