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

[Reporting/Dashboard] Update integration to use v2 reports #108553

Merged

Conversation

jloleysens
Copy link
Contributor

@jloleysens jloleysens commented Aug 13, 2021

Summary

Closes #99890

Updates the dashboard-reporting integration so that dashboard uses v2 export types. This enables PNG/PDF reports to be generated without first needing to save as well as using locators instead of storing URLs.

How to test

  1. Start Kibana + ES on basic level license
  2. Load sample data into the cluster via the UI
  3. Open dashboard and create a new dashboard
  4. Add a visulization
  5. Add a query to the dashboard
  6. Add a filter to the dashboard
  7. Set a custom timerange on the dashboard
  8. Create a PDF and PNG report via the "Share" menu
  9. Copy the POST URL for both the PDF and PNG report and execute these against local Kibana
  10. Verify that all the reports have been generated and show the expected result in the visualisations

To reviewers

  • Will the "Copy POST URL" functionality cause any issues? I know URL length is a concern with Vega charts, but looking at the current implementation, is there anything missing?
  • I've reworked the locator to pass all state on scopedHistory.location.state instead of the URL and created a new interface called ForwardedDashboardState. This is the shape of the data dashboard should expect to find on scopedHistory.location.state.

Screenshots

Unsaved dashboard, with unsaved panel (on the left):

Screenshot 2021-08-19 at 15 29 23

Release note

Dashboard PDF and PNG reports can now be generated without requiring users to first save.

Screenshot 2021-08-17 at 12 27 16

TODO

  • Figure out how to make time filters work correctly
  • Tests

@jloleysens jloleysens added Feature:Dashboard Dashboard related features enhancement New value added to drive a business result Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.0.0 Team:AppServices v7.16.0 labels Aug 13, 2021
@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

@jloleysens jloleysens marked this pull request as ready for review August 17, 2021 10:24
@jloleysens jloleysens requested a review from a team as a code owner August 17, 2021 10:24
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-services (Team:AppServices)

@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-reporting-services (Team:Reporting Services)

@jloleysens jloleysens added release_note:enhancement impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. loe:medium Medium Level of Effort labels Aug 17, 2021
@botelastic botelastic bot added the Feature:Drilldowns Embeddable panel Drilldowns label Aug 17, 2021
  values we get from it will never contain something that cannot
  be passed to history.push
- updated types to remove some `& SerializableRecord` instances
- fixed embeddable drilldown Jest tests given that we no longer
  expect state to be in the URL
