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

[Chore] Visualize link fix #2395

Merged
merged 4 commits into from
Oct 4, 2022

Conversation

BSFishy
Copy link
Contributor

@BSFishy BSFishy commented Sep 20, 2022

Description

Change the links in the visualize plugin to use href rather than onClick. This is beneficial, as it allows links to be opened in new tabs, and helps with accessibility, as the elements are a instead of button now.

Issues Resolved

#2197

Check List

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

@BSFishy BSFishy requested a review from a team as a code owner September 20, 2022 21:24
@codecov-commenter
Copy link

codecov-commenter commented Sep 20, 2022

Codecov Report

Merging #2395 (7a29f5c) into main (06abe83) will increase coverage by 0.00%.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #2395   +/-   ##
=======================================
  Coverage   66.74%   66.75%           
=======================================
  Files        3194     3194           
  Lines       60803    60803           
  Branches     9238     9238           
=======================================
+ Hits        40585    40589    +4     
+ Misses      18009    18007    -2     
+ Partials     2209     2207    -2     
Impacted Files Coverage Δ
...ared/static/forms/hook_form_lib/hooks/use_field.ts 65.70% <0.00%> (-0.97%) ⬇️
...ic/application/models/sense_editor/sense_editor.ts 64.88% <0.00%> (+0.88%) ⬆️
packages/osd-optimizer/src/node/cache.ts 52.77% <0.00%> (+2.77%) ⬆️
...s/osd-optimizer/src/node/node_auto_tranpilation.ts 87.75% <0.00%> (+4.08%) ⬆️

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

@ashwin-pc ashwin-pc changed the title Visualize link fix [Bug] Visualize link fix Sep 21, 2022
@ashwin-pc ashwin-pc changed the title [Bug] Visualize link fix [Chore] Visualize link fix Sep 21, 2022
@ashwin-pc ashwin-pc added the a11y label Sep 21, 2022
Copy link
Member

@ashwin-pc ashwin-pc left a comment

Choose a reason for hiding this comment

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

This fix does not work with aliased visualizations. e.g. Vis Builder aka Wizard.

I didn't look too closely into why but the steps to repro this are:

  1. Enable Wizard: Set the last flag in opensearch_dashboards.yml config to true wizard.enabled:true
  2. Create a new visualization using the wizard type and save it
  3. Go to the visualization table and try to edit it

You should see
Screen Shot 2022-09-22 at 1 37 30 AM

@BSFishy
Copy link
Contributor Author

BSFishy commented Sep 22, 2022

Also, something that just came to me that I think might be up for discussion is link prefetching. It's out of the scope of this issue and PR, but I think that it might be useful. I don't think the regular load speed is much of an issue, but if the link is opened in a new tab, the page can take a little bit of time to load which I think prefetching would help with. Should I open a new issue to discuss this further?

cc @ashwin-pc @kavilla

@BSFishy BSFishy requested review from ashwin-pc and kavilla and removed request for kavilla September 22, 2022 19:01
@bandinib-amzn
Copy link
Member

This fix does not work with aliased visualizations. e.g. Vis Builder aka Wizard.

I didn't look too closely into why but the steps to repro this are:

  1. Enable Wizard: Set the last flag in opensearch_dashboards.yml config to true wizard.enabled:true
  2. Create a new visualization using the wizard type and save it
  3. Go to the visualization table and try to edit it

You should see Screen Shot 2022-09-22 at 1 37 30 AM

Hi @ashwin-pc
I followed your steps to repro the issue but couldn't reproduce it. I'm not getting Page not found error. I tried both Edit action and Open Link in new tab/new window.

@BSFishy
Copy link
Contributor Author

BSFishy commented Sep 22, 2022

This fix does not work with aliased visualizations. e.g. Vis Builder aka Wizard.
I didn't look too closely into why but the steps to repro this are:

  1. Enable Wizard: Set the last flag in opensearch_dashboards.yml config to true wizard.enabled:true
  2. Create a new visualization using the wizard type and save it
  3. Go to the visualization table and try to edit it

You should see Screen Shot 2022-09-22 at 1 37 30 AM

Hi @ashwin-pc I followed your steps to repro the issue but couldn't reproduce it. I'm not getting Page not found error. I tried both Edit action and Open Link in new tab/new window.

Hey @bandinib-amzn
I actually fixed that bug in this commit. You would probably find it again if you pulled from a previous commit, but it should be fixed now.

Copy link
Member

@ashwin-pc ashwin-pc left a comment

Choose a reason for hiding this comment

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

Ship it 🚢

