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

Use locators service for Discover shared URLs #154947

Merged
merged 34 commits into from
May 17, 2023

Conversation

lukasolson
Copy link
Member

@lukasolson lukasolson commented Apr 13, 2023

Summary

Resolves #148886.
Resolves #142525.
Resolves #156275.
Resolves #142522.

Uses the URL locators service for generating the URL when clicking "Share" in Discover. This enables ad-hoc data views in shared URLs. As a result, we no longer show a prompt to save the ad-hoc data view before sharing, which means we can get rid of some no-longer used hooks.

Checklist

For maintainers

Release notes

Updates Discover sharing capabilities to enable sharing a link to Discover when using ad-hoc (temporary) data views.
Enables export to CSV when using ad-hoc data views.

@lukasolson lukasolson added release_note:enhancement Feature:Discover Discover Application Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. v8.8.0 labels Apr 13, 2023
@lukasolson lukasolson requested a review from a team as a code owner April 13, 2023 18:55
@lukasolson lukasolson self-assigned this Apr 13, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@lukasolson lukasolson added the ci:cloud-deploy Create or update a Cloud deployment label Apr 13, 2023
@lukasolson
Copy link
Member Author

I still need to update functional tests for this. I'm also running into a bug where shorten URLs aren't working initially... But this may be a bug with the short URL service directly. I'm still investigating.

@lukasolson lukasolson requested a review from a team as a code owner April 21, 2023 23:07
@lukasolson
Copy link
Member Author

@kertal Could you see if this is working now as expected? As far as I can tell it's working properly now.

@kertal
Copy link
Member

kertal commented Apr 24, 2023

@kertal Could you see if this is working now as expected? As far as I can tell it's working properly now.

Generally looking good 👍
One thing I noticed it seems before saved object sharing added the global filters :
Error: expected http://localhost:5620/app/discover#/view/ab12e3c0-f231-11e6-9486-733b1ac9221a?_g=() to equal http://localhost:5620/app/discover#/view/ab12e3c0-f231-11e6-9486-733b1ac9221a?_g=(filters%3A!()%2CrefreshInterval%3A(pause%3A!t%2Cvalue%3A60000)%2Ctime%3A(from%3A\'2015-09-19T06%3A31%3A44.000Z\'%2Cto%3A\'2015-09-23T18%3A31%3A44.000Z\'))

The question is here, if the old behavior was right, since we communicate to the user we just share the URL to the saved version of the saved object?

@kertal
Copy link
Member

kertal commented Apr 24, 2023

Hurray for removing code in this PR 🥳
One thing I wonder, does relativeToAbsolute add so much to our package?
Bildschirmfoto 2023-04-24 um 09 37 56

Copy link
Contributor

@vadimkibana vadimkibana left a comment

Choose a reason for hiding this comment

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

SharedUX code changes LGTM.

@lukasolson
Copy link
Member Author

I created the bug issue for pinned filters here: #156275

@lukasolson lukasolson added v8.9.0 and removed v8.8.0 labels May 1, 2023
@lukasolson lukasolson marked this pull request as ready for review May 1, 2023 23:00
@kertal
Copy link
Member

kertal commented May 3, 2023

@elasticmachine merge upstream

@kertal kertal self-requested a review May 3, 2023 15:05
Copy link
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

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

This is great work 👍 ! Sometimes easy looking things turn into a 🐰🕳️ ! So it needs a gentle 🦊 like you to dig a bit deeper. One hopefully last thing I encountered while testing ... it seems it's not possible to create a CSV link with temporary data views, because the link gets to long? seems it contains lots of mappings?
Bildschirmfoto 2023-05-03 um 17 00 06
If there's no workaround for this we might consider to not provide this button when using temporary data views

Comment on lines +183 to +187
// This logic is duplicated from `relativeToAbsolute` (for bundle size reasons). Ultimately, this should be
// replaced when https://github.com/elastic/kibana/issues/153323 is implemented.
const link = document.createElement('a');
link.setAttribute('href', relativeUrl);
const shareableUrl = link.href;
Copy link
Member

Choose a reason for hiding this comment

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

I think this needs to be updated, since this was merged, but doesn't seem to solve the issue

#153323 (comment)

I do agree with you, it should not be necessary to use this workaround. If getUrl works it should also be possible to use getRedirectUrlas an absolute URL .. FYI @vadimkibana

Copy link
Member

Choose a reason for hiding this comment

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

Anyway thx for taking care of the bundle size @lukasolson

@lukasolson
Copy link
Member Author

One hopefully last thing I encountered while testing ... it seems it's not possible to create a CSV link with temporary data views, because the link gets to long? seems it contains lots of mappings?

This should be fixed now, do you mind giving it one more look? 🙏 🙇

@@ -107,7 +107,7 @@ export async function getSharingData(

searchSource.setField('fields', fields);
}
return searchSource.getSerializedFields(true);
return searchSource.getSerializedFields(true, false);
Copy link
Member

Choose a reason for hiding this comment

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

@lukasolson should this be false only for ad-hoc data views?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure why you'd want to send the field list/mappings in the request since they don't seem to be necessary to the POST URL. Is there something that is being accessed from this list in the CSV generation?

Copy link
Member

@tsullivan tsullivan May 17, 2023

Choose a reason for hiding this comment

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

Reporting doesn't care about the parameters, as they just get forwarded to other dependencies on the server side when the report is generating. These are all called in the kbn-generate-csv package:

  • searchSource.getSearchRequestBody()
  • data.search()
  • field formatters
  • tabifyDocs()

If those dependencies do not need the field list or mappings, then I agree with you they don't seem to be necessary. It may have just been a carryover from an older implementation.

On a side note, I find the CSV export implementation that passes a searchsource object in the parameters to be overly complex, and since it doesn't reference a saved search it isn't user-friendly for advanced users that want to automate reports of any saved search. That's why I consider the csv_searchsource export type to be tech debt: #151190

@kibana-ci
Copy link
Collaborator

kibana-ci commented May 16, 2023

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
discover 462 460 -2

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
share 59 60 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
discover 424.1KB 421.9KB -2.2KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
share 51.5KB 51.8KB +386.0B
Unknown metric groups

API count

id before after diff
share 118 119 +1

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
securitySolution 400 404 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
securitySolution 480 484 +4
total +6

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @lukasolson

@kertal kertal self-requested a review May 17, 2023 06:47
Copy link
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

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

LGTM, 🕺 Thx! Tested locally and also the CSV POST thingy now works. Once @tsullivan's question is clarified, pls ship it. Great work! Really excited we now fully support temporary data views and can remove those workarounds!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting ci:cloud-deploy Create or update a Cloud deployment Feature:Discover Discover Application release_note:enhancement release_note:fix Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. v8.9.0
Projects
None yet
8 participants