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

[ContentManagement] Fix Visualize List search and CRUD operations via CM #165485

Merged
merged 24 commits into from
Sep 13, 2023

Conversation

dej611
Copy link
Contributor

@dej611 dej611 commented Sep 1, 2023

Summary

Fix #163246

This PR fixes the CM problems within the Visualize List page leveraging the services already in place.
The approach here is lighter than #165292 as it passes each client via the TypesService already used to register extensions in the Visualization scope. Also the search method now transparently uses the mSearch if more content types are detected without leaking any implementation detail outside the VisualizationClient interface.

More fixes/features:

  • fixed Maps update operation definition which was missing the overwrite flag
  • Allow mSearch to accept an options object argument
  • Added new helper functions to interact with the metadata flyout in Listing page

Checklist

@dej611 dej611 changed the title [ContentManagement] Fix Visualize List search + CRUD operations via CM [ContentManagement] Fix Visualize List search and CRUD operations via CM Sep 1, 2023
@dej611 dej611 marked this pull request as ready for review September 4, 2023 10:51
@dej611 dej611 requested review from a team as code owners September 4, 2023 10:51
@dej611 dej611 added release_note:fix Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:Lens Feature:Content Management User generated content (saved objects) management Feature:Maps v8.11.0 labels Sep 4, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-visualizations (Team:Visualizations)

export interface MSearchIn<Options extends void | object = object> {
contentTypes: Array<{ contentTypeId: string; version?: Version }>;
query: MSearchQuery;
options?: Options;
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree that options make sense, but are they actually used anywhere for msearch in this pr? It seems they are not used and, as I understand, they won't work because the implementation of the msearch service wasn't changed to work with options. Or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at the implementation it seems it's dropped. I can drop it here at search wrapping function.

Copy link
Contributor

@Dosant Dosant Sep 4, 2023

Choose a reason for hiding this comment

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

got it. I suggest we revert these changes to msearch interface, because this can't be used in msearch

@@ -66,6 +66,14 @@ const deleteVisualization = async (id: string) => {
};

const search = async (query: SearchQuery = {}, options?: VisualizationSearchQuery) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does the return type of this method account for that it could return maps and lens objects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not specifically the types of those, but all adhere to a generic interface defined https://github.com/elastic/kibana/pull/165485/files#diff-72eb8e94b67c0c56b5744ac732c6164a66b68e6e4a6fb1857da4d361acb6b149R52

Having the exact types returned by this method, from my understanding, requires either a type cast or a full refactor of the architecture, as types are registered dynamically to Visualizations and there's no static way to detect the correct type.

Copy link
Contributor

@Dosant Dosant left a comment

Choose a reason for hiding this comment

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

I smoked checked the usage on visualize page and it looks good to me. just that comment amount reverting options change #165485 (comment)

great work 👏 thank you!

Copy link
Contributor

@stratoula stratoula left a comment

Choose a reason for hiding this comment

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

Vis team changes LGTM and the bug from the listing page has been fixed 🎉
There is only one unit test failing but I am approving as I dont want to block this PR. Great work Marco ❤️

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.

LGTM, tested in chrome linux

@@ -161,6 +161,8 @@ export interface SavedObjectSearchOptions {

/** Saved Object update options - Pick and Omit to customize */
export interface SavedObjectUpdateOptions<Attributes = unknown> {
/** Overwrite existing documents (defaults to false) */
Copy link
Member

Choose a reason for hiding this comment

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

why is this needed ? in the old times we used this as we didnt have the update operation, but now we have full crud operation set.

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 used by all visualization types but maps right now. I had to introduce it to maps in order to make it work within the metadata editing in visualize Listing page.
Other visualizations were using the CreateOptions type on Update in order to validate/pass the overwrite flag.
I can see how this can be removed, but I would like to move it in a follow up PR unless it's strictly required.

Copy link
Contributor

Choose a reason for hiding this comment

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

here is some context where a related bug in Lens was fixed #160116 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like a more complete explanation of this which might be best done over zoom since its modifying api types.

Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

kibana-gis changes LGTM. Thanks for adding functional test verifying map saved object types can be edited in visualize listing table.
code review, tested in chrome

@dej611 dej611 enabled auto-merge (squash) September 5, 2023 14:34
@@ -161,6 +161,8 @@ export interface SavedObjectSearchOptions {

/** Saved Object update options - Pick and Omit to customize */
export interface SavedObjectUpdateOptions<Attributes = unknown> {
/** Overwrite existing documents (defaults to false) */
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like a more complete explanation of this which might be best done over zoom since its modifying api types.

Copy link
Contributor

@mattkime mattkime left a comment

Choose a reason for hiding this comment

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

Overall, looks great, just a question about passing overwrite to to the update method. Its nice that this PR is a net removal of code.

@dej611
Copy link
Contributor Author

dej611 commented Sep 8, 2023

@mattkime as discussed offline I've removed the overwrite from the UpdateOptions and had to make it an appExtension prop which each plugin could set for its own client. Maps code remains unchanged while Lens will export it as it is required on its storage side.

@dej611 dej611 requested a review from mattkime September 12, 2023 10:11
Copy link
Contributor

@mattkime mattkime left a comment

Choose a reason for hiding this comment

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

changes look good to me, thanks!

@dej611 dej611 merged commit 01ad4c2 into elastic:main Sep 13, 2023
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
lens 1156 1157 +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 793 807 +14

Async chunks

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

id before after diff
lens 1.4MB 1.4MB -106.0B
maps 2.8MB 2.8MB -1019.0B
visualizations 264.5KB 265.2KB +716.0B
total -409.0B

Page load bundle

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

id before after diff
lens 36.3KB 36.9KB +581.0B
maps 45.3KB 46.3KB +1.1KB
visualizations 56.9KB 57.1KB +189.0B
total +1.8KB
Unknown metric groups

API count

id before after diff
visualizations 823 837 +14

History

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

cc @matthewabbott

@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Sep 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Content Management User generated content (saved objects) management Feature:Lens Feature:Maps release_note:fix Team:Visualizations Visualization editors, elastic-charts and infrastructure v8.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CM][Visualizations] Correct usage of CM in visualize library
10 participants