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

[Visualization] Get rid of saved object loader and use savedObjectClient resolve #113121

Merged
merged 38 commits into from
Oct 11, 2021

Conversation

VladLasitsa
Copy link
Contributor

@VladLasitsa VladLasitsa commented Sep 27, 2021

Closes: #105809

Summary

Get rid of SavedObjectLoader in Visualization. This work is done because the SavedObject class has been deprecated and will be removed in Kibana 8

What was done:

  • 🏁 Created a simple functions for get/save visualization and use it from all external plugins instead of SavedObjectLoader
  • 🏁 savedObject.get was replaced to savedObject.resolve
  • 🏁 added handling of cases when we get conflict and aliasMatch

@VladLasitsa
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Not finished yet, but noticed one thing I want to change in general

src/plugins/visualizations/public/index.ts Outdated Show resolved Hide resolved
@VladLasitsa
Copy link
Contributor Author

@elasticmachine merge upstream

@flash1293 flash1293 marked this pull request as ready for review October 6, 2021 08:02
@flash1293 flash1293 requested a review from a team as a code owner October 6, 2021 08:02
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-vis-editors (Team:VisEditors)

@flash1293
Copy link
Contributor

@elasticmachine merge upstream

@VladLasitsa VladLasitsa added the release_note:skip Skip the PR/issue when compiling release notes label Oct 6, 2021
@flash1293
Copy link
Contributor

This looks mostly good to me. However just yesterday evening a unified error component got merged to guide the user into the right direction to delete the alias: #112606

This is how it looks right now:
Screenshot 2021-10-06 at 10 24 23

This is how it should look:
Screenshot 2021-10-06 at 10 29 21

See for example the usage in Lens:

if (sharingSavedObjectProps?.outcome === 'conflict' && this.deps.spaces) {

We can do this on a separate PR to get this one merged, but we should definitely align here.

Copy link
Contributor

@flash1293 flash1293 left a comment

Choose a reason for hiding this comment

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

Tested and didn't notice any weird behavior anymore, LGTM

Added some nits about anys in there (we should not introduce them anymore)

src/plugins/visualizations/public/types.ts Outdated Show resolved Hide resolved
src/plugins/visualizations/public/plugin.ts Outdated Show resolved Hide resolved
@VladLasitsa
Copy link
Contributor Author

@elasticmachine merge upstream

@VladLasitsa VladLasitsa requested a review from alexwizp October 7, 2021 12:45
Comment on lines +172 to +181
if (savedObject.sharingSavedObjectProps?.outcome === 'conflict') {
return new ErrorEmbeddable(
i18n.translate('visualizations.embeddable.legacyURLConflict.errorMessage', {
defaultMessage: `This visualization has the same URL as a legacy alias. Disable the alias to resolve this error : {json}`,
values: { json: savedObject.sharingSavedObjectProps?.errorJSON },
}),
input,
parent
);
}
Copy link
Contributor

@jportner jportner Oct 10, 2021

Choose a reason for hiding this comment

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

As @flash1293 mentioned in #113121 (comment), the Spaces plugin now provides a component for this. Whether you want to change it in this PR or leave it for a follow-on PR, I just wanted to leave a note and let you know that I made some additional changes to it in #114172.
You can load this component with spaces.ui.components.getEmbeddableLegacyUrlConflict; you can see how Lens consumes it here:

if (sharingSavedObjectProps?.outcome === 'conflict' && this.deps.spaces) {
const conflictError = {
shortMessage: i18n.translate('xpack.lens.embeddable.legacyURLConflict.shortMessage', {
defaultMessage: `You've encountered a URL conflict`,
}),
longMessage: (
<this.deps.spaces.ui.components.getEmbeddableLegacyUrlConflict
targetType={DOC_TYPE}
sourceId={sharingSavedObjectProps.sourceId!}
/>
),
};
this.errors = this.errors ? [...this.errors, conflictError] : [conflictError];
}

The sourceId is the ID of the saved object.

@flash1293
Copy link
Contributor

@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
visualizations 107 108 +1

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
visualizations 257 286 +29

Async chunks

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

id before after diff
visualizations 72.6KB 72.7KB +84.0B
visualize 51.9KB 53.1KB +1.2KB
total +1.3KB

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
visualizations 15 16 +1

Page load bundle

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

id before after diff
visualizations 33.0KB 39.0KB +6.0KB
visualize 16.0KB 15.9KB -47.0B
total +6.0KB
Unknown metric groups

API count

id before after diff
visualizations 275 304 +29

References to deprecated APIs

id before after diff
visualizations 104 102 -2

History

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

@VladLasitsa VladLasitsa merged commit 41c813b into elastic:master Oct 11, 2021
VladLasitsa added a commit to VladLasitsa/kibana that referenced this pull request Oct 11, 2021
…ent resolve (elastic#113121)

* First step: create saved_visualize_utils, starting use new get/save methods

* Use new util methods in embeddable

* move findListItem in utils

* some clean up

* clean up

* Some fixes

* Fix saved object tags

* Some types fixes

* Fix unit tests

* Clean up code

* Add unit tests for new utils

* Fix lint

* Fix tagging

* Add unit tests

* Some fixes

* Clean up code

* Fix lint

* Fix types

* put new methods in start contract

* Fix imports

* Fix lint

* Fix comments

* Fix lint

* Fix CI

* use local url instead of full path

* Fix unit test

* Some clean up

* Fix nits

* fix types

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
VladLasitsa added a commit that referenced this pull request Oct 12, 2021
…ent resolve (#113121) (#114442)

* First step: create saved_visualize_utils, starting use new get/save methods

* Use new util methods in embeddable

* move findListItem in utils

* some clean up

* clean up

* Some fixes

* Fix saved object tags

* Some types fixes

* Fix unit tests

* Clean up code

* Add unit tests for new utils

* Fix lint

* Fix tagging

* Add unit tests

* Some fixes

* Clean up code

* Fix lint

* Fix types

* put new methods in start contract

* Fix imports

* Fix lint

* Fix comments

* Fix lint

* Fix CI

* use local url instead of full path

* Fix unit test

* Some clean up

* Fix nits

* fix types

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Visualizations Generic visualization features (in case no more specific feature label is available) release_note:skip Skip the PR/issue when compiling release notes Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.16.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Visualize] Switch to SavedObjectClient.resolve
7 participants