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 saved object references for dashboard drilldowns #82602

Merged
merged 6 commits into from
Nov 12, 2020

Conversation

Dosant
Copy link
Contributor

@Dosant Dosant commented Nov 4, 2020

Summary

Closes #71409

This PR integrates embeddables persistable state service with dashboard app to handle references to other dashboards created by dashboard drilldowns.

In addition to extracting and injecting references on a client-side dashboard, this pr also adds a 7.11.0 dashboard migration that extracts dashboardIds from existing drilldowns and puts them to dashboard's references. To achieve this bunch of client-side dashboard/embeddable code had to be moved to common to be reused on the client-side.

Release Notes

Dashboards connected via drilldowns are now exported or copied to a different space together.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@Dosant Dosant changed the title Dev/dashboard drilldown so 2 Use saved object references for dashboard drilldowns Nov 5, 2020
embeddablePersistableStateService: embeddableStart,
}
);
Object.assign(so, newAttributes);
Copy link
Contributor Author

@Dosant Dosant Nov 5, 2020

Choose a reason for hiding this comment

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

Not sure about this, but this seem to be working.
I had to decouple injectReferences from client side DashboardSavedObject class to reuse this on server.
Don't see any other way

>;

const generateRefName = (state: SerializedEvent, id: string) =>
`drilldown:${id}:${state.eventId}:dashboardId`;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we have a naming convention for reference names?

Copy link
Member

Choose a reason for hiding this comment

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

not yet, i agree it would be useful to have one

@Dosant Dosant requested a review from ppisljar November 5, 2020 12:18
extractedReferencesResult.forEach((res) => {
panelReferences.push(...res.references);
});

