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

Refactor saved object management registry usage #54155

Conversation

kertal
Copy link
Member

@kertal kertal commented Jan 7, 2020

Summary

Management will continue to use the SavedObjectManagementRegistry for a while. However, the way it's currently used isn't necessary any more. The SavedObjectLoader services first had to be registered in the global Angular, the ids were saved in the registry. For use in Management, the services where retrieved from the global angular. This PR now registers the services directly, removes global angular registration of SavedObjectLoader servives in discover / visualize / dashboard. Timelion still needs the SavedObjectLoader registered in Angular at the moment.

Since savedSearches is no longer registered in Angular by Discover, I've also converted the last client, thetransform plugin, to get this service by calling the createSavedSearchesService function that the discover plugin offers instead.

Dev docs

Registration of the following SavedObjectLoader in Angular was removed:

  • savedSearches
  • savedVisualizations
  • savedDashboard

The plugins now provide the functions to create a SavedObjectLoader service, here's an example how the services are created now:

import { createSavedSearchesService } from '../discover';
import { TypesService, createSavedVisLoader } from '../../../visualizations/public';
import { createSavedDashboardLoader } from '../dashboard';

const services = {
   savedObjectsClient: npStart.core.savedObjects.client,
   indexPatterns: npStart.plugins.data.indexPatterns,
   chrome: npStart.core.chrome,
   overlays: npStart.core.overlays,
 };

const servicesForVisualizations = {
    ...services,
    ...{ visualizationTypes: new TypesService().start() },
  }

const savedSearches = createSavedSearchesService(services);
const savedVisualizations = createSavedVisLoader(servicesForVisualizations);
const savedDashboards = createSavedDashboardLoader(services);

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

- [ ] This was checked for cross-browser compatibility, including a check against IE11
- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
- [ ] Documentation was added for features that require explanation or tutorials
- [ ] Unit or functional tests were updated or added to match the most common scenarios
- [ ] This was checked for keyboard-only and screenreader accessibility

For maintainers

- [ ] This was checked for breaking API changes and was labeled appropriately

@kertal kertal self-assigned this Jan 8, 2020
@kertal kertal added release_note:skip Skip the PR/issue when compiling release notes v7.6.0 v8.0.0 labels Jan 9, 2020
@kertal kertal marked this pull request as ready for review January 9, 2020 12:38
@kertal kertal requested a review from a team January 9, 2020 12:38
@kertal kertal requested review from a team as code owners January 9, 2020 12:38
@kertal kertal requested review from walterra and flash1293 January 9, 2020 12:42
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.

Code LGTM, didn't test locally. This change might be worth a dev doc section.

@kertal
Copy link
Member Author

kertal commented Jan 10, 2020

thx for the review dear @flash1292 and I do agree, there should be a dev doc section about this change 👍

@lizozom
Copy link
Contributor

lizozom commented Jan 13, 2020

@elasticmachine merge upstream

Copy link
Contributor

@lizozom lizozom left a comment

Choose a reason for hiding this comment

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

Tested transform, saved objects management and timelion on Ubuntu \ Chrome
Overall code seems LGTM.
Added a couple of comments.

Copy link
Contributor

@walterra walterra left a comment

Choose a reason for hiding this comment

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

Thanks for doing the transform plugin changes. Code LGTM, also tested a local checkout.

@kertal kertal added the release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. label Jan 13, 2020
@kertal
Copy link
Member Author

kertal commented Jan 13, 2020

thx @flash1293 , @lizozom , @walterra for your reviews 🙇 . @lizozom , I'll address you're useful hints soon

…egistry' of github.com:kertal/kibana into kertal-pr-2020-01-07-refactor-saved-object-management-registry
@kertal kertal added v7.7.0 and removed v7.6.0 labels Jan 15, 2020
@kertal kertal requested a review from ppisljar January 24, 2020 17:36
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.

code lgtm, thanks for moving saved vis stuff to visualizations plugin!

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

@kertal kertal merged commit 1504e83 into elastic:master Jan 28, 2020
kertal added a commit to kertal/kibana that referenced this pull request Jan 28, 2020
* Migrate registry to TypeScript

* Migrate management code

* Migrate SavedObjectLoader services registration to management section

* Replace Angular SavedSearchLoader in transform plugin

* Migrate saved_visualizations from visualize to visualizations plugin
kertal added a commit that referenced this pull request Jan 28, 2020
* Migrate registry to TypeScript

* Migrate management code

* Migrate SavedObjectLoader services registration to management section

* Replace Angular SavedSearchLoader in transform plugin

* Migrate saved_visualizations from visualize to visualizations plugin
jloleysens added a commit to jloleysens/kibana that referenced this pull request Jan 28, 2020
…ve-out-legacy

* 'master' of github.com:elastic/kibana: (187 commits)
  [ML] Reseting categorization validation if category field is cleared (elastic#56029)
  [SIEM] Fields browser readable (elastic#56000)
  [docs] Remove unused callout (elastic#56032)
  Refactor saved object management registry usage (elastic#54155)
  [SIEM][Detection Engine] critical blocker, updates the pre-packaged rules, removes dead ones, adds license file (elastic#56090)
  Fix failing snapshot artifact tests when using env var (elastic#56063)
  Fix Github PR comment formatting (elastic#56078)
  [Maps] fix join metric field selection bugs (elastic#56044)
  Create a new menu for observability links (elastic#54847)
  [SIEM] [Detection Engine] Fixes histogram intervals  (elastic#55969)
  make test less flaky by retrying if list is re-rendered (elastic#55949)
  Remove matrix build support (elastic#54202)
  Add animation to service map layout (elastic#56042)
  [Canvas] Remove Angular and unnecessary reporting config from Canvas (elastic#54050)
  [Uptime] Simplify snapshot max to Infinity (elastic#55931)
  [Uptime] Reintroduce a column for url (elastic#55451)
  Cleanup action task params objects after successful execution (elastic#55227)
  [CI] Retry flaky tests (elastic#53961)
  Expose NP FieldFormats service to server side (elastic#55419)
  [Endpoint] EMT-65: make endpoint data types common, restructure (elastic#54772)
  ...

# Conflicts:
#	src/legacy/core_plugins/console/public/np_ready/application/components/split_panel/__snapshots__/split_panel.test.tsx.snap
#	src/legacy/core_plugins/console/public/np_ready/application/components/split_panel/containers/panel.tsx
#	src/legacy/core_plugins/console/public/np_ready/application/components/split_panel/context.tsx
#	src/legacy/core_plugins/console/public/np_ready/application/components/split_panel/index.ts
#	src/legacy/core_plugins/console/public/np_ready/application/components/split_panel/split_panel.test.tsx
#	src/legacy/ui/public/vis/editors/default/default_editor.tsx
#	src/plugins/console/public/application/components/split_panel/__snapshots__/split_panel.test.tsx.snap
#	src/plugins/console/public/application/components/split_panel/components/resizer.tsx
#	src/plugins/console/public/application/components/split_panel/containers/panel.tsx
#	src/plugins/console/public/application/components/split_panel/containers/panel_container.tsx
#	src/plugins/console/public/application/components/split_panel/context.tsx
#	src/plugins/console/public/application/components/split_panel/index.ts
#	src/plugins/console/public/application/components/split_panel/registry.ts
#	src/plugins/console/public/application/components/split_panel/split_panel.test.tsx
#	src/plugins/kibana_react/public/split_panel/__snapshots__/split_panel.test.tsx.snap
#	src/plugins/kibana_react/public/split_panel/containers/panel.tsx
#	src/plugins/kibana_react/public/split_panel/context.tsx
#	src/plugins/kibana_react/public/split_panel/index.ts
#	src/plugins/kibana_react/public/split_panel/split_panel.test.tsx
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jan 28, 2020
* master: (77 commits)
  [ML] Reseting categorization validation if category field is cleared (elastic#56029)
  [SIEM] Fields browser readable (elastic#56000)
  [docs] Remove unused callout (elastic#56032)
  Refactor saved object management registry usage (elastic#54155)
  [SIEM][Detection Engine] critical blocker, updates the pre-packaged rules, removes dead ones, adds license file (elastic#56090)
  Fix failing snapshot artifact tests when using env var (elastic#56063)
  Fix Github PR comment formatting (elastic#56078)
  [Maps] fix join metric field selection bugs (elastic#56044)
  Create a new menu for observability links (elastic#54847)
  [SIEM] [Detection Engine] Fixes histogram intervals  (elastic#55969)
  make test less flaky by retrying if list is re-rendered (elastic#55949)
  Remove matrix build support (elastic#54202)
  Add animation to service map layout (elastic#56042)
  [Canvas] Remove Angular and unnecessary reporting config from Canvas (elastic#54050)
  [Uptime] Simplify snapshot max to Infinity (elastic#55931)
  [Uptime] Reintroduce a column for url (elastic#55451)
  Cleanup action task params objects after successful execution (elastic#55227)
  [CI] Retry flaky tests (elastic#53961)
  Expose NP FieldFormats service to server side (elastic#55419)
  [Endpoint] EMT-65: make endpoint data types common, restructure (elastic#54772)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Discover Discover Application Feature:NP Migration release_note:plugin_api_changes Contains a Plugin API changes section for the breaking plugin API changes section. release_note:skip Skip the PR/issue when compiling release notes v7.7.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants