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

[Discover] Removing SavedObject usage for savedSearch #112983

Merged
merged 34 commits into from
Oct 13, 2021

Conversation

alexwizp
Copy link
Contributor

@alexwizp alexwizp commented Sep 23, 2021

Closes: #105810

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

To avoid the PR affecting many files, I suggest breaking it down into several parts:

  • Step 1 (7.16 and 8.0):
    The goal of this step is to get rid of legacy dependencies in all external plugins. What should be done:

    • 🏁 Mark all code related to savedSearch SavedObject as deprecated and move into legacy folder.
    • 🏁 Create a simple function for getting savedSearch and use it from all external plugins instead of SavedObjectLoader;
    • 🏁 remove lastSavedTitle from SavedSearch
    • 🏁 savedObject.get should be replaced to savedObject.resolve
  • Step 2 (7.16 and 8.0):

    • 🏁 Discover works with ISearchSource, SearchSource type should be replaced to ISearchSource
    • 🏁 Remove getSavedSearchById and getSavedSearchUrlById from the DiscoverServices API;
    • 🏁 Refactor Discover to work with savedSearch'es without SavedObject.
  • Step 3 (7.16 and 8.0):

  • Step 4 (only for 8.0): 🏃

    • completely remove SavedObjectLoader

Testing notes:

This PR contains changes with replacing get() to resolve() for support of Sharing Saved Objects. To test it follow the following guide #107099 (comment)

Screens:

SavedSearchURLConflictCallout:
image

Redirect:
image

Conflict index pattern:
image

Transform plugin:
image

@alexwizp alexwizp force-pushed the discover-saved-object-loader branch 2 times, most recently from 7a5fe7f to 7000224 Compare September 24, 2021 10:24
@alexwizp alexwizp force-pushed the discover-saved-object-loader branch 3 times, most recently from 2af74a6 to bb32a6a Compare September 24, 2021 14:20
@alexwizp
Copy link
Contributor Author

@elasticmachine merge upstream

@alexwizp alexwizp changed the title [Discover] Step 1 - remove SavedObjectLoader [Discover] Removing SavedObject usage for savedSearch Sep 27, 2021
@alexwizp
Copy link
Contributor Author

@elasticmachine merge upstream

@alexwizp alexwizp force-pushed the discover-saved-object-loader branch 4 times, most recently from ab44b21 to 61d82f7 Compare September 29, 2021 10:58
@elastic elastic deleted a comment from kibanamachine Sep 29, 2021
@alexwizp alexwizp force-pushed the discover-saved-object-loader branch 3 times, most recently from 269ae6b to 5a6e2f0 Compare September 29, 2021 16:43
@elastic elastic deleted a comment from kibanamachine Sep 29, 2021
@elastic elastic deleted a comment from kibanamachine Sep 29, 2021
@elastic elastic deleted a comment from kibanamachine Sep 29, 2021
@alexwizp alexwizp self-assigned this Sep 30, 2021
@alexwizp alexwizp added v7.16.0 v8.0.0 Team:Visualizations Visualization editors, elastic-charts and infrastructure release_note:enhancement labels Sep 30, 2021
@flash1293
Copy link
Contributor

@elastic/kibana-reporting-services could we get a review on this?

@VladLasitsa
Copy link
Contributor

Found two minor issues while re-testing. The rest looks good to me.

  • When trying to save a search "as new" (switch in the modal) and pick a name which exists already, the warning about duplicate names is shown, but pressing the button a second time doesn't save the search under this name
Screenshot 2021-10-11 at 09 55 25
  • When accessing discover with a conflicting index pattern, the error page is rendered. But when loading a saved search via deeplink, it's stuck at the loading spinner:
Screenshot 2021-10-11 at 10 13 45

@flash1293 I think I fixed these issues.

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.

Comments got addressed, works fine for me 👍

@VladLasitsa
Copy link
Contributor

@elasticmachine merge upstream

Copy link
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

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

Is there a way we could improve showing a conflicting saved search? Because currently users need to navigate to a different application, return to Discover, to have it removed. This is confusing, because first you'll try to reload the page, but the last link of Discover is still in session, which means, still the conflict screen is displayed. So I think showing the default view with the default index pattern and showing an error message about the conflicting saved object would be a better experience in this case.

@flash1293
Copy link
Contributor

flash1293 commented Oct 12, 2021

