-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Conversation
embeddablePersistableStateService: embeddableStart, | ||
} | ||
); | ||
Object.assign(so, newAttributes); |
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.
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`; |
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.
Do we have a naming convention for reference names?
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.
not yet, i agree it would be useful to have one
extractedReferencesResult.forEach((res) => { | ||
panelReferences.push(...res.references); | ||
}); | ||
|
||
panels.forEach((panel, i) => { |
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.
can we create an issue to move this inside embeddable reference extraction (rather than having it here on dashboard) ?
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 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.
9cd13a8
to
03ee1a6
Compare
@@ -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']), |
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.
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\\"}]", |
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.
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< |
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.
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 }), |
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 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": "[]", |
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.
{}
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?
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.
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.
@@ -11,6 +11,12 @@ | |||
"title": "[Logs Sample] Overview ECS", | |||
"version": 1 | |||
}, | |||
"references": [ | |||
{ "id": "sample_visualization", "name": "panel_0", "type": "visualization" }, |
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.
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)
Pinging @elastic/kibana-app-arch (Team:AppArch) |
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.
code LGTM
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.
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!
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.
LGTM
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
|
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Module Count
Async chunks
Distributable file count
Page load bundle
History
To update your PR or re-run it, just comment with: |
* 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)
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