panels.forEach((panel, i) => {
Copy link
Member

Choose a reason for hiding this comment

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

can we create an issue to move this inside embeddable reference extraction (rather than having it here on dashboard) ?

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 added a comment and created a placeholder issue: 9cd13a8

I am not 100% sure though that it is possible without breaking changes and if this is required. This extract/inject now operates on dashboard panel specific data model and not on embeddable model.

@Dosant Dosant closed this Nov 6, 2020
@Dosant Dosant force-pushed the dev/dashboard-drilldown-so-2 branch from 9cd13a8 to 03ee1a6 Compare November 6, 2020 15:06
@Dosant Dosant reopened this Nov 6, 2020
@@ -49,7 +48,7 @@ export function convertPanelStateToSavedDashboardPanel(
type: panelState.type,
gridData: panelState.gridData,
panelIndex: panelState.explicitInput.id,
embeddableConfig: omit(panelState.explicitInput, ['id', 'savedObjectId']),
embeddableConfig: omit(panelState.explicitInput, ['id', 'savedObjectId', 'title']),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit:
I noticed that title was not omitted even though it is copied on a root level of the object.
This is causing duplicate title in each panel of dashboard SO which caught my eye in new unit tests.

Object {
"attributes": Object {
"foo": true,
"panelsJSON": "[{\\"embeddableConfig\\":{},\\"title\\":\\"Title 1\\",\\"panelRefName\\":\\"panel_0\\"},{\\"embeddableConfig\\":{},\\"title\\":\\"Title 2\\",\\"panelRefName\\":\\"panel_1\\"}]",
Copy link
Contributor Author

@Dosant Dosant Nov 6, 2020

Choose a reason for hiding this comment

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

In each of these snapshots embeddableConfig:{} is added because now underlying code converts to EmbeddablePanel and then back. We don't clean up embeddableConfig when we convert from EmbeddablePanel to DashboardSavedPanel. I think having embeddableConfig is technically more correct and initial doc is just not in a complete shape.

Other option could be to remove embeddableConfig in convertSavedDashboardPanelToPanelState if there is no keys.

export type PanelId = string;
export type SavedObjectId = string;

export interface DashboardPanelState<
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Had to move this to common from public/type/i_container
Didn't move the whole file because it contains references to client side types

plugins.uiActionsEnhanced.registerActionFactory({
id: EMBEDDABLE_TO_DASHBOARD_DRILLDOWN,
inject: createInject({ drilldownId: EMBEDDABLE_TO_DASHBOARD_DRILLDOWN }),
extract: createExtract({ drilldownId: EMBEDDABLE_TO_DASHBOARD_DRILLDOWN }),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an important bit:
We register a EMBEDDABLE_TO_DASHBOARD_DRILLDOWN server side counter part which provides extract/inject functions which will be used by dashboard migrations via EmbeddablePersistableStateService

@@ -126,7 +126,7 @@
"title": "Dashboard Foo",
"hits": 0,
"description": "",
"panelsJSON": "[{}]",
"panelsJSON": "[]",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

{} is definitely invalid panel shape :D
New dashboard migration failed because of this.
Previously this would have failed on dashboard app open.

Alternatively we could make sure that migration can swallow {}, but I am not sure what is a recommended approach?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similarly there is single change in x-pack/test/functional/es_archives/reporting/hugedata/data.json.gz which started failing during import. There was a typo in a reference name: Fanel_1 reference instead of panel_1 which led to test failures.

I just updated the data as I guess we should fail the migration in such case.

@Dosant Dosant added Feature:Dashboard Dashboard related features Feature:Drilldowns Embeddable panel Drilldowns Feature:Embedding Embedding content via iFrame release_note:enhancement Team:AppArch v7.11.0 v8.0.0 labels Nov 6, 2020
@@ -11,6 +11,12 @@
"title": "[Logs Sample] Overview ECS",
"version": 1
},
"references": [
{ "id": "sample_visualization", "name": "panel_0", "type": "visualization" },
Copy link
Contributor Author

@Dosant Dosant Nov 7, 2020

Choose a reason for hiding this comment

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

Same as #82602 (comment) and other x-pack/test/ingest_manager_api_integration/apis/fixtures/test_packages/all_assets/*. The sample dashboard JSON was incorrect as was missing references array and new migration failed when importing these sample dashboards.

proc [kibana]   log   [19:25:34.199] [error][ingestManager][plugins] Error: Could not find reference "panel_0"
[00:05:19]                   │ proc [kibana]     at panels.forEach.panel (/dev/shm/workspace/kibana-build-xpack-9/src/plugins/dashboard/common/saved_dashboard_references.js:105:13)

@Dosant Dosant marked this pull request as ready for review November 7, 2020 08:44
@Dosant Dosant requested review from a team as code owners November 7, 2020 08:44
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

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

code LGTM

Copy link
Contributor

@ThomThomson ThomThomson left a comment

Choose a reason for hiding this comment

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

Code LGTM - plenty of test coverage! Tested in chrome and everything still works as expected. Ensured saved object references were being registered properly for dashboard drilldowns. Didn't test the migrations, but the tests seem robust!

@Dosant Dosant requested a review from bhavyarm November 11, 2020 16:35
Copy link
Contributor

@bhavyarm bhavyarm left a comment

Choose a reason for hiding this comment

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

LGTM

@bhavyarm
Copy link
Contributor

bhavyarm commented Nov 12, 2020

Tested the following cases after creating drilldowns in 7.10 and running ES 8.0.0 with data pointed towards 7.10. Thanks @ThomThomson cc @LeeDr

  • Dashboards created with drilldowns in 7.10 (exported from 6.8.13) work fine in 8.0.
  • Exported dashboard saved object is successfully imported and drilldowns are fine
  • URL drilldowns are working
  • dashboard drilldowns are working
  • Regular dashboards without drilldowns are working fine
  • Drilldowns show up correctly in relationship table on saved objects
  • Can copy drilldown dashboards between spaces
  • Can export drill downs ndjson and import it successfully again

@Dosant
Copy link
Contributor Author

Dosant commented Nov 12, 2020

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
dashboard 169 170 +1
dashboardEnhanced 28 34 +6
total +7

Async chunks

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

id before after diff
dashboard 198.1KB 195.9KB -2.2KB

Distributable file count

id before after diff
default 42775 42789 +14
oss 22459 22464 +5

Page load bundle

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

id before after diff
dashboard 311.9KB 320.8KB +8.9KB
dashboardEnhanced 31.1KB 34.8KB +3.7KB
embeddable 221.6KB 221.5KB -22.0B
total +12.6KB

History

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

@Dosant Dosant merged commit eaa6553 into elastic:master Nov 12, 2020
Dosant added a commit to Dosant/kibana that referenced this pull request Nov 12, 2020
gmmorris added a commit to gmmorris/kibana that referenced this pull request Nov 12, 2020
* master:
  [Ingest Manager] Lift up registry/{stream,extract} functions (elastic#83239)
  [Reporting] Move "common" types and constants to allow cross-plugin integration (elastic#83198)
  [Lens] Add suffix formatter (elastic#82852)
  [App Search] Version documentation links (elastic#83245)
  Use saved object references for dashboard drilldowns (elastic#82602)
  Btsymbala/registered av (elastic#81910)
  [APM] Errors table for service overview (elastic#83065)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Dashboard Dashboard related features Feature:Drilldowns Embeddable panel Drilldowns Feature:Embedding Embedding content via iFrame release_note:enhancement v7.11.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dashboard drilldowns are not using saved object references
6 participants