Is there a way we could improve showing a conflicting saved search? Because currently users need to navigate to a different application, return to Discover, to have it removed

This should not be the case, a conflicted saved search loads just fine (and shows a warning callout above the app). I'm guessing you are talking about the case with a conflicted index pattern (if you follow Joe Portners script with an export containing both index pattern and saved search, it will actually put both into a conflicting state). We discussed this with Joe and the current guidance is to fail on conflicts on "secondary saved objects" (SOs managed by some other part of Kibana, but used in the current view) - this is also how dashboard behaves (even though it's just per panel there). I don't have a strong opinion on this - @jportner what do you think?

@kertal
Copy link
Member

kertal commented Oct 12, 2021

Is there a way we could improve showing a conflicting saved search? Because currently users need to navigate to a different application, return to Discover, to have it removed

This should not be the case, a conflicted saved search loads just fine (and shows a warning callout above the app). I'm guessing you are talking about the case with a conflicted index pattern (if you follow Joe Portners script with an export containing both index pattern and saved search, it will actually put both into a conflicting state).

yes, exactly that's what I did. fine with failing here, just to remove the failure in this special case could be improved

@flash1293
Copy link
Contributor

We do the "show toast and go to default view of the app" in some other error cases (e.g. Visualize). Could be done here as well, but we would have to make sure to not enter a loop (what if the default index pattern is conflicted?)

@kertal
Copy link
Member

kertal commented Oct 12, 2021

(what if the default index pattern is conflicted?)

yes, this could be the case. Is there a way to remove or clean the last discover URL in the session in case there's an conflicting error?

@jportner
Copy link
Contributor

