-
Notifications
You must be signed in to change notification settings - Fork 916
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
[Chore] Visualize link fix #2395
Conversation
Signed-off-by: Matt Provost <provomat@amazon.com>
Codecov Report
@@ 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
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this 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:
- Enable Wizard: Set the last flag in
opensearch_dashboards.yml
config to truewizard.enabled:true
- Create a new visualization using the wizard type and save it
- Go to the visualization table and try to edit it
Signed-off-by: Matt Provost <provomat@amazon.com>
…shboards into visualize_link_fix
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? |
Hi @ashwin-pc |
Hey @bandinib-amzn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ship it 🚢
history.push(editUrl); | ||
} | ||
}} | ||
href={editApp ? application.getUrlForApp(editApp, { path: editUrl }) : `#${editUrl}`} |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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:
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.
OpenSearch-Dashboards/src/plugins/dashboard/public/application/listing/dashboard_listing.js
Lines 173 to 177 in 48fe60b
render: (field, record) => ( | |
<EuiLink | |
href={this.props.getViewUrl(record)} | |
data-test-subj={`dashboardListingTitleLink-${record.title.split(' ').join('-')}`} | |
> |
There was a problem hiding this comment.
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}`} |
There was a problem hiding this comment.
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.
* Fix links in visualize plugin * Fix links to other apps Signed-off-by: Matt Provost <provomat@amazon.com> (cherry picked from commit 551ffa3)
* Fix links in visualize plugin * Fix links to other apps Signed-off-by: Matt Provost <provomat@amazon.com> (cherry picked from commit 551ffa3)
* Fix links in visualize plugin * Fix links to other apps Signed-off-by: Matt Provost <provomat@amazon.com> (cherry picked from commit 551ffa3)
* Fix links in visualize plugin * Fix links to other apps Signed-off-by: Matt Provost <provomat@amazon.com> (cherry picked from commit 551ffa3)
Nice, great job. @BSFishy and Thanks @ashwin-pc @bandinib-amzn @joshuarrrr for the review. |
* Fix links in visualize plugin * Fix links to other apps Signed-off-by: Matt Provost <provomat@amazon.com> (cherry picked from commit 551ffa3) Co-authored-by: Matt Provost <mattprovost6@gmail.com> Co-authored-by: Kawika Avilla <kavilla414@gmail.com>
* Fix links in visualize plugin * Fix links to other apps Signed-off-by: Matt Provost <provomat@amazon.com> Signed-off-by: Sergey V. Osipov <sipopo@yandex.ru>
Description
Change the links in the visualize plugin to use
href
rather thanonClick
. This is beneficial, as it allows links to be opened in new tabs, and helps with accessibility, as the elements area
instead ofbutton
now.Issues Resolved
#2197
Check List
yarn test:jest
yarn test:jest_integration
yarn test:ftr