savedDashboard.title ||
i18n.translate('dashboard.share.defaultDashboardTitle', {
defaultMessage: 'Dashboard [{date}]',
values: { date: moment().toISOString(true) },
Copy link
Member

Choose a reason for hiding this comment

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

Does this date string need to be converted to the user's timezone and formatted per the time format in Advanced Settings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Whether we issue a request for v1 or v2 reports depends on the jobProviderOptions that are passed in. If they contain locatorParams then we know it's a v2 report type. To answer your question: yes v1 can be accessed from this UI and depends on the values passed in from the consumer.

I decided to keep it this way because I was not sure whether other parts of Kibana (like Canvas and visualize) still depend on v1 report types based on the params they pass in. Once they've all been updated we should remove this funcitonality - and probably send out a message that Reports now requires locators. WDYT?

savedDashboard.title ||
i18n.translate('dashboard.share.defaultDashboardTitle', {
defaultMessage: 'Dashboard [{date}]',
values: { date: moment().toISOString(true) },
Copy link
Member

Choose a reason for hiding this comment

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

Does this date string need to be converted to the user's timezone and formatted per the time format in Advanced Settings?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a great point @tsullivan ! Do you mind if I address this in a follow up PR as I did this same thing in discover

@tsullivan tsullivan changed the title [Dashboard] Update integration to use v2 reports [Reporting/Dashboard] Update integration to use v2 reports Aug 23, 2021
@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

@@ -26,7 +33,8 @@ const cleanEmptyKeys = (stateObj: Record<string, unknown>) => {

export const DASHBOARD_APP_LOCATOR = 'DASHBOARD_APP_LOCATOR';

export interface DashboardAppLocatorParams extends SerializableRecord {
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions
export type DashboardAppLocatorParams = {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: maybe add a comment about why this is not an interface?

// TODO: Remove this code once everyone is using the new PDF format, then we can also remove the legacy
// export type entirely
export const isJobV2Params = ({ sharingData }: { sharingData: Record<string, unknown> }): boolean =>
Array.isArray(sharingData.locatorParams);
Array.isArray(sharingData.locatorParams) || isObject(sharingData.locatorParams);
Copy link
Member

Choose a reason for hiding this comment

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

Would returning sharingData.locatorParams != null work more simply?

Copy link
Contributor Author

@jloleysens jloleysens Aug 25, 2021

Choose a reason for hiding this comment

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

Happy to go with your suggestion, I was trying to be more strict in what values pass the test, but I don't think it adds much value in this case.

Copy link
Member

@tsullivan tsullivan left a comment

Choose a reason for hiding this comment

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

I left a few small comments, but this LGTM!

@jloleysens
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine kibanamachine requested a review from a team as a code owner August 25, 2021 10:08
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
dashboard 266 268 +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
dashboard 138 132 -6
data 2981 2977 -4
total -10

Async chunks

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

id before after diff
dashboard 221.3KB 222.5KB +1.2KB

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
dashboard 9 10 +1

Page load bundle

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

id before after diff
dashboard 329.2KB 329.8KB +567.0B
reporting 67.4KB 67.3KB -13.0B
total +554.0B
Unknown metric groups

API count

id before after diff
dashboard 161 145 -16
data 3498 3494 -4
total -20

References to deprecated APIs

id before after diff
dashboard 165 164 -1

History

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

@jloleysens
Copy link
Contributor Author

I'm going to merge this for now so that we can get a good amount of time for this in master. I think we've addressed @ppisljar's concerns regarding types (used type Name = rather than interface to avoid issues with extending SerializableRecord. We can address further concerns in a follow up PR 👍🏻

@jloleysens jloleysens merged commit 9e04d2c into elastic:master Aug 26, 2021
@jloleysens jloleysens deleted the dashboard/update-report-to-use-v2 branch August 26, 2021 07:53
jloleysens added a commit to jloleysens/kibana that referenced this pull request Aug 26, 2021
…08553)

* very wip, updating dashboard integration to use v2 reports. at the moment time filters are not working correctly

* added missing dependency to hook

* added tests and refined ForwadedAppState interface

* remove unused import

* updated test because generating a report from an unsaved report is possible

* migrated locator to forward state on history only, reordered methods on react component

* remove unused import

* update locator test and use panel index number if panelIndex does not exist

* ensure locator params are serializable

* - moved getSerializableRecord to locator.ts to ensure that the
  values we get from it will never contain something that cannot
  be passed to history.push
- updated types to remove some `& SerializableRecord` instances
- fixed embeddable drilldown Jest tests given that we no longer
  expect state to be in the URL

* update generated api docs

* remove unused variable

* - removed SerializedRecord extension from dashboard locator params
  interface
- factored out state conversion logic from the locator getLocation

* updated locator jest tests and SerializableRecord types

* explicitly map values to dashboardlocatorparams and export serializable params type

* use serializable params type in embeddable

* factored out logic for converting panels to dashboard panels map

* use "type =" instead of "interface"

* big update to locator params: type fixes and added options key

* added comment about why we are using "type" alias instead of "interface" declaration

* simplify is v2 job param check

Co-authored-by: Kibana Machine <[email protected]>
jloleysens added a commit that referenced this pull request Aug 26, 2021
…110177)

* very wip, updating dashboard integration to use v2 reports. at the moment time filters are not working correctly

* added missing dependency to hook

* added tests and refined ForwadedAppState interface

* remove unused import

* updated test because generating a report from an unsaved report is possible

* migrated locator to forward state on history only, reordered methods on react component

* remove unused import

* update locator test and use panel index number if panelIndex does not exist

* ensure locator params are serializable

* - moved getSerializableRecord to locator.ts to ensure that the
  values we get from it will never contain something that cannot
  be passed to history.push
- updated types to remove some `& SerializableRecord` instances
- fixed embeddable drilldown Jest tests given that we no longer
  expect state to be in the URL

* update generated api docs

* remove unused variable

* - removed SerializedRecord extension from dashboard locator params
  interface
- factored out state conversion logic from the locator getLocation

* updated locator jest tests and SerializableRecord types

* explicitly map values to dashboardlocatorparams and export serializable params type

* use serializable params type in embeddable

* factored out logic for converting panels to dashboard panels map

* use "type =" instead of "interface"

* big update to locator params: type fixes and added options key

* added comment about why we are using "type" alias instead of "interface" declaration

* simplify is v2 job param check

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
@sophiec20 sophiec20 added the (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead label Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
(Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead enhancement New value added to drive a business result Feature:Dashboard Dashboard related features Feature:Drilldowns Embeddable panel Drilldowns impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. loe:medium Medium Level of Effort release_note:enhancement Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Discussion] Generating PDF/PNG reports should not require a saved object in plugin
7 participants