We discussed this with Joe and the current guidance is to fail on conflicts on "secondary saved objects" (SOs managed by some other part of Kibana, but used in the current view) - this is also how dashboard behaves (even though it's just per panel there). I don't have a strong opinion on this - @jportner what do you think?

Yeah, for the most consistent user experience we should do this. FWIW, a more recent development is #113335, in which we will add validation before objects are created to prevent legacy URL alias conflict scenarios from happening in the first place.

We hope no users will ever run into this in the real world, but we have this error handling out of an abundance of caution. I wouldn't worry too much about making sure this screen has a really nice workflow to help users fix the issue. If this does happen, users will need to disable the legacy URL alias using our API. With #114172 that was recently merged, the LegacyUrlConflict and EmbeddableLegacyUrlConflict components now point to the docs where users can learn more about that.

Copy link
Contributor

@VladLasitsa VladLasitsa 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 locally.

…ct-loader

# Conflicts:
#	src/plugins/discover/public/application/apps/context/services/context.ts
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
discover 394 399 +5

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
discover 56 77 +21

Async chunks

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

id before after diff
discover 327.7KB 328.5KB +770.0B
transform 322.1KB 322.3KB +183.0B
visDefaultEditor 152.6KB 152.7KB +33.0B
visualizations 72.7KB 72.8KB +134.0B
visualize 53.1KB 53.1KB +36.0B
total +1.1KB

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
discover 6 7 +1

Page load bundle

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

id before after diff
discover 19.6KB 23.6KB +4.0KB
reporting 40.9KB 40.9KB +4.0B
visDefaultEditor 19.2KB 19.3KB +138.0B
visualizations 39.0KB 38.9KB -107.0B
total +4.0KB
Unknown metric groups

API count

id before after diff
discover 82 103 +21

References to deprecated APIs

id before after diff
discover 1821 1818 -3
visDefaultEditor 223 213 -10
visualize 99 86 -13
total -26

History

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

cc @alexwizp

@kertal kertal self-requested a review October 13, 2021 08:12
Copy link
Member

@kertal kertal 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 and works as expected ... talked with @alexwizp and decided to move forward here and solve the problem with the special case of conflicts in saves search and index pattern in a follow up PR.

@alexwizp alexwizp merged commit d9ef453 into elastic:master Oct 13, 2021
alexwizp added a commit to alexwizp/kibana that referenced this pull request Oct 13, 2021
* [Discover] Step 2 - remove SavedObjectLoader

* Fix PR comments

* fix test names

* fix ts error

* add handling of missed 'so'

* add Embeddable error

* fix jest

* add DiscoverError component

* fix Joe comments

* add search params

* add throwErrorOnUrlConflict util method

* add error handling into transform plugin

* do some updates

* add spaces into visualize, visualizations

* fix Tim's comment

* pass false into createGetterSetter for getSpaces

* Fix comments

* Fix lint

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Uladzislau Lasitsa <Uladzislau_Lasitsa@epam.com>
# Conflicts:
#	src/plugins/discover/public/application/apps/context/services/context.ts
gbamparop pushed a commit to gbamparop/kibana that referenced this pull request Oct 13, 2021
* [Discover] Step 2 - remove SavedObjectLoader

* Fix PR comments

* fix test names

* fix ts error

* add handling of missed 'so'

* add Embeddable error

* fix jest

* add DiscoverError component

* fix Joe comments

* add search params

* add throwErrorOnUrlConflict util method

* add error handling into transform plugin

* do some updates

* add spaces into visualize, visualizations

* fix Tim's comment

* pass false into createGetterSetter for getSpaces

* Fix comments

* Fix lint

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Uladzislau Lasitsa <Uladzislau_Lasitsa@epam.com>
alexwizp added a commit that referenced this pull request Oct 13, 2021
…#114767)

* [Discover] Removing SavedObject usage for savedSearch (#112983)

* [Discover] Step 2 - remove SavedObjectLoader

* Fix PR comments

* fix test names

* fix ts error

* add handling of missed 'so'

* add Embeddable error

* fix jest

* add DiscoverError component

* fix Joe comments

* add search params

* add throwErrorOnUrlConflict util method

* add error handling into transform plugin

* do some updates

* add spaces into visualize, visualizations

* fix Tim's comment

* pass false into createGetterSetter for getSpaces

* Fix comments

* Fix lint

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Uladzislau Lasitsa <Uladzislau_Lasitsa@epam.com>
# Conflicts:
#	src/plugins/discover/public/application/apps/context/services/context.ts

* Update context.ts

* fix saved_object_manangement
jloleysens added a commit to jloleysens/kibana that referenced this pull request Oct 13, 2021
…ide-users-to-saving-ux

* 'master' of github.com:elastic/kibana: (133 commits)
  [DOCS] Indicate reports are a subscription feature (elastic#114653)
  Update namespace for indices (elastic#114612)
  [DOCS] Adds Logstash pipeline settings (elastic#114648)
  Bump EPR snapshot version used for tests (elastic#114529)
  [Security Solution] [Endpoint] Fleet summary card adjustments (elastic#114291)
  skip flaky suite (elastic#68400)
  [Visualizations] fix usage of optional dependencies (elastic#114286)
  [Security Solution] [Detections] Improves custom query rule upgrade test (elastic#114454)
  [fleet] Add Integration Preference selector (elastic#114432)
  [Reporting] Add new `data-render-error` attribute (elastic#114472)
  Replace EuiCodeEditor with CodeEditor in app-services code (elastic#114316)
  [data views] add getDefaultDataView method  (elastic#113891)
  [Security Solution] [Endpoint] Event filters uses the new card design (elastic#114126)
  [fleet] Tweak Header UI (elastic#114704)
  [APM] Filter on tx metrics for instance stats (elastic#114758)
  [APM] Fix typo in linting docs (elastic#114764)
  [Discover] Removing SavedObject usage for savedSearch (elastic#112983)
  [Fleet] Add Integration Policy Page Improvements (elastic#114556)
  [Lens] Keep the custom label when transitioning to/from Formula (elastic#114270)
  [Security Solution][Endpoint] Host Isolation API changes (elastic#113621)
  ...
artem-shelkovnikov pushed a commit to artem-shelkovnikov/kibana that referenced this pull request Oct 20, 2021
* [Discover] Step 2 - remove SavedObjectLoader

* Fix PR comments

* fix test names

* fix ts error

* add handling of missed 'so'

* add Embeddable error

* fix jest

* add DiscoverError component

* fix Joe comments

* add search params

* add throwErrorOnUrlConflict util method

* add error handling into transform plugin

* do some updates

* add spaces into visualize, visualizations

* fix Tim's comment

* pass false into createGetterSetter for getSpaces

* Fix comments

* Fix lint

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Uladzislau Lasitsa <Uladzislau_Lasitsa@epam.com>
@flash1293 flash1293 added release_note:skip Skip the PR/issue when compiling release notes and removed release_note:enhancement labels Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

[Discover] Switch to SavedObjectClient.resolve