-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Graph] Fix graph saved object references #85295
[Graph] Fix graph saved object references #85295
Conversation
Pinging @elastic/kibana-app (Team:KibanaApp) |
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 reviewed 👍 . Only minor comments
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Async chunks
Distributable file count
Saved Objects .kibana field count
History
To update your PR or re-run it, just comment with: |
* master: (53 commits) Fixing recovered instance reference bug (elastic#85412) Switch to new elasticsearch client for Visualizations (elastic#85245) Switch to new elasticsearch client for TSVB (elastic#85275) Switch to new elasticsearch client for Vega (elastic#85280) [ILM] Add shrink field to hot phase (elastic#84087) Add rolling-file appender to core logging (elastic#84735) [APM] Service overview: Dependencies table (elastic#83416) [Uptime ]Update empty message for certs list (elastic#78575) [Graph] Fix graph saved object references (elastic#85295) [APM] Create new API's to return Latency and Throughput charts (elastic#85242) [Advanced settings] Reset to default for empty strings (elastic#85137) [SECURITY SOLUTION] Bundles _source -> Fields + able to sort on multiple fields in Timeline (elastic#83761) [Fleet] Update agent listing for better status reporting (elastic#84798) [APM] enable 'sanitize_field_names' for Go (elastic#85373) Update dependency @elastic/charts to v24.4.0 (elastic#85452) Introduce external url service (elastic#81234) Deprecate disabling the security plugin (elastic#85159) [FLEET] New Integration Policy Details page for use in Integrations section (elastic#85355) [Security Solutions][Detection Engine] Fixes one liner access control with find_rules REST API chore: 🤖 remove extraPublicDirs (elastic#85454) ...
Fixes #34989
Fixes #34997
This PR fixes saved object references for Graph and makes them importable/exportable.
The problem
Right now, graph does use the reference system, but it's not storing the proper id, but the title of the index pattern instead:
In the serialized state, an
indexPatternRefName
is stored:In
x-pack/plugins/graph/public/services/persistence/saved_workspace_references.ts
the reference is placed inside the state.This part of the code wasn't touched in this PR, as it's already functioning as it should, the only issue being it contains the title instead of the id of the index pattern.
If a user would try to export/import a workspace saved object, they would get errors because the referenced index pattern can't be found.
The solution
This PR resolves this by doing the following changes:
legacyIndexPatternRef
property (x-pack/plugins/graph/server/saved_objects/migrations.ts
)migrateLegacyIndexPatternRef
(x-pack/plugins/graph/public/services/persistence/deserialize.ts
) is called, which tries to map the index pattern title to the id by searching for it in a list of all index pattern which is anyway fetched for the Graph UI. If it is successful,legacyIndexPatternRef
is removed, and the index pattern id is stored in the deserialized workspace statex-pack/plugins/graph/public/services/persistence/serialize.ts
andx-pack/plugins/graph/public/services/persistence/saved_workspace_references.ts
)Other changes
xpack.graph.loadWorkspace.missingIndexPatternErrorMessage
got improved by including the name of the index pattern causing the problem (either if loading it fails for some reason or if a legacy workspace is opened and thelegacyIndexPatternRef
can't be mapped)x-pack/plugins/graph/server/saved_objects/graph_workspace.ts
workspace saved objects are whitelisted for importing/exportingx-pack/plugins/graph/server/plugin.ts
a new UI capability "show" is added to make it possible to enable the edit link in the saved object management page for graph workspaces if the user has at least "read" permissions for the Graph app