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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,7 @@ export const getTableColumns = (
// In case an error occurs i.e. the vis has wrong type, we render the vis but without the link
!error ? (
<EuiLink
onClick={() => {
if (editApp) {
application.navigateToApp(editApp, { path: editUrl });
} else if (editUrl) {
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.

data-test-subj={`visListingTitleLink-${title.split(' ').join('-')}`}
>
{field}
Expand Down