@seraphjiang seraphjiang assigned BSFishy and KrooshalUX and unassigned BSFishy Sep 25, 2022
@seraphjiang seraphjiang added the ux / ui Improvements or additions to user experience, flows, components, UI elements label Sep 25, 2022
history.push(editUrl);
}
}}
href={editApp ? application.getUrlForApp(editApp, { path: editUrl }) : `#${editUrl}`}
Copy link
Member

@joshuarrrr joshuarrrr Sep 28, 2022

Choose a reason for hiding this comment

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

@BSFishy I really like the direction you've gone with this, but unfortunately it's not sufficient to hardcode the # prefix to the editUrl. The reason that works for the wizard plugin is that we define #/ as the aliasPath here: https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/plugins/wizard/public/plugin.ts#L117 . This may cause regressions for aliased visualizations with other aliasPaths.

My suspicion is that we may need to adjust the way editUrl is fetched for aliased visualizations upstream of this component so that it correctly accounts for the aliasPath.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just did a bit of digging, and I think this should work fine. The reason that it works with the wizard plugin is because it defines its own application, causing it to call getUrlForApp. Otherwise, it will follow the same functionality that was done by navigateToUrl. In that function, a call was made to history.push, which is implemented in the history package. In that package, they simply prepend a # to the beginning of the path:

https://github.com/remix-run/history/blob/3e9dab413f4eda8d6bce565388c5ddb7aeff9f7e/packages/history/index.ts#L693

I can still have it get the url upstream of this component, though, like the DashboardListing component does, however in that component, the getViewUrl function is a property, which I think would be a breaking change.

render: (field, record) => (
<EuiLink
href={this.props.getViewUrl(record)}
data-test-subj={`dashboardListingTitleLink-${record.title.split(' ').join('-')}`}
>

Copy link
Member

Choose a reason for hiding this comment

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

Ah, thanks for digging into the history implementation, that makes sense.

history.push(editUrl);
}
}}
href={editApp ? application.getUrlForApp(editApp, { path: editUrl }) : `#${editUrl}`}
Copy link
Member

Choose a reason for hiding this comment

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

Ah, thanks for digging into the history implementation, that makes sense.

@joshuarrrr joshuarrrr merged commit 551ffa3 into opensearch-project:main Oct 4, 2022
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 4, 2022
* Fix links in visualize plugin
* Fix links to other apps

Signed-off-by: Matt Provost <[email protected]>
(cherry picked from commit 551ffa3)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 4, 2022
* Fix links in visualize plugin
* Fix links to other apps

Signed-off-by: Matt Provost <[email protected]>
(cherry picked from commit 551ffa3)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 4, 2022
* Fix links in visualize plugin
* Fix links to other apps

Signed-off-by: Matt Provost <[email protected]>
(cherry picked from commit 551ffa3)
opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 4, 2022
* Fix links in visualize plugin
* Fix links to other apps

Signed-off-by: Matt Provost <[email protected]>
(cherry picked from commit 551ffa3)
@seraphjiang
Copy link
Member

Nice, great job. @BSFishy and Thanks @ashwin-pc @bandinib-amzn @joshuarrrr for the review.

@kavilla kavilla added the v2.4.0 'Issues and PRs related to version v2.4.0' label Oct 6, 2022
kavilla pushed a commit that referenced this pull request Oct 6, 2022
* Fix links in visualize plugin
* Fix links to other apps

Signed-off-by: Matt Provost <[email protected]>
(cherry picked from commit 551ffa3)
joshuarrrr pushed a commit that referenced this pull request Oct 10, 2022
* Fix links in visualize plugin
* Fix links to other apps

Signed-off-by: Matt Provost <[email protected]>
(cherry picked from commit 551ffa3)

Co-authored-by: Matt Provost <[email protected]>
joshuarrrr pushed a commit that referenced this pull request Oct 10, 2022
* Fix links in visualize plugin
* Fix links to other apps

Signed-off-by: Matt Provost <[email protected]>
(cherry picked from commit 551ffa3)

Co-authored-by: Matt Provost <[email protected]>
Co-authored-by: Kawika Avilla <[email protected]>
kavilla pushed a commit that referenced this pull request Oct 11, 2022
* Fix links in visualize plugin
* Fix links to other apps

Signed-off-by: Matt Provost <[email protected]>
(cherry picked from commit 551ffa3)
sipopo pushed a commit to sipopo/OpenSearch-Dashboards that referenced this pull request Dec 16, 2022
* Fix links in visualize plugin
* Fix links to other apps

Signed-off-by: Matt Provost <[email protected]>
Signed-off-by: Sergey V. Osipov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y backport 1.3 backport 2.x ux / ui Improvements or additions to user experience, flows, components, UI elements v1.3.7 v2.4.0 'Issues and PRs related to version v2.4.